documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * 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".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * 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"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. 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;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * 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"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * 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".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, 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 right 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 LookAtRH(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 right 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 LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * 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.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * 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)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @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
  5120. * @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
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. 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);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * The options Interface for creating a Capsule Mesh
  6820. */
  6821. export interface ICreateCapsuleOptions {
  6822. /** The Orientation of the capsule. Default : Vector3.Up() */
  6823. orientation?: Vector3;
  6824. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6825. subdivisions: number;
  6826. /** Number of cylindrical segments on the capsule. */
  6827. tessellation: number;
  6828. /** Height or Length of the capsule. */
  6829. height: number;
  6830. /** Radius of the capsule. */
  6831. radius: number;
  6832. /** Height or Length of the capsule. */
  6833. capSubdivisions: number;
  6834. /** Overwrite for the top radius. */
  6835. radiusTop?: number;
  6836. /** Overwrite for the bottom radius. */
  6837. radiusBottom?: number;
  6838. /** Overwrite for the top capSubdivisions. */
  6839. topCapSubdivisions?: number;
  6840. /** Overwrite for the bottom capSubdivisions. */
  6841. bottomCapSubdivisions?: number;
  6842. }
  6843. /**
  6844. * Class containing static functions to help procedurally build meshes
  6845. */
  6846. export class CapsuleBuilder {
  6847. /**
  6848. * Creates a capsule or a pill mesh
  6849. * @param name defines the name of the mesh
  6850. * @param options The constructors options.
  6851. * @param scene The scene the mesh is scoped to.
  6852. * @returns Capsule Mesh
  6853. */
  6854. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * @hidden
  6860. */
  6861. export class IntersectionInfo {
  6862. bu: Nullable<number>;
  6863. bv: Nullable<number>;
  6864. distance: number;
  6865. faceId: number;
  6866. subMeshId: number;
  6867. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6868. }
  6869. }
  6870. declare module BABYLON {
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module BABYLON {
  6957. /**
  6958. * Class used to store bounding box information
  6959. */
  6960. export class BoundingBox implements ICullable {
  6961. /**
  6962. * Gets the 8 vectors representing the bounding box in local space
  6963. */
  6964. readonly vectors: Vector3[];
  6965. /**
  6966. * Gets the center of the bounding box in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Gets the center of the bounding box in world space
  6971. */
  6972. readonly centerWorld: Vector3;
  6973. /**
  6974. * Gets the extend size in local space
  6975. */
  6976. readonly extendSize: Vector3;
  6977. /**
  6978. * Gets the extend size in world space
  6979. */
  6980. readonly extendSizeWorld: Vector3;
  6981. /**
  6982. * Gets the OBB (object bounding box) directions
  6983. */
  6984. readonly directions: Vector3[];
  6985. /**
  6986. * Gets the 8 vectors representing the bounding box in world space
  6987. */
  6988. readonly vectorsWorld: Vector3[];
  6989. /**
  6990. * Gets the minimum vector in world space
  6991. */
  6992. readonly minimumWorld: Vector3;
  6993. /**
  6994. * Gets the maximum vector in world space
  6995. */
  6996. readonly maximumWorld: Vector3;
  6997. /**
  6998. * Gets the minimum vector in local space
  6999. */
  7000. readonly minimum: Vector3;
  7001. /**
  7002. * Gets the maximum vector in local space
  7003. */
  7004. readonly maximum: Vector3;
  7005. private _worldMatrix;
  7006. private static readonly TmpVector3;
  7007. /**
  7008. * @hidden
  7009. */
  7010. _tag: number;
  7011. /**
  7012. * Creates a new bounding box
  7013. * @param min defines the minimum vector (in local space)
  7014. * @param max defines the maximum vector (in local space)
  7015. * @param worldMatrix defines the new world matrix
  7016. */
  7017. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7018. /**
  7019. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7020. * @param min defines the new minimum vector (in local space)
  7021. * @param max defines the new maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7025. /**
  7026. * Scale the current bounding box by applying a scale factor
  7027. * @param factor defines the scale factor to apply
  7028. * @returns the current bounding box
  7029. */
  7030. scale(factor: number): BoundingBox;
  7031. /**
  7032. * Gets the world matrix of the bounding box
  7033. * @returns a matrix
  7034. */
  7035. getWorldMatrix(): DeepImmutable<Matrix>;
  7036. /** @hidden */
  7037. _update(world: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Tests if the bounding box is intersecting the frustum planes
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @returns true if there is an intersection
  7042. */
  7043. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if the bounding box is entirely inside the frustum planes
  7046. * @param frustumPlanes defines the frustum planes to test
  7047. * @returns true if there is an inclusion
  7048. */
  7049. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7050. /**
  7051. * Tests if a point is inside the bounding box
  7052. * @param point defines the point to test
  7053. * @returns true if the point is inside the bounding box
  7054. */
  7055. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7056. /**
  7057. * Tests if the bounding box intersects with a bounding sphere
  7058. * @param sphere defines the sphere to test
  7059. * @returns true if there is an intersection
  7060. */
  7061. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7062. /**
  7063. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7064. * @param min defines the min vector to use
  7065. * @param max defines the max vector to use
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if two bounding boxes are intersections
  7071. * @param box0 defines the first box to test
  7072. * @param box1 defines the second box to test
  7073. * @returns true if there is an intersection
  7074. */
  7075. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7076. /**
  7077. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7078. * @param minPoint defines the minimum vector of the bounding box
  7079. * @param maxPoint defines the maximum vector of the bounding box
  7080. * @param sphereCenter defines the sphere center
  7081. * @param sphereRadius defines the sphere radius
  7082. * @returns true if there is an intersection
  7083. */
  7084. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7085. /**
  7086. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7087. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @return true if there is an inclusion
  7090. */
  7091. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an intersection
  7097. */
  7098. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. }
  7100. }
  7101. declare module BABYLON {
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. get collisionMask(): number;
  7145. set collisionMask(mask: number);
  7146. /**
  7147. * Gets the plane normal used to compute the sliding response (in local space)
  7148. */
  7149. get slidePlaneNormal(): Vector3;
  7150. /** @hidden */
  7151. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7152. /** @hidden */
  7153. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7154. /** @hidden */
  7155. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7156. /** @hidden */
  7157. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7158. /** @hidden */
  7159. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7160. /** @hidden */
  7161. _getResponse(pos: Vector3, vel: Vector3): void;
  7162. }
  7163. }
  7164. declare module BABYLON {
  7165. /**
  7166. * Interface for cullable objects
  7167. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7168. */
  7169. export interface ICullable {
  7170. /**
  7171. * Checks if the object or part of the object is in the frustum
  7172. * @param frustumPlanes Camera near/planes
  7173. * @returns true if the object is in frustum otherwise false
  7174. */
  7175. isInFrustum(frustumPlanes: Plane[]): boolean;
  7176. /**
  7177. * Checks if a cullable object (mesh...) is in the camera frustum
  7178. * Unlike isInFrustum this cheks the full bounding box
  7179. * @param frustumPlanes Camera near/planes
  7180. * @returns true if the object is in frustum otherwise false
  7181. */
  7182. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7183. }
  7184. /**
  7185. * Info for a bounding data of a mesh
  7186. */
  7187. export class BoundingInfo implements ICullable {
  7188. /**
  7189. * Bounding box for the mesh
  7190. */
  7191. readonly boundingBox: BoundingBox;
  7192. /**
  7193. * Bounding sphere for the mesh
  7194. */
  7195. readonly boundingSphere: BoundingSphere;
  7196. private _isLocked;
  7197. private static readonly TmpVector3;
  7198. /**
  7199. * Constructs bounding info
  7200. * @param minimum min vector of the bounding box/sphere
  7201. * @param maximum max vector of the bounding box/sphere
  7202. * @param worldMatrix defines the new world matrix
  7203. */
  7204. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7205. /**
  7206. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7207. * @param min defines the new minimum vector (in local space)
  7208. * @param max defines the new maximum vector (in local space)
  7209. * @param worldMatrix defines the new world matrix
  7210. */
  7211. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7212. /**
  7213. * min vector of the bounding box/sphere
  7214. */
  7215. get minimum(): Vector3;
  7216. /**
  7217. * max vector of the bounding box/sphere
  7218. */
  7219. get maximum(): Vector3;
  7220. /**
  7221. * If the info is locked and won't be updated to avoid perf overhead
  7222. */
  7223. get isLocked(): boolean;
  7224. set isLocked(value: boolean);
  7225. /**
  7226. * Updates the bounding sphere and box
  7227. * @param world world matrix to be used to update
  7228. */
  7229. update(world: DeepImmutable<Matrix>): void;
  7230. /**
  7231. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7232. * @param center New center of the bounding info
  7233. * @param extend New extend of the bounding info
  7234. * @returns the current bounding info
  7235. */
  7236. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7237. /**
  7238. * Scale the current bounding info by applying a scale factor
  7239. * @param factor defines the scale factor to apply
  7240. * @returns the current bounding info
  7241. */
  7242. scale(factor: number): BoundingInfo;
  7243. /**
  7244. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7245. * @param frustumPlanes defines the frustum to test
  7246. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7247. * @returns true if the bounding info is in the frustum planes
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7250. /**
  7251. * Gets the world distance between the min and max points of the bounding box
  7252. */
  7253. get diagonalLength(): number;
  7254. /**
  7255. * Checks if a cullable object (mesh...) is in the camera frustum
  7256. * Unlike isInFrustum this cheks the full bounding box
  7257. * @param frustumPlanes Camera near/planes
  7258. * @returns true if the object is in frustum otherwise false
  7259. */
  7260. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7261. /** @hidden */
  7262. _checkCollision(collider: Collider): boolean;
  7263. /**
  7264. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7265. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7266. * @param point the point to check intersection with
  7267. * @returns if the point intersects
  7268. */
  7269. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7270. /**
  7271. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7272. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7273. * @param boundingInfo the bounding info to check intersection with
  7274. * @param precise if the intersection should be done using OBB
  7275. * @returns if the bounding info intersects
  7276. */
  7277. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7278. }
  7279. }
  7280. declare module BABYLON {
  7281. /**
  7282. * Extracts minimum and maximum values from a list of indexed positions
  7283. * @param positions defines the positions to use
  7284. * @param indices defines the indices to the positions
  7285. * @param indexStart defines the start index
  7286. * @param indexCount defines the end index
  7287. * @param bias defines bias value to add to the result
  7288. * @return minimum and maximum values
  7289. */
  7290. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7291. minimum: Vector3;
  7292. maximum: Vector3;
  7293. };
  7294. /**
  7295. * Extracts minimum and maximum values from a list of positions
  7296. * @param positions defines the positions to use
  7297. * @param start defines the start index in the positions array
  7298. * @param count defines the number of positions to handle
  7299. * @param bias defines bias value to add to the result
  7300. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7301. * @return minimum and maximum values
  7302. */
  7303. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7304. minimum: Vector3;
  7305. maximum: Vector3;
  7306. };
  7307. }
  7308. declare module BABYLON {
  7309. /** @hidden */
  7310. export class WebGLDataBuffer extends DataBuffer {
  7311. private _buffer;
  7312. constructor(resource: WebGLBuffer);
  7313. get underlyingResource(): any;
  7314. }
  7315. }
  7316. declare module BABYLON {
  7317. /** @hidden */
  7318. export class WebGLPipelineContext implements IPipelineContext {
  7319. engine: ThinEngine;
  7320. program: Nullable<WebGLProgram>;
  7321. context?: WebGLRenderingContext;
  7322. vertexShader?: WebGLShader;
  7323. fragmentShader?: WebGLShader;
  7324. isParallelCompiled: boolean;
  7325. onCompiled?: () => void;
  7326. transformFeedback?: WebGLTransformFeedback | null;
  7327. vertexCompilationError: Nullable<string>;
  7328. fragmentCompilationError: Nullable<string>;
  7329. programLinkError: Nullable<string>;
  7330. programValidationError: Nullable<string>;
  7331. get isAsync(): boolean;
  7332. get isReady(): boolean;
  7333. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7334. _getVertexShaderCode(): string | null;
  7335. _getFragmentShaderCode(): string | null;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. interface ThinEngine {
  7340. /**
  7341. * Create an uniform buffer
  7342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7343. * @param elements defines the content of the uniform buffer
  7344. * @returns the webGL uniform buffer
  7345. */
  7346. createUniformBuffer(elements: FloatArray): DataBuffer;
  7347. /**
  7348. * Create a dynamic uniform buffer
  7349. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7350. * @param elements defines the content of the uniform buffer
  7351. * @returns the webGL uniform buffer
  7352. */
  7353. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7354. /**
  7355. * Update an existing uniform buffer
  7356. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7357. * @param uniformBuffer defines the target uniform buffer
  7358. * @param elements defines the content to update
  7359. * @param offset defines the offset in the uniform buffer where update should start
  7360. * @param count defines the size of the data to update
  7361. */
  7362. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7363. /**
  7364. * Bind an uniform buffer to the current webGL context
  7365. * @param buffer defines the buffer to bind
  7366. */
  7367. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7368. /**
  7369. * Bind a buffer to the current webGL context at a given location
  7370. * @param buffer defines the buffer to bind
  7371. * @param location defines the index where to bind the buffer
  7372. */
  7373. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7374. /**
  7375. * Bind a specific block at a given index in a specific shader program
  7376. * @param pipelineContext defines the pipeline context to use
  7377. * @param blockName defines the block name
  7378. * @param index defines the index where to bind the block
  7379. */
  7380. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7381. }
  7382. }
  7383. declare module BABYLON {
  7384. /**
  7385. * Uniform buffer objects.
  7386. *
  7387. * Handles blocks of uniform on the GPU.
  7388. *
  7389. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7390. *
  7391. * For more information, please refer to :
  7392. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7393. */
  7394. export class UniformBuffer {
  7395. private _engine;
  7396. private _buffer;
  7397. private _data;
  7398. private _bufferData;
  7399. private _dynamic?;
  7400. private _uniformLocations;
  7401. private _uniformSizes;
  7402. private _uniformLocationPointer;
  7403. private _needSync;
  7404. private _noUBO;
  7405. private _currentEffect;
  7406. /** @hidden */
  7407. _alreadyBound: boolean;
  7408. private static _MAX_UNIFORM_SIZE;
  7409. private static _tempBuffer;
  7410. /**
  7411. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7416. /**
  7417. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7422. /**
  7423. * Lambda to Update a single float in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateFloat: (name: string, x: number) => void;
  7428. /**
  7429. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7434. /**
  7435. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7440. /**
  7441. * Lambda to Update a vec4 of 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7446. /**
  7447. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7452. /**
  7453. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7458. /**
  7459. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7464. /**
  7465. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7470. /**
  7471. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7476. /**
  7477. * Instantiates a new Uniform buffer objects.
  7478. *
  7479. * Handles blocks of uniform on the GPU.
  7480. *
  7481. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7482. *
  7483. * For more information, please refer to :
  7484. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7485. * @param engine Define the engine the buffer is associated with
  7486. * @param data Define the data contained in the buffer
  7487. * @param dynamic Define if the buffer is updatable
  7488. */
  7489. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7490. /**
  7491. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7492. * or just falling back on setUniformXXX calls.
  7493. */
  7494. get useUbo(): boolean;
  7495. /**
  7496. * Indicates if the WebGL underlying uniform buffer is in sync
  7497. * with the javascript cache data.
  7498. */
  7499. get isSync(): boolean;
  7500. /**
  7501. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7502. * Also, a dynamic UniformBuffer will disable cache verification and always
  7503. * update the underlying WebGL uniform buffer to the GPU.
  7504. * @returns if Dynamic, otherwise false
  7505. */
  7506. isDynamic(): boolean;
  7507. /**
  7508. * The data cache on JS side.
  7509. * @returns the underlying data as a float array
  7510. */
  7511. getData(): Float32Array;
  7512. /**
  7513. * The underlying WebGL Uniform buffer.
  7514. * @returns the webgl buffer
  7515. */
  7516. getBuffer(): Nullable<DataBuffer>;
  7517. /**
  7518. * std140 layout specifies how to align data within an UBO structure.
  7519. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7520. * for specs.
  7521. */
  7522. private _fillAlignment;
  7523. /**
  7524. * Adds an uniform in the buffer.
  7525. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7526. * for the layout to be correct !
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param size Data size, or data directly.
  7529. */
  7530. addUniform(name: string, size: number | number[]): void;
  7531. /**
  7532. * Adds a Matrix 4x4 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. * @param mat A 4x4 matrix.
  7535. */
  7536. addMatrix(name: string, mat: Matrix): void;
  7537. /**
  7538. * Adds a vec2 to the uniform buffer.
  7539. * @param name Name of the uniform, as used in the uniform block in the shader.
  7540. * @param x Define the x component value of the vec2
  7541. * @param y Define the y component value of the vec2
  7542. */
  7543. addFloat2(name: string, x: number, y: number): void;
  7544. /**
  7545. * Adds a vec3 to the uniform buffer.
  7546. * @param name Name of the uniform, as used in the uniform block in the shader.
  7547. * @param x Define the x component value of the vec3
  7548. * @param y Define the y component value of the vec3
  7549. * @param z Define the z component value of the vec3
  7550. */
  7551. addFloat3(name: string, x: number, y: number, z: number): void;
  7552. /**
  7553. * Adds a vec3 to the uniform buffer.
  7554. * @param name Name of the uniform, as used in the uniform block in the shader.
  7555. * @param color Define the vec3 from a Color
  7556. */
  7557. addColor3(name: string, color: Color3): void;
  7558. /**
  7559. * Adds a vec4 to the uniform buffer.
  7560. * @param name Name of the uniform, as used in the uniform block in the shader.
  7561. * @param color Define the rgb components from a Color
  7562. * @param alpha Define the a component of the vec4
  7563. */
  7564. addColor4(name: string, color: Color3, alpha: number): void;
  7565. /**
  7566. * Adds a vec3 to the uniform buffer.
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param vector Define the vec3 components from a Vector
  7569. */
  7570. addVector3(name: string, vector: Vector3): void;
  7571. /**
  7572. * Adds a Matrix 3x3 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. */
  7575. addMatrix3x3(name: string): void;
  7576. /**
  7577. * Adds a Matrix 2x2 to the uniform buffer.
  7578. * @param name Name of the uniform, as used in the uniform block in the shader.
  7579. */
  7580. addMatrix2x2(name: string): void;
  7581. /**
  7582. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7583. */
  7584. create(): void;
  7585. /** @hidden */
  7586. _rebuild(): void;
  7587. /**
  7588. * Updates the WebGL Uniform Buffer on the GPU.
  7589. * If the `dynamic` flag is set to true, no cache comparison is done.
  7590. * Otherwise, the buffer will be updated only if the cache differs.
  7591. */
  7592. update(): void;
  7593. /**
  7594. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7595. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7596. * @param data Define the flattened data
  7597. * @param size Define the size of the data.
  7598. */
  7599. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7600. private _valueCache;
  7601. private _cacheMatrix;
  7602. private _updateMatrix3x3ForUniform;
  7603. private _updateMatrix3x3ForEffect;
  7604. private _updateMatrix2x2ForEffect;
  7605. private _updateMatrix2x2ForUniform;
  7606. private _updateFloatForEffect;
  7607. private _updateFloatForUniform;
  7608. private _updateFloat2ForEffect;
  7609. private _updateFloat2ForUniform;
  7610. private _updateFloat3ForEffect;
  7611. private _updateFloat3ForUniform;
  7612. private _updateFloat4ForEffect;
  7613. private _updateFloat4ForUniform;
  7614. private _updateMatrixForEffect;
  7615. private _updateMatrixForUniform;
  7616. private _updateVector3ForEffect;
  7617. private _updateVector3ForUniform;
  7618. private _updateVector4ForEffect;
  7619. private _updateVector4ForUniform;
  7620. private _updateColor3ForEffect;
  7621. private _updateColor3ForUniform;
  7622. private _updateColor4ForEffect;
  7623. private _updateColor4ForUniform;
  7624. /**
  7625. * Sets a sampler uniform on the effect.
  7626. * @param name Define the name of the sampler.
  7627. * @param texture Define the texture to set in the sampler
  7628. */
  7629. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7630. /**
  7631. * Directly updates the value of the uniform in the cache AND on the GPU.
  7632. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7633. * @param data Define the flattened data
  7634. */
  7635. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7636. /**
  7637. * Binds this uniform buffer to an effect.
  7638. * @param effect Define the effect to bind the buffer to
  7639. * @param name Name of the uniform block in the shader.
  7640. */
  7641. bindToEffect(effect: Effect, name: string): void;
  7642. /**
  7643. * Disposes the uniform buffer.
  7644. */
  7645. dispose(): void;
  7646. }
  7647. }
  7648. declare module BABYLON {
  7649. /**
  7650. * Enum that determines the text-wrapping mode to use.
  7651. */
  7652. export enum InspectableType {
  7653. /**
  7654. * Checkbox for booleans
  7655. */
  7656. Checkbox = 0,
  7657. /**
  7658. * Sliders for numbers
  7659. */
  7660. Slider = 1,
  7661. /**
  7662. * Vector3
  7663. */
  7664. Vector3 = 2,
  7665. /**
  7666. * Quaternions
  7667. */
  7668. Quaternion = 3,
  7669. /**
  7670. * Color3
  7671. */
  7672. Color3 = 4,
  7673. /**
  7674. * String
  7675. */
  7676. String = 5
  7677. }
  7678. /**
  7679. * Interface used to define custom inspectable properties.
  7680. * This interface is used by the inspector to display custom property grids
  7681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7682. */
  7683. export interface IInspectable {
  7684. /**
  7685. * Gets the label to display
  7686. */
  7687. label: string;
  7688. /**
  7689. * Gets the name of the property to edit
  7690. */
  7691. propertyName: string;
  7692. /**
  7693. * Gets the type of the editor to use
  7694. */
  7695. type: InspectableType;
  7696. /**
  7697. * Gets the minimum value of the property when using in "slider" mode
  7698. */
  7699. min?: number;
  7700. /**
  7701. * Gets the maximum value of the property when using in "slider" mode
  7702. */
  7703. max?: number;
  7704. /**
  7705. * Gets the setp to use when using in "slider" mode
  7706. */
  7707. step?: number;
  7708. }
  7709. }
  7710. declare module BABYLON {
  7711. /**
  7712. * Class used to provide helper for timing
  7713. */
  7714. export class TimingTools {
  7715. /**
  7716. * Polyfill for setImmediate
  7717. * @param action defines the action to execute after the current execution block
  7718. */
  7719. static SetImmediate(action: () => void): void;
  7720. }
  7721. }
  7722. declare module BABYLON {
  7723. /**
  7724. * Class used to enable instatition of objects by class name
  7725. */
  7726. export class InstantiationTools {
  7727. /**
  7728. * Use this object to register external classes like custom textures or material
  7729. * to allow the laoders to instantiate them
  7730. */
  7731. static RegisteredExternalClasses: {
  7732. [key: string]: Object;
  7733. };
  7734. /**
  7735. * Tries to instantiate a new object from a given class name
  7736. * @param className defines the class name to instantiate
  7737. * @returns the new object or null if the system was not able to do the instantiation
  7738. */
  7739. static Instantiate(className: string): any;
  7740. }
  7741. }
  7742. declare module BABYLON {
  7743. /**
  7744. * Define options used to create a depth texture
  7745. */
  7746. export class DepthTextureCreationOptions {
  7747. /** Specifies whether or not a stencil should be allocated in the texture */
  7748. generateStencil?: boolean;
  7749. /** Specifies whether or not bilinear filtering is enable on the texture */
  7750. bilinearFiltering?: boolean;
  7751. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7752. comparisonFunction?: number;
  7753. /** Specifies if the created texture is a cube texture */
  7754. isCube?: boolean;
  7755. }
  7756. }
  7757. declare module BABYLON {
  7758. interface ThinEngine {
  7759. /**
  7760. * Creates a depth stencil cube texture.
  7761. * This is only available in WebGL 2.
  7762. * @param size The size of face edge in the cube texture.
  7763. * @param options The options defining the cube texture.
  7764. * @returns The cube texture
  7765. */
  7766. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7767. /**
  7768. * Creates a cube texture
  7769. * @param rootUrl defines the url where the files to load is located
  7770. * @param scene defines the current scene
  7771. * @param files defines the list of files to load (1 per face)
  7772. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7773. * @param onLoad defines an optional callback raised when the texture is loaded
  7774. * @param onError defines an optional callback raised if there is an issue to load the texture
  7775. * @param format defines the format of the data
  7776. * @param forcedExtension defines the extension to use to pick the right loader
  7777. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7778. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7779. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7780. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7781. * @returns the cube texture as an InternalTexture
  7782. */
  7783. 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;
  7784. /**
  7785. * Creates a cube texture
  7786. * @param rootUrl defines the url where the files to load is located
  7787. * @param scene defines the current scene
  7788. * @param files defines the list of files to load (1 per face)
  7789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7790. * @param onLoad defines an optional callback raised when the texture is loaded
  7791. * @param onError defines an optional callback raised if there is an issue to load the texture
  7792. * @param format defines the format of the data
  7793. * @param forcedExtension defines the extension to use to pick the right loader
  7794. * @returns the cube texture as an InternalTexture
  7795. */
  7796. 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;
  7797. /**
  7798. * Creates a cube texture
  7799. * @param rootUrl defines the url where the files to load is located
  7800. * @param scene defines the current scene
  7801. * @param files defines the list of files to load (1 per face)
  7802. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7803. * @param onLoad defines an optional callback raised when the texture is loaded
  7804. * @param onError defines an optional callback raised if there is an issue to load the texture
  7805. * @param format defines the format of the data
  7806. * @param forcedExtension defines the extension to use to pick the right loader
  7807. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7810. * @returns the cube texture as an InternalTexture
  7811. */
  7812. 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;
  7813. /** @hidden */
  7814. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7815. /** @hidden */
  7816. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7817. /** @hidden */
  7818. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7819. /** @hidden */
  7820. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7821. /**
  7822. * @hidden
  7823. */
  7824. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7825. }
  7826. }
  7827. declare module BABYLON {
  7828. /**
  7829. * Class for creating a cube texture
  7830. */
  7831. export class CubeTexture extends BaseTexture {
  7832. private _delayedOnLoad;
  7833. /**
  7834. * Observable triggered once the texture has been loaded.
  7835. */
  7836. onLoadObservable: Observable<CubeTexture>;
  7837. /**
  7838. * The url of the texture
  7839. */
  7840. url: string;
  7841. /**
  7842. * Gets or sets the center of the bounding box associated with the cube texture.
  7843. * It must define where the camera used to render the texture was set
  7844. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7845. */
  7846. boundingBoxPosition: Vector3;
  7847. private _boundingBoxSize;
  7848. /**
  7849. * Gets or sets the size of the bounding box associated with the cube texture
  7850. * When defined, the cubemap will switch to local mode
  7851. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7852. * @example https://www.babylonjs-playground.com/#RNASML
  7853. */
  7854. set boundingBoxSize(value: Vector3);
  7855. /**
  7856. * Returns the bounding box size
  7857. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7858. */
  7859. get boundingBoxSize(): Vector3;
  7860. protected _rotationY: number;
  7861. /**
  7862. * Sets texture matrix rotation angle around Y axis in radians.
  7863. */
  7864. set rotationY(value: number);
  7865. /**
  7866. * Gets texture matrix rotation angle around Y axis radians.
  7867. */
  7868. get rotationY(): number;
  7869. /**
  7870. * Are mip maps generated for this texture or not.
  7871. */
  7872. get noMipmap(): boolean;
  7873. private _noMipmap;
  7874. private _files;
  7875. protected _forcedExtension: Nullable<string>;
  7876. private _extensions;
  7877. private _textureMatrix;
  7878. private _format;
  7879. private _createPolynomials;
  7880. /**
  7881. * Creates a cube texture from an array of image urls
  7882. * @param files defines an array of image urls
  7883. * @param scene defines the hosting scene
  7884. * @param noMipmap specifies if mip maps are not used
  7885. * @returns a cube texture
  7886. */
  7887. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7888. /**
  7889. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7890. * @param url defines the url of the prefiltered texture
  7891. * @param scene defines the scene the texture is attached to
  7892. * @param forcedExtension defines the extension of the file if different from the url
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @return the prefiltered texture
  7895. */
  7896. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7897. /**
  7898. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7899. * as prefiltered data.
  7900. * @param rootUrl defines the url of the texture or the root name of the six images
  7901. * @param null defines the scene or engine the texture is attached to
  7902. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7903. * @param noMipmap defines if mipmaps should be created or not
  7904. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7905. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7906. * @param onError defines a callback triggered in case of error during load
  7907. * @param format defines the internal format to use for the texture once loaded
  7908. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7909. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7910. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7911. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7912. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7913. * @return the cube texture
  7914. */
  7915. 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);
  7916. /**
  7917. * Get the current class name of the texture useful for serialization or dynamic coding.
  7918. * @returns "CubeTexture"
  7919. */
  7920. getClassName(): string;
  7921. /**
  7922. * Update the url (and optional buffer) of this texture if url was null during construction.
  7923. * @param url the url of the texture
  7924. * @param forcedExtension defines the extension to use
  7925. * @param onLoad callback called when the texture is loaded (defaults to null)
  7926. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7927. */
  7928. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7929. /**
  7930. * Delays loading of the cube texture
  7931. * @param forcedExtension defines the extension to use
  7932. */
  7933. delayLoad(forcedExtension?: string): void;
  7934. /**
  7935. * Returns the reflection texture matrix
  7936. * @returns the reflection texture matrix
  7937. */
  7938. getReflectionTextureMatrix(): Matrix;
  7939. /**
  7940. * Sets the reflection texture matrix
  7941. * @param value Reflection texture matrix
  7942. */
  7943. setReflectionTextureMatrix(value: Matrix): void;
  7944. /**
  7945. * Parses text to create a cube texture
  7946. * @param parsedTexture define the serialized text to read from
  7947. * @param scene defines the hosting scene
  7948. * @param rootUrl defines the root url of the cube texture
  7949. * @returns a cube texture
  7950. */
  7951. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7952. /**
  7953. * Makes a clone, or deep copy, of the cube texture
  7954. * @returns a new cube texture
  7955. */
  7956. clone(): CubeTexture;
  7957. }
  7958. }
  7959. declare module BABYLON {
  7960. /**
  7961. * Manages the defines for the Material
  7962. */
  7963. export class MaterialDefines {
  7964. /** @hidden */
  7965. protected _keys: string[];
  7966. private _isDirty;
  7967. /** @hidden */
  7968. _renderId: number;
  7969. /** @hidden */
  7970. _areLightsDirty: boolean;
  7971. /** @hidden */
  7972. _areLightsDisposed: boolean;
  7973. /** @hidden */
  7974. _areAttributesDirty: boolean;
  7975. /** @hidden */
  7976. _areTexturesDirty: boolean;
  7977. /** @hidden */
  7978. _areFresnelDirty: boolean;
  7979. /** @hidden */
  7980. _areMiscDirty: boolean;
  7981. /** @hidden */
  7982. _areImageProcessingDirty: boolean;
  7983. /** @hidden */
  7984. _normals: boolean;
  7985. /** @hidden */
  7986. _uvs: boolean;
  7987. /** @hidden */
  7988. _needNormals: boolean;
  7989. /** @hidden */
  7990. _needUVs: boolean;
  7991. [id: string]: any;
  7992. /**
  7993. * Specifies if the material needs to be re-calculated
  7994. */
  7995. get isDirty(): boolean;
  7996. /**
  7997. * Marks the material to indicate that it has been re-calculated
  7998. */
  7999. markAsProcessed(): void;
  8000. /**
  8001. * Marks the material to indicate that it needs to be re-calculated
  8002. */
  8003. markAsUnprocessed(): void;
  8004. /**
  8005. * Marks the material to indicate all of its defines need to be re-calculated
  8006. */
  8007. markAllAsDirty(): void;
  8008. /**
  8009. * Marks the material to indicate that image processing needs to be re-calculated
  8010. */
  8011. markAsImageProcessingDirty(): void;
  8012. /**
  8013. * Marks the material to indicate the lights need to be re-calculated
  8014. * @param disposed Defines whether the light is dirty due to dispose or not
  8015. */
  8016. markAsLightDirty(disposed?: boolean): void;
  8017. /**
  8018. * Marks the attribute state as changed
  8019. */
  8020. markAsAttributesDirty(): void;
  8021. /**
  8022. * Marks the texture state as changed
  8023. */
  8024. markAsTexturesDirty(): void;
  8025. /**
  8026. * Marks the fresnel state as changed
  8027. */
  8028. markAsFresnelDirty(): void;
  8029. /**
  8030. * Marks the misc state as changed
  8031. */
  8032. markAsMiscDirty(): void;
  8033. /**
  8034. * Rebuilds the material defines
  8035. */
  8036. rebuild(): void;
  8037. /**
  8038. * Specifies if two material defines are equal
  8039. * @param other - A material define instance to compare to
  8040. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8041. */
  8042. isEqual(other: MaterialDefines): boolean;
  8043. /**
  8044. * Clones this instance's defines to another instance
  8045. * @param other - material defines to clone values to
  8046. */
  8047. cloneTo(other: MaterialDefines): void;
  8048. /**
  8049. * Resets the material define values
  8050. */
  8051. reset(): void;
  8052. /**
  8053. * Converts the material define values to a string
  8054. * @returns - String of material define information
  8055. */
  8056. toString(): string;
  8057. }
  8058. }
  8059. declare module BABYLON {
  8060. /**
  8061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8063. * 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;
  8064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8065. */
  8066. export class ColorCurves {
  8067. private _dirty;
  8068. private _tempColor;
  8069. private _globalCurve;
  8070. private _highlightsCurve;
  8071. private _midtonesCurve;
  8072. private _shadowsCurve;
  8073. private _positiveCurve;
  8074. private _negativeCurve;
  8075. private _globalHue;
  8076. private _globalDensity;
  8077. private _globalSaturation;
  8078. private _globalExposure;
  8079. /**
  8080. * Gets the global Hue value.
  8081. * 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).
  8082. */
  8083. get globalHue(): number;
  8084. /**
  8085. * Sets the global Hue value.
  8086. * 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).
  8087. */
  8088. set globalHue(value: number);
  8089. /**
  8090. * Gets the global Density value.
  8091. * 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.
  8092. * Values less than zero provide a filter of opposite hue.
  8093. */
  8094. get globalDensity(): number;
  8095. /**
  8096. * Sets the global Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. set globalDensity(value: number);
  8101. /**
  8102. * Gets the global Saturation value.
  8103. * 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.
  8104. */
  8105. get globalSaturation(): number;
  8106. /**
  8107. * Sets the global Saturation value.
  8108. * 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.
  8109. */
  8110. set globalSaturation(value: number);
  8111. /**
  8112. * Gets the global Exposure value.
  8113. * 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.
  8114. */
  8115. get globalExposure(): number;
  8116. /**
  8117. * Sets the global Exposure value.
  8118. * 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.
  8119. */
  8120. set globalExposure(value: number);
  8121. private _highlightsHue;
  8122. private _highlightsDensity;
  8123. private _highlightsSaturation;
  8124. private _highlightsExposure;
  8125. /**
  8126. * Gets the highlights Hue value.
  8127. * 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).
  8128. */
  8129. get highlightsHue(): number;
  8130. /**
  8131. * Sets the highlights Hue value.
  8132. * 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).
  8133. */
  8134. set highlightsHue(value: number);
  8135. /**
  8136. * Gets the highlights Density value.
  8137. * 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.
  8138. * Values less than zero provide a filter of opposite hue.
  8139. */
  8140. get highlightsDensity(): number;
  8141. /**
  8142. * Sets the highlights Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. set highlightsDensity(value: number);
  8147. /**
  8148. * Gets the highlights Saturation value.
  8149. * 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.
  8150. */
  8151. get highlightsSaturation(): number;
  8152. /**
  8153. * Sets the highlights Saturation value.
  8154. * 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.
  8155. */
  8156. set highlightsSaturation(value: number);
  8157. /**
  8158. * Gets the highlights Exposure value.
  8159. * 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.
  8160. */
  8161. get highlightsExposure(): number;
  8162. /**
  8163. * Sets the highlights Exposure value.
  8164. * 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.
  8165. */
  8166. set highlightsExposure(value: number);
  8167. private _midtonesHue;
  8168. private _midtonesDensity;
  8169. private _midtonesSaturation;
  8170. private _midtonesExposure;
  8171. /**
  8172. * Gets the midtones Hue value.
  8173. * 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).
  8174. */
  8175. get midtonesHue(): number;
  8176. /**
  8177. * Sets the midtones Hue value.
  8178. * 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).
  8179. */
  8180. set midtonesHue(value: number);
  8181. /**
  8182. * Gets the midtones Density value.
  8183. * 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.
  8184. * Values less than zero provide a filter of opposite hue.
  8185. */
  8186. get midtonesDensity(): number;
  8187. /**
  8188. * Sets the midtones Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. set midtonesDensity(value: number);
  8193. /**
  8194. * Gets the midtones Saturation value.
  8195. * 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.
  8196. */
  8197. get midtonesSaturation(): number;
  8198. /**
  8199. * Sets the midtones Saturation value.
  8200. * 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.
  8201. */
  8202. set midtonesSaturation(value: number);
  8203. /**
  8204. * Gets the midtones Exposure value.
  8205. * 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.
  8206. */
  8207. get midtonesExposure(): number;
  8208. /**
  8209. * Sets the midtones Exposure value.
  8210. * 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.
  8211. */
  8212. set midtonesExposure(value: number);
  8213. private _shadowsHue;
  8214. private _shadowsDensity;
  8215. private _shadowsSaturation;
  8216. private _shadowsExposure;
  8217. /**
  8218. * Gets the shadows Hue value.
  8219. * 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).
  8220. */
  8221. get shadowsHue(): number;
  8222. /**
  8223. * Sets the shadows Hue value.
  8224. * 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).
  8225. */
  8226. set shadowsHue(value: number);
  8227. /**
  8228. * Gets the shadows Density value.
  8229. * 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.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. get shadowsDensity(): number;
  8233. /**
  8234. * Sets the shadows Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. set shadowsDensity(value: number);
  8239. /**
  8240. * Gets the shadows Saturation value.
  8241. * 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.
  8242. */
  8243. get shadowsSaturation(): number;
  8244. /**
  8245. * Sets the shadows Saturation value.
  8246. * 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.
  8247. */
  8248. set shadowsSaturation(value: number);
  8249. /**
  8250. * Gets the shadows Exposure value.
  8251. * 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.
  8252. */
  8253. get shadowsExposure(): number;
  8254. /**
  8255. * Sets the shadows Exposure value.
  8256. * 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.
  8257. */
  8258. set shadowsExposure(value: number);
  8259. /**
  8260. * Returns the class name
  8261. * @returns The class name
  8262. */
  8263. getClassName(): string;
  8264. /**
  8265. * Binds the color curves to the shader.
  8266. * @param colorCurves The color curve to bind
  8267. * @param effect The effect to bind to
  8268. * @param positiveUniform The positive uniform shader parameter
  8269. * @param neutralUniform The neutral uniform shader parameter
  8270. * @param negativeUniform The negative uniform shader parameter
  8271. */
  8272. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8273. /**
  8274. * Prepare the list of uniforms associated with the ColorCurves effects.
  8275. * @param uniformsList The list of uniforms used in the effect
  8276. */
  8277. static PrepareUniforms(uniformsList: string[]): void;
  8278. /**
  8279. * Returns color grading data based on a hue, density, saturation and exposure value.
  8280. * @param filterHue The hue of the color filter.
  8281. * @param filterDensity The density of the color filter.
  8282. * @param saturation The saturation.
  8283. * @param exposure The exposure.
  8284. * @param result The result data container.
  8285. */
  8286. private getColorGradingDataToRef;
  8287. /**
  8288. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8289. * @param value The input slider value in range [-100,100].
  8290. * @returns Adjusted value.
  8291. */
  8292. private static applyColorGradingSliderNonlinear;
  8293. /**
  8294. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8295. * @param hue The hue (H) input.
  8296. * @param saturation The saturation (S) input.
  8297. * @param brightness The brightness (B) input.
  8298. * @result An RGBA color represented as Vector4.
  8299. */
  8300. private static fromHSBToRef;
  8301. /**
  8302. * Returns a value clamped between min and max
  8303. * @param value The value to clamp
  8304. * @param min The minimum of value
  8305. * @param max The maximum of value
  8306. * @returns The clamped value.
  8307. */
  8308. private static clamp;
  8309. /**
  8310. * Clones the current color curve instance.
  8311. * @return The cloned curves
  8312. */
  8313. clone(): ColorCurves;
  8314. /**
  8315. * Serializes the current color curve instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the color curve from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed curves
  8323. */
  8324. static Parse(source: any): ColorCurves;
  8325. }
  8326. }
  8327. declare module BABYLON {
  8328. /**
  8329. * Interface to follow in your material defines to integrate easily the
  8330. * Image proccessing functions.
  8331. * @hidden
  8332. */
  8333. export interface IImageProcessingConfigurationDefines {
  8334. IMAGEPROCESSING: boolean;
  8335. VIGNETTE: boolean;
  8336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8337. VIGNETTEBLENDMODEOPAQUE: boolean;
  8338. TONEMAPPING: boolean;
  8339. TONEMAPPING_ACES: boolean;
  8340. CONTRAST: boolean;
  8341. EXPOSURE: boolean;
  8342. COLORCURVES: boolean;
  8343. COLORGRADING: boolean;
  8344. COLORGRADING3D: boolean;
  8345. SAMPLER3DGREENDEPTH: boolean;
  8346. SAMPLER3DBGRMAP: boolean;
  8347. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8348. }
  8349. /**
  8350. * @hidden
  8351. */
  8352. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8353. IMAGEPROCESSING: boolean;
  8354. VIGNETTE: boolean;
  8355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8356. VIGNETTEBLENDMODEOPAQUE: boolean;
  8357. TONEMAPPING: boolean;
  8358. TONEMAPPING_ACES: boolean;
  8359. CONTRAST: boolean;
  8360. COLORCURVES: boolean;
  8361. COLORGRADING: boolean;
  8362. COLORGRADING3D: boolean;
  8363. SAMPLER3DGREENDEPTH: boolean;
  8364. SAMPLER3DBGRMAP: boolean;
  8365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8366. EXPOSURE: boolean;
  8367. constructor();
  8368. }
  8369. /**
  8370. * This groups together the common properties used for image processing either in direct forward pass
  8371. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8372. * or not.
  8373. */
  8374. export class ImageProcessingConfiguration {
  8375. /**
  8376. * Default tone mapping applied in BabylonJS.
  8377. */
  8378. static readonly TONEMAPPING_STANDARD: number;
  8379. /**
  8380. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8381. * to other engines rendering to increase portability.
  8382. */
  8383. static readonly TONEMAPPING_ACES: number;
  8384. /**
  8385. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8386. */
  8387. colorCurves: Nullable<ColorCurves>;
  8388. private _colorCurvesEnabled;
  8389. /**
  8390. * Gets wether the color curves effect is enabled.
  8391. */
  8392. get colorCurvesEnabled(): boolean;
  8393. /**
  8394. * Sets wether the color curves effect is enabled.
  8395. */
  8396. set colorCurvesEnabled(value: boolean);
  8397. private _colorGradingTexture;
  8398. /**
  8399. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8400. */
  8401. get colorGradingTexture(): Nullable<BaseTexture>;
  8402. /**
  8403. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8404. */
  8405. set colorGradingTexture(value: Nullable<BaseTexture>);
  8406. private _colorGradingEnabled;
  8407. /**
  8408. * Gets wether the color grading effect is enabled.
  8409. */
  8410. get colorGradingEnabled(): boolean;
  8411. /**
  8412. * Sets wether the color grading effect is enabled.
  8413. */
  8414. set colorGradingEnabled(value: boolean);
  8415. private _colorGradingWithGreenDepth;
  8416. /**
  8417. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8418. */
  8419. get colorGradingWithGreenDepth(): boolean;
  8420. /**
  8421. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8422. */
  8423. set colorGradingWithGreenDepth(value: boolean);
  8424. private _colorGradingBGR;
  8425. /**
  8426. * Gets wether the color grading texture contains BGR values.
  8427. */
  8428. get colorGradingBGR(): boolean;
  8429. /**
  8430. * Sets wether the color grading texture contains BGR values.
  8431. */
  8432. set colorGradingBGR(value: boolean);
  8433. /** @hidden */
  8434. _exposure: number;
  8435. /**
  8436. * Gets the Exposure used in the effect.
  8437. */
  8438. get exposure(): number;
  8439. /**
  8440. * Sets the Exposure used in the effect.
  8441. */
  8442. set exposure(value: number);
  8443. private _toneMappingEnabled;
  8444. /**
  8445. * Gets wether the tone mapping effect is enabled.
  8446. */
  8447. get toneMappingEnabled(): boolean;
  8448. /**
  8449. * Sets wether the tone mapping effect is enabled.
  8450. */
  8451. set toneMappingEnabled(value: boolean);
  8452. private _toneMappingType;
  8453. /**
  8454. * Gets the type of tone mapping effect.
  8455. */
  8456. get toneMappingType(): number;
  8457. /**
  8458. * Sets the type of tone mapping effect used in BabylonJS.
  8459. */
  8460. set toneMappingType(value: number);
  8461. protected _contrast: number;
  8462. /**
  8463. * Gets the contrast used in the effect.
  8464. */
  8465. get contrast(): number;
  8466. /**
  8467. * Sets the contrast used in the effect.
  8468. */
  8469. set contrast(value: number);
  8470. /**
  8471. * Vignette stretch size.
  8472. */
  8473. vignetteStretch: number;
  8474. /**
  8475. * Vignette centre X Offset.
  8476. */
  8477. vignetteCentreX: number;
  8478. /**
  8479. * Vignette centre Y Offset.
  8480. */
  8481. vignetteCentreY: number;
  8482. /**
  8483. * Vignette weight or intensity of the vignette effect.
  8484. */
  8485. vignetteWeight: number;
  8486. /**
  8487. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8488. * if vignetteEnabled is set to true.
  8489. */
  8490. vignetteColor: Color4;
  8491. /**
  8492. * Camera field of view used by the Vignette effect.
  8493. */
  8494. vignetteCameraFov: number;
  8495. private _vignetteBlendMode;
  8496. /**
  8497. * Gets the vignette blend mode allowing different kind of effect.
  8498. */
  8499. get vignetteBlendMode(): number;
  8500. /**
  8501. * Sets the vignette blend mode allowing different kind of effect.
  8502. */
  8503. set vignetteBlendMode(value: number);
  8504. private _vignetteEnabled;
  8505. /**
  8506. * Gets wether the vignette effect is enabled.
  8507. */
  8508. get vignetteEnabled(): boolean;
  8509. /**
  8510. * Sets wether the vignette effect is enabled.
  8511. */
  8512. set vignetteEnabled(value: boolean);
  8513. private _applyByPostProcess;
  8514. /**
  8515. * Gets wether the image processing is applied through a post process or not.
  8516. */
  8517. get applyByPostProcess(): boolean;
  8518. /**
  8519. * Sets wether the image processing is applied through a post process or not.
  8520. */
  8521. set applyByPostProcess(value: boolean);
  8522. private _isEnabled;
  8523. /**
  8524. * Gets wether the image processing is enabled or not.
  8525. */
  8526. get isEnabled(): boolean;
  8527. /**
  8528. * Sets wether the image processing is enabled or not.
  8529. */
  8530. set isEnabled(value: boolean);
  8531. /**
  8532. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8533. */
  8534. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8535. /**
  8536. * Method called each time the image processing information changes requires to recompile the effect.
  8537. */
  8538. protected _updateParameters(): void;
  8539. /**
  8540. * Gets the current class name.
  8541. * @return "ImageProcessingConfiguration"
  8542. */
  8543. getClassName(): string;
  8544. /**
  8545. * Prepare the list of uniforms associated with the Image Processing effects.
  8546. * @param uniforms The list of uniforms used in the effect
  8547. * @param defines the list of defines currently in use
  8548. */
  8549. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8550. /**
  8551. * Prepare the list of samplers associated with the Image Processing effects.
  8552. * @param samplersList The list of uniforms used in the effect
  8553. * @param defines the list of defines currently in use
  8554. */
  8555. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8556. /**
  8557. * Prepare the list of defines associated to the shader.
  8558. * @param defines the list of defines to complete
  8559. * @param forPostProcess Define if we are currently in post process mode or not
  8560. */
  8561. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8562. /**
  8563. * Returns true if all the image processing information are ready.
  8564. * @returns True if ready, otherwise, false
  8565. */
  8566. isReady(): boolean;
  8567. /**
  8568. * Binds the image processing to the shader.
  8569. * @param effect The effect to bind to
  8570. * @param overrideAspectRatio Override the aspect ratio of the effect
  8571. */
  8572. bind(effect: Effect, overrideAspectRatio?: number): void;
  8573. /**
  8574. * Clones the current image processing instance.
  8575. * @return The cloned image processing
  8576. */
  8577. clone(): ImageProcessingConfiguration;
  8578. /**
  8579. * Serializes the current image processing instance to a json representation.
  8580. * @return a JSON representation
  8581. */
  8582. serialize(): any;
  8583. /**
  8584. * Parses the image processing from a json representation.
  8585. * @param source the JSON source to parse
  8586. * @return The parsed image processing
  8587. */
  8588. static Parse(source: any): ImageProcessingConfiguration;
  8589. private static _VIGNETTEMODE_MULTIPLY;
  8590. private static _VIGNETTEMODE_OPAQUE;
  8591. /**
  8592. * Used to apply the vignette as a mix with the pixel color.
  8593. */
  8594. static get VIGNETTEMODE_MULTIPLY(): number;
  8595. /**
  8596. * Used to apply the vignette as a replacement of the pixel color.
  8597. */
  8598. static get VIGNETTEMODE_OPAQUE(): number;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** @hidden */
  8603. export var postprocessVertexShader: {
  8604. name: string;
  8605. shader: string;
  8606. };
  8607. }
  8608. declare module BABYLON {
  8609. /**
  8610. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8611. */
  8612. export type RenderTargetTextureSize = number | {
  8613. width: number;
  8614. height: number;
  8615. layers?: number;
  8616. };
  8617. interface ThinEngine {
  8618. /**
  8619. * Creates a new render target texture
  8620. * @param size defines the size of the texture
  8621. * @param options defines the options used to create the texture
  8622. * @returns a new render target texture stored in an InternalTexture
  8623. */
  8624. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8625. /**
  8626. * Creates a depth stencil texture.
  8627. * This is only available in WebGL 2 or with the depth texture extension available.
  8628. * @param size The size of face edge in the texture.
  8629. * @param options The options defining the texture.
  8630. * @returns The texture
  8631. */
  8632. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8633. /** @hidden */
  8634. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Defines the kind of connection point for node based material
  8640. */
  8641. export enum NodeMaterialBlockConnectionPointTypes {
  8642. /** Float */
  8643. Float = 1,
  8644. /** Int */
  8645. Int = 2,
  8646. /** Vector2 */
  8647. Vector2 = 4,
  8648. /** Vector3 */
  8649. Vector3 = 8,
  8650. /** Vector4 */
  8651. Vector4 = 16,
  8652. /** Color3 */
  8653. Color3 = 32,
  8654. /** Color4 */
  8655. Color4 = 64,
  8656. /** Matrix */
  8657. Matrix = 128,
  8658. /** Custom object */
  8659. Object = 256,
  8660. /** Detect type based on connection */
  8661. AutoDetect = 1024,
  8662. /** Output type that will be defined by input type */
  8663. BasedOnInput = 2048
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Enum used to define the target of a block
  8669. */
  8670. export enum NodeMaterialBlockTargets {
  8671. /** Vertex shader */
  8672. Vertex = 1,
  8673. /** Fragment shader */
  8674. Fragment = 2,
  8675. /** Neutral */
  8676. Neutral = 4,
  8677. /** Vertex and Fragment */
  8678. VertexAndFragment = 3
  8679. }
  8680. }
  8681. declare module BABYLON {
  8682. /**
  8683. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8684. */
  8685. export enum NodeMaterialBlockConnectionPointMode {
  8686. /** Value is an uniform */
  8687. Uniform = 0,
  8688. /** Value is a mesh attribute */
  8689. Attribute = 1,
  8690. /** Value is a varying between vertex and fragment shaders */
  8691. Varying = 2,
  8692. /** Mode is undefined */
  8693. Undefined = 3
  8694. }
  8695. }
  8696. declare module BABYLON {
  8697. /**
  8698. * Enum used to define system values e.g. values automatically provided by the system
  8699. */
  8700. export enum NodeMaterialSystemValues {
  8701. /** World */
  8702. World = 1,
  8703. /** View */
  8704. View = 2,
  8705. /** Projection */
  8706. Projection = 3,
  8707. /** ViewProjection */
  8708. ViewProjection = 4,
  8709. /** WorldView */
  8710. WorldView = 5,
  8711. /** WorldViewProjection */
  8712. WorldViewProjection = 6,
  8713. /** CameraPosition */
  8714. CameraPosition = 7,
  8715. /** Fog Color */
  8716. FogColor = 8,
  8717. /** Delta time */
  8718. DeltaTime = 9
  8719. }
  8720. }
  8721. declare module BABYLON {
  8722. /** Defines supported spaces */
  8723. export enum Space {
  8724. /** Local (object) space */
  8725. LOCAL = 0,
  8726. /** World space */
  8727. WORLD = 1,
  8728. /** Bone space */
  8729. BONE = 2
  8730. }
  8731. /** Defines the 3 main axes */
  8732. export class Axis {
  8733. /** X axis */
  8734. static X: Vector3;
  8735. /** Y axis */
  8736. static Y: Vector3;
  8737. /** Z axis */
  8738. static Z: Vector3;
  8739. }
  8740. }
  8741. declare module BABYLON {
  8742. /**
  8743. * Represents a camera frustum
  8744. */
  8745. export class Frustum {
  8746. /**
  8747. * Gets the planes representing the frustum
  8748. * @param transform matrix to be applied to the returned planes
  8749. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8750. */
  8751. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8752. /**
  8753. * Gets the near frustum plane transformed by the transform matrix
  8754. * @param transform transformation matrix to be applied to the resulting frustum plane
  8755. * @param frustumPlane the resuling frustum plane
  8756. */
  8757. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8758. /**
  8759. * Gets the far frustum plane transformed by the transform matrix
  8760. * @param transform transformation matrix to be applied to the resulting frustum plane
  8761. * @param frustumPlane the resuling frustum plane
  8762. */
  8763. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8764. /**
  8765. * Gets the left frustum plane transformed by the transform matrix
  8766. * @param transform transformation matrix to be applied to the resulting frustum plane
  8767. * @param frustumPlane the resuling frustum plane
  8768. */
  8769. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8770. /**
  8771. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8776. /**
  8777. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8782. /**
  8783. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8788. /**
  8789. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8790. * @param transform transformation matrix to be applied to the resulting frustum planes
  8791. * @param frustumPlanes the resuling frustum planes
  8792. */
  8793. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8794. }
  8795. }
  8796. declare module BABYLON {
  8797. /**
  8798. * Interface for the size containing width and height
  8799. */
  8800. export interface ISize {
  8801. /**
  8802. * Width
  8803. */
  8804. width: number;
  8805. /**
  8806. * Heighht
  8807. */
  8808. height: number;
  8809. }
  8810. /**
  8811. * Size containing widht and height
  8812. */
  8813. export class Size implements ISize {
  8814. /**
  8815. * Width
  8816. */
  8817. width: number;
  8818. /**
  8819. * Height
  8820. */
  8821. height: number;
  8822. /**
  8823. * Creates a Size object from the given width and height (floats).
  8824. * @param width width of the new size
  8825. * @param height height of the new size
  8826. */
  8827. constructor(width: number, height: number);
  8828. /**
  8829. * Returns a string with the Size width and height
  8830. * @returns a string with the Size width and height
  8831. */
  8832. toString(): string;
  8833. /**
  8834. * "Size"
  8835. * @returns the string "Size"
  8836. */
  8837. getClassName(): string;
  8838. /**
  8839. * Returns the Size hash code.
  8840. * @returns a hash code for a unique width and height
  8841. */
  8842. getHashCode(): number;
  8843. /**
  8844. * Updates the current size from the given one.
  8845. * @param src the given size
  8846. */
  8847. copyFrom(src: Size): void;
  8848. /**
  8849. * Updates in place the current Size from the given floats.
  8850. * @param width width of the new size
  8851. * @param height height of the new size
  8852. * @returns the updated Size.
  8853. */
  8854. copyFromFloats(width: number, height: number): Size;
  8855. /**
  8856. * Updates in place the current Size from the given floats.
  8857. * @param width width to set
  8858. * @param height height to set
  8859. * @returns the updated Size.
  8860. */
  8861. set(width: number, height: number): Size;
  8862. /**
  8863. * Multiplies the width and height by numbers
  8864. * @param w factor to multiple the width by
  8865. * @param h factor to multiple the height by
  8866. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8867. */
  8868. multiplyByFloats(w: number, h: number): Size;
  8869. /**
  8870. * Clones the size
  8871. * @returns a new Size copied from the given one.
  8872. */
  8873. clone(): Size;
  8874. /**
  8875. * True if the current Size and the given one width and height are strictly equal.
  8876. * @param other the other size to compare against
  8877. * @returns True if the current Size and the given one width and height are strictly equal.
  8878. */
  8879. equals(other: Size): boolean;
  8880. /**
  8881. * The surface of the Size : width * height (float).
  8882. */
  8883. get surface(): number;
  8884. /**
  8885. * Create a new size of zero
  8886. * @returns a new Size set to (0.0, 0.0)
  8887. */
  8888. static Zero(): Size;
  8889. /**
  8890. * Sums the width and height of two sizes
  8891. * @param otherSize size to add to this size
  8892. * @returns a new Size set as the addition result of the current Size and the given one.
  8893. */
  8894. add(otherSize: Size): Size;
  8895. /**
  8896. * Subtracts the width and height of two
  8897. * @param otherSize size to subtract to this size
  8898. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8899. */
  8900. subtract(otherSize: Size): Size;
  8901. /**
  8902. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8903. * @param start starting size to lerp between
  8904. * @param end end size to lerp between
  8905. * @param amount amount to lerp between the start and end values
  8906. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8907. */
  8908. static Lerp(start: Size, end: Size, amount: number): Size;
  8909. }
  8910. }
  8911. declare module BABYLON {
  8912. /**
  8913. * Contains position and normal vectors for a vertex
  8914. */
  8915. export class PositionNormalVertex {
  8916. /** the position of the vertex (defaut: 0,0,0) */
  8917. position: Vector3;
  8918. /** the normal of the vertex (defaut: 0,1,0) */
  8919. normal: Vector3;
  8920. /**
  8921. * Creates a PositionNormalVertex
  8922. * @param position the position of the vertex (defaut: 0,0,0)
  8923. * @param normal the normal of the vertex (defaut: 0,1,0)
  8924. */
  8925. constructor(
  8926. /** the position of the vertex (defaut: 0,0,0) */
  8927. position?: Vector3,
  8928. /** the normal of the vertex (defaut: 0,1,0) */
  8929. normal?: Vector3);
  8930. /**
  8931. * Clones the PositionNormalVertex
  8932. * @returns the cloned PositionNormalVertex
  8933. */
  8934. clone(): PositionNormalVertex;
  8935. }
  8936. /**
  8937. * Contains position, normal and uv vectors for a vertex
  8938. */
  8939. export class PositionNormalTextureVertex {
  8940. /** the position of the vertex (defaut: 0,0,0) */
  8941. position: Vector3;
  8942. /** the normal of the vertex (defaut: 0,1,0) */
  8943. normal: Vector3;
  8944. /** the uv of the vertex (default: 0,0) */
  8945. uv: Vector2;
  8946. /**
  8947. * Creates a PositionNormalTextureVertex
  8948. * @param position the position of the vertex (defaut: 0,0,0)
  8949. * @param normal the normal of the vertex (defaut: 0,1,0)
  8950. * @param uv the uv of the vertex (default: 0,0)
  8951. */
  8952. constructor(
  8953. /** the position of the vertex (defaut: 0,0,0) */
  8954. position?: Vector3,
  8955. /** the normal of the vertex (defaut: 0,1,0) */
  8956. normal?: Vector3,
  8957. /** the uv of the vertex (default: 0,0) */
  8958. uv?: Vector2);
  8959. /**
  8960. * Clones the PositionNormalTextureVertex
  8961. * @returns the cloned PositionNormalTextureVertex
  8962. */
  8963. clone(): PositionNormalTextureVertex;
  8964. }
  8965. }
  8966. declare module BABYLON {
  8967. /**
  8968. * Enum defining the type of animations supported by InputBlock
  8969. */
  8970. export enum AnimatedInputBlockTypes {
  8971. /** No animation */
  8972. None = 0,
  8973. /** Time based animation. Will only work for floats */
  8974. Time = 1
  8975. }
  8976. }
  8977. declare module BABYLON {
  8978. /**
  8979. * Interface describing all the common properties and methods a shadow light needs to implement.
  8980. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8981. * as well as binding the different shadow properties to the effects.
  8982. */
  8983. export interface IShadowLight extends Light {
  8984. /**
  8985. * The light id in the scene (used in scene.findLighById for instance)
  8986. */
  8987. id: string;
  8988. /**
  8989. * The position the shdow will be casted from.
  8990. */
  8991. position: Vector3;
  8992. /**
  8993. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8994. */
  8995. direction: Vector3;
  8996. /**
  8997. * The transformed position. Position of the light in world space taking parenting in account.
  8998. */
  8999. transformedPosition: Vector3;
  9000. /**
  9001. * The transformed direction. Direction of the light in world space taking parenting in account.
  9002. */
  9003. transformedDirection: Vector3;
  9004. /**
  9005. * The friendly name of the light in the scene.
  9006. */
  9007. name: string;
  9008. /**
  9009. * Defines the shadow projection clipping minimum z value.
  9010. */
  9011. shadowMinZ: number;
  9012. /**
  9013. * Defines the shadow projection clipping maximum z value.
  9014. */
  9015. shadowMaxZ: number;
  9016. /**
  9017. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9018. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9019. */
  9020. computeTransformedInformation(): boolean;
  9021. /**
  9022. * Gets the scene the light belongs to.
  9023. * @returns The scene
  9024. */
  9025. getScene(): Scene;
  9026. /**
  9027. * Callback defining a custom Projection Matrix Builder.
  9028. * This can be used to override the default projection matrix computation.
  9029. */
  9030. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9031. /**
  9032. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9033. * @param matrix The materix to updated with the projection information
  9034. * @param viewMatrix The transform matrix of the light
  9035. * @param renderList The list of mesh to render in the map
  9036. * @returns The current light
  9037. */
  9038. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9039. /**
  9040. * Gets the current depth scale used in ESM.
  9041. * @returns The scale
  9042. */
  9043. getDepthScale(): number;
  9044. /**
  9045. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9046. * @returns true if a cube texture needs to be use
  9047. */
  9048. needCube(): boolean;
  9049. /**
  9050. * Detects if the projection matrix requires to be recomputed this frame.
  9051. * @returns true if it requires to be recomputed otherwise, false.
  9052. */
  9053. needProjectionMatrixCompute(): boolean;
  9054. /**
  9055. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9056. */
  9057. forceProjectionMatrixCompute(): void;
  9058. /**
  9059. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9062. */
  9063. getShadowDirection(faceIndex?: number): Vector3;
  9064. /**
  9065. * Gets the minZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the min for
  9067. * @returns the depth min z
  9068. */
  9069. getDepthMinZ(activeCamera: Camera): number;
  9070. /**
  9071. * Gets the maxZ used for shadow according to both the scene and the light.
  9072. * @param activeCamera The camera we are returning the max for
  9073. * @returns the depth max z
  9074. */
  9075. getDepthMaxZ(activeCamera: Camera): number;
  9076. }
  9077. /**
  9078. * Base implementation IShadowLight
  9079. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9080. */
  9081. export abstract class ShadowLight extends Light implements IShadowLight {
  9082. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9083. protected _position: Vector3;
  9084. protected _setPosition(value: Vector3): void;
  9085. /**
  9086. * Sets the position the shadow will be casted from. Also use as the light position for both
  9087. * point and spot lights.
  9088. */
  9089. get position(): Vector3;
  9090. /**
  9091. * Sets the position the shadow will be casted from. Also use as the light position for both
  9092. * point and spot lights.
  9093. */
  9094. set position(value: Vector3);
  9095. protected _direction: Vector3;
  9096. protected _setDirection(value: Vector3): void;
  9097. /**
  9098. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9099. * Also use as the light direction on spot and directional lights.
  9100. */
  9101. get direction(): Vector3;
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. set direction(value: Vector3);
  9107. protected _shadowMinZ: number;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. get shadowMinZ(): number;
  9112. /**
  9113. * Sets the shadow projection clipping minimum z value.
  9114. */
  9115. set shadowMinZ(value: number);
  9116. protected _shadowMaxZ: number;
  9117. /**
  9118. * Sets the shadow projection clipping maximum z value.
  9119. */
  9120. get shadowMaxZ(): number;
  9121. /**
  9122. * Gets the shadow projection clipping maximum z value.
  9123. */
  9124. set shadowMaxZ(value: number);
  9125. /**
  9126. * Callback defining a custom Projection Matrix Builder.
  9127. * This can be used to override the default projection matrix computation.
  9128. */
  9129. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9130. /**
  9131. * The transformed position. Position of the light in world space taking parenting in account.
  9132. */
  9133. transformedPosition: Vector3;
  9134. /**
  9135. * The transformed direction. Direction of the light in world space taking parenting in account.
  9136. */
  9137. transformedDirection: Vector3;
  9138. private _needProjectionMatrixCompute;
  9139. /**
  9140. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9141. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9142. */
  9143. computeTransformedInformation(): boolean;
  9144. /**
  9145. * Return the depth scale used for the shadow map.
  9146. * @returns the depth scale.
  9147. */
  9148. getDepthScale(): number;
  9149. /**
  9150. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9153. */
  9154. getShadowDirection(faceIndex?: number): Vector3;
  9155. /**
  9156. * Returns the ShadowLight absolute position in the World.
  9157. * @returns the position vector in world space
  9158. */
  9159. getAbsolutePosition(): Vector3;
  9160. /**
  9161. * Sets the ShadowLight direction toward the passed target.
  9162. * @param target The point to target in local space
  9163. * @returns the updated ShadowLight direction
  9164. */
  9165. setDirectionToTarget(target: Vector3): Vector3;
  9166. /**
  9167. * Returns the light rotation in euler definition.
  9168. * @returns the x y z rotation in local space.
  9169. */
  9170. getRotation(): Vector3;
  9171. /**
  9172. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9173. * @returns true if a cube texture needs to be use
  9174. */
  9175. needCube(): boolean;
  9176. /**
  9177. * Detects if the projection matrix requires to be recomputed this frame.
  9178. * @returns true if it requires to be recomputed otherwise, false.
  9179. */
  9180. needProjectionMatrixCompute(): boolean;
  9181. /**
  9182. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9183. */
  9184. forceProjectionMatrixCompute(): void;
  9185. /** @hidden */
  9186. _initCache(): void;
  9187. /** @hidden */
  9188. _isSynchronized(): boolean;
  9189. /**
  9190. * Computes the world matrix of the node
  9191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9192. * @returns the world matrix
  9193. */
  9194. computeWorldMatrix(force?: boolean): Matrix;
  9195. /**
  9196. * Gets the minZ used for shadow according to both the scene and the light.
  9197. * @param activeCamera The camera we are returning the min for
  9198. * @returns the depth min z
  9199. */
  9200. getDepthMinZ(activeCamera: Camera): number;
  9201. /**
  9202. * Gets the maxZ used for shadow according to both the scene and the light.
  9203. * @param activeCamera The camera we are returning the max for
  9204. * @returns the depth max z
  9205. */
  9206. getDepthMaxZ(activeCamera: Camera): number;
  9207. /**
  9208. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9209. * @param matrix The materix to updated with the projection information
  9210. * @param viewMatrix The transform matrix of the light
  9211. * @param renderList The list of mesh to render in the map
  9212. * @returns The current light
  9213. */
  9214. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9215. }
  9216. }
  9217. declare module BABYLON {
  9218. /** @hidden */
  9219. export var packingFunctions: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module BABYLON {
  9225. /** @hidden */
  9226. export var bayerDitherFunctions: {
  9227. name: string;
  9228. shader: string;
  9229. };
  9230. }
  9231. declare module BABYLON {
  9232. /** @hidden */
  9233. export var shadowMapFragmentDeclaration: {
  9234. name: string;
  9235. shader: string;
  9236. };
  9237. }
  9238. declare module BABYLON {
  9239. /** @hidden */
  9240. export var clipPlaneFragmentDeclaration: {
  9241. name: string;
  9242. shader: string;
  9243. };
  9244. }
  9245. declare module BABYLON {
  9246. /** @hidden */
  9247. export var clipPlaneFragment: {
  9248. name: string;
  9249. shader: string;
  9250. };
  9251. }
  9252. declare module BABYLON {
  9253. /** @hidden */
  9254. export var shadowMapFragment: {
  9255. name: string;
  9256. shader: string;
  9257. };
  9258. }
  9259. declare module BABYLON {
  9260. /** @hidden */
  9261. export var shadowMapPixelShader: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var bonesDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var morphTargetsVertexGlobalDeclaration: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var morphTargetsVertexDeclaration: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var instancesDeclaration: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var helperFunctions: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var shadowMapVertexDeclaration: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var clipPlaneVertexDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var morphTargetsVertex: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var instancesVertex: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var bonesVertex: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var shadowMapVertexNormalBias: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var shadowMapVertexMetric: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var clipPlaneVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var shadowMapVertexShader: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var depthBoxBlurPixelShader: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var shadowMapFragmentSoftTransparentShadow: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /**
  9380. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9381. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9382. */
  9383. export class EffectFallbacks implements IEffectFallbacks {
  9384. private _defines;
  9385. private _currentRank;
  9386. private _maxRank;
  9387. private _mesh;
  9388. /**
  9389. * Removes the fallback from the bound mesh.
  9390. */
  9391. unBindMesh(): void;
  9392. /**
  9393. * Adds a fallback on the specified property.
  9394. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9395. * @param define The name of the define in the shader
  9396. */
  9397. addFallback(rank: number, define: string): void;
  9398. /**
  9399. * Sets the mesh to use CPU skinning when needing to fallback.
  9400. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9401. * @param mesh The mesh to use the fallbacks.
  9402. */
  9403. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9404. /**
  9405. * Checks to see if more fallbacks are still availible.
  9406. */
  9407. get hasMoreFallbacks(): boolean;
  9408. /**
  9409. * Removes the defines that should be removed when falling back.
  9410. * @param currentDefines defines the current define statements for the shader.
  9411. * @param effect defines the current effect we try to compile
  9412. * @returns The resulting defines with defines of the current rank removed.
  9413. */
  9414. reduce(currentDefines: string, effect: Effect): string;
  9415. }
  9416. }
  9417. declare module BABYLON {
  9418. /**
  9419. * Interface used to define Action
  9420. */
  9421. export interface IAction {
  9422. /**
  9423. * Trigger for the action
  9424. */
  9425. trigger: number;
  9426. /** Options of the trigger */
  9427. triggerOptions: any;
  9428. /**
  9429. * Gets the trigger parameters
  9430. * @returns the trigger parameters
  9431. */
  9432. getTriggerParameter(): any;
  9433. /**
  9434. * Internal only - executes current action event
  9435. * @hidden
  9436. */
  9437. _executeCurrent(evt?: ActionEvent): void;
  9438. /**
  9439. * Serialize placeholder for child classes
  9440. * @param parent of child
  9441. * @returns the serialized object
  9442. */
  9443. serialize(parent: any): any;
  9444. /**
  9445. * Internal only
  9446. * @hidden
  9447. */
  9448. _prepare(): void;
  9449. /**
  9450. * Internal only - manager for action
  9451. * @hidden
  9452. */
  9453. _actionManager: Nullable<AbstractActionManager>;
  9454. /**
  9455. * Adds action to chain of actions, may be a DoNothingAction
  9456. * @param action defines the next action to execute
  9457. * @returns The action passed in
  9458. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9459. */
  9460. then(action: IAction): IAction;
  9461. }
  9462. /**
  9463. * The action to be carried out following a trigger
  9464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9465. */
  9466. export class Action implements IAction {
  9467. /** the trigger, with or without parameters, for the action */
  9468. triggerOptions: any;
  9469. /**
  9470. * Trigger for the action
  9471. */
  9472. trigger: number;
  9473. /**
  9474. * Internal only - manager for action
  9475. * @hidden
  9476. */
  9477. _actionManager: ActionManager;
  9478. private _nextActiveAction;
  9479. private _child;
  9480. private _condition?;
  9481. private _triggerParameter;
  9482. /**
  9483. * An event triggered prior to action being executed.
  9484. */
  9485. onBeforeExecuteObservable: Observable<Action>;
  9486. /**
  9487. * Creates a new Action
  9488. * @param triggerOptions the trigger, with or without parameters, for the action
  9489. * @param condition an optional determinant of action
  9490. */
  9491. constructor(
  9492. /** the trigger, with or without parameters, for the action */
  9493. triggerOptions: any, condition?: Condition);
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _prepare(): void;
  9499. /**
  9500. * Gets the trigger parameters
  9501. * @returns the trigger parameters
  9502. */
  9503. getTriggerParameter(): any;
  9504. /**
  9505. * Internal only - executes current action event
  9506. * @hidden
  9507. */
  9508. _executeCurrent(evt?: ActionEvent): void;
  9509. /**
  9510. * Execute placeholder for child classes
  9511. * @param evt optional action event
  9512. */
  9513. execute(evt?: ActionEvent): void;
  9514. /**
  9515. * Skips to next active action
  9516. */
  9517. skipToNextActiveAction(): void;
  9518. /**
  9519. * Adds action to chain of actions, may be a DoNothingAction
  9520. * @param action defines the next action to execute
  9521. * @returns The action passed in
  9522. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9523. */
  9524. then(action: Action): Action;
  9525. /**
  9526. * Internal only
  9527. * @hidden
  9528. */
  9529. _getProperty(propertyPath: string): string;
  9530. /**
  9531. * Internal only
  9532. * @hidden
  9533. */
  9534. _getEffectiveTarget(target: any, propertyPath: string): any;
  9535. /**
  9536. * Serialize placeholder for child classes
  9537. * @param parent of child
  9538. * @returns the serialized object
  9539. */
  9540. serialize(parent: any): any;
  9541. /**
  9542. * Internal only called by serialize
  9543. * @hidden
  9544. */
  9545. protected _serialize(serializedAction: any, parent?: any): any;
  9546. /**
  9547. * Internal only
  9548. * @hidden
  9549. */
  9550. static _SerializeValueAsString: (value: any) => string;
  9551. /**
  9552. * Internal only
  9553. * @hidden
  9554. */
  9555. static _GetTargetProperty: (target: Scene | Node) => {
  9556. name: string;
  9557. targetType: string;
  9558. value: string;
  9559. };
  9560. }
  9561. }
  9562. declare module BABYLON {
  9563. /**
  9564. * A Condition applied to an Action
  9565. */
  9566. export class Condition {
  9567. /**
  9568. * Internal only - manager for action
  9569. * @hidden
  9570. */
  9571. _actionManager: ActionManager;
  9572. /**
  9573. * Internal only
  9574. * @hidden
  9575. */
  9576. _evaluationId: number;
  9577. /**
  9578. * Internal only
  9579. * @hidden
  9580. */
  9581. _currentResult: boolean;
  9582. /**
  9583. * Creates a new Condition
  9584. * @param actionManager the manager of the action the condition is applied to
  9585. */
  9586. constructor(actionManager: ActionManager);
  9587. /**
  9588. * Check if the current condition is valid
  9589. * @returns a boolean
  9590. */
  9591. isValid(): boolean;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. _getProperty(propertyPath: string): string;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. _getEffectiveTarget(target: any, propertyPath: string): any;
  9602. /**
  9603. * Serialize placeholder for child classes
  9604. * @returns the serialized object
  9605. */
  9606. serialize(): any;
  9607. /**
  9608. * Internal only
  9609. * @hidden
  9610. */
  9611. protected _serialize(serializedCondition: any): any;
  9612. }
  9613. /**
  9614. * Defines specific conditional operators as extensions of Condition
  9615. */
  9616. export class ValueCondition extends Condition {
  9617. /** path to specify the property of the target the conditional operator uses */
  9618. propertyPath: string;
  9619. /** the value compared by the conditional operator against the current value of the property */
  9620. value: any;
  9621. /** the conditional operator, default ValueCondition.IsEqual */
  9622. operator: number;
  9623. /**
  9624. * Internal only
  9625. * @hidden
  9626. */
  9627. private static _IsEqual;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private static _IsDifferent;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private static _IsGreater;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private static _IsLesser;
  9643. /**
  9644. * returns the number for IsEqual
  9645. */
  9646. static get IsEqual(): number;
  9647. /**
  9648. * Returns the number for IsDifferent
  9649. */
  9650. static get IsDifferent(): number;
  9651. /**
  9652. * Returns the number for IsGreater
  9653. */
  9654. static get IsGreater(): number;
  9655. /**
  9656. * Returns the number for IsLesser
  9657. */
  9658. static get IsLesser(): number;
  9659. /**
  9660. * Internal only The action manager for the condition
  9661. * @hidden
  9662. */
  9663. _actionManager: ActionManager;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. private _target;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. private _effectiveTarget;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. private _property;
  9679. /**
  9680. * Creates a new ValueCondition
  9681. * @param actionManager manager for the action the condition applies to
  9682. * @param target for the action
  9683. * @param propertyPath path to specify the property of the target the conditional operator uses
  9684. * @param value the value compared by the conditional operator against the current value of the property
  9685. * @param operator the conditional operator, default ValueCondition.IsEqual
  9686. */
  9687. constructor(actionManager: ActionManager, target: any,
  9688. /** path to specify the property of the target the conditional operator uses */
  9689. propertyPath: string,
  9690. /** the value compared by the conditional operator against the current value of the property */
  9691. value: any,
  9692. /** the conditional operator, default ValueCondition.IsEqual */
  9693. operator?: number);
  9694. /**
  9695. * Compares the given value with the property value for the specified conditional operator
  9696. * @returns the result of the comparison
  9697. */
  9698. isValid(): boolean;
  9699. /**
  9700. * Serialize the ValueCondition into a JSON compatible object
  9701. * @returns serialization object
  9702. */
  9703. serialize(): any;
  9704. /**
  9705. * Gets the name of the conditional operator for the ValueCondition
  9706. * @param operator the conditional operator
  9707. * @returns the name
  9708. */
  9709. static GetOperatorName(operator: number): string;
  9710. }
  9711. /**
  9712. * Defines a predicate condition as an extension of Condition
  9713. */
  9714. export class PredicateCondition extends Condition {
  9715. /** defines the predicate function used to validate the condition */
  9716. predicate: () => boolean;
  9717. /**
  9718. * Internal only - manager for action
  9719. * @hidden
  9720. */
  9721. _actionManager: ActionManager;
  9722. /**
  9723. * Creates a new PredicateCondition
  9724. * @param actionManager manager for the action the condition applies to
  9725. * @param predicate defines the predicate function used to validate the condition
  9726. */
  9727. constructor(actionManager: ActionManager,
  9728. /** defines the predicate function used to validate the condition */
  9729. predicate: () => boolean);
  9730. /**
  9731. * @returns the validity of the predicate condition
  9732. */
  9733. isValid(): boolean;
  9734. }
  9735. /**
  9736. * Defines a state condition as an extension of Condition
  9737. */
  9738. export class StateCondition extends Condition {
  9739. /** Value to compare with target state */
  9740. value: string;
  9741. /**
  9742. * Internal only - manager for action
  9743. * @hidden
  9744. */
  9745. _actionManager: ActionManager;
  9746. /**
  9747. * Internal only
  9748. * @hidden
  9749. */
  9750. private _target;
  9751. /**
  9752. * Creates a new StateCondition
  9753. * @param actionManager manager for the action the condition applies to
  9754. * @param target of the condition
  9755. * @param value to compare with target state
  9756. */
  9757. constructor(actionManager: ActionManager, target: any,
  9758. /** Value to compare with target state */
  9759. value: string);
  9760. /**
  9761. * Gets a boolean indicating if the current condition is met
  9762. * @returns the validity of the state
  9763. */
  9764. isValid(): boolean;
  9765. /**
  9766. * Serialize the StateCondition into a JSON compatible object
  9767. * @returns serialization object
  9768. */
  9769. serialize(): any;
  9770. }
  9771. }
  9772. declare module BABYLON {
  9773. /**
  9774. * This defines an action responsible to toggle a boolean once triggered.
  9775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9776. */
  9777. export class SwitchBooleanAction extends Action {
  9778. /**
  9779. * The path to the boolean property in the target object
  9780. */
  9781. propertyPath: string;
  9782. private _target;
  9783. private _effectiveTarget;
  9784. private _property;
  9785. /**
  9786. * Instantiate the action
  9787. * @param triggerOptions defines the trigger options
  9788. * @param target defines the object containing the boolean
  9789. * @param propertyPath defines the path to the boolean property in the target object
  9790. * @param condition defines the trigger related conditions
  9791. */
  9792. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9793. /** @hidden */
  9794. _prepare(): void;
  9795. /**
  9796. * Execute the action toggle the boolean value.
  9797. */
  9798. execute(): void;
  9799. /**
  9800. * Serializes the actions and its related information.
  9801. * @param parent defines the object to serialize in
  9802. * @returns the serialized object
  9803. */
  9804. serialize(parent: any): any;
  9805. }
  9806. /**
  9807. * This defines an action responsible to set a the state field of the target
  9808. * to a desired value once triggered.
  9809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9810. */
  9811. export class SetStateAction extends Action {
  9812. /**
  9813. * The value to store in the state field.
  9814. */
  9815. value: string;
  9816. private _target;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the state property
  9821. * @param value defines the value to store in the state field
  9822. * @param condition defines the trigger related conditions
  9823. */
  9824. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9825. /**
  9826. * Execute the action and store the value on the target state property.
  9827. */
  9828. execute(): void;
  9829. /**
  9830. * Serializes the actions and its related information.
  9831. * @param parent defines the object to serialize in
  9832. * @returns the serialized object
  9833. */
  9834. serialize(parent: any): any;
  9835. }
  9836. /**
  9837. * This defines an action responsible to set a property of the target
  9838. * to a desired value once triggered.
  9839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9840. */
  9841. export class SetValueAction extends Action {
  9842. /**
  9843. * The path of the property to set in the target.
  9844. */
  9845. propertyPath: string;
  9846. /**
  9847. * The value to set in the property
  9848. */
  9849. value: any;
  9850. private _target;
  9851. private _effectiveTarget;
  9852. private _property;
  9853. /**
  9854. * Instantiate the action
  9855. * @param triggerOptions defines the trigger options
  9856. * @param target defines the object containing the property
  9857. * @param propertyPath defines the path of the property to set in the target
  9858. * @param value defines the value to set in the property
  9859. * @param condition defines the trigger related conditions
  9860. */
  9861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9862. /** @hidden */
  9863. _prepare(): void;
  9864. /**
  9865. * Execute the action and set the targetted property to the desired value.
  9866. */
  9867. execute(): void;
  9868. /**
  9869. * Serializes the actions and its related information.
  9870. * @param parent defines the object to serialize in
  9871. * @returns the serialized object
  9872. */
  9873. serialize(parent: any): any;
  9874. }
  9875. /**
  9876. * This defines an action responsible to increment the target value
  9877. * to a desired value once triggered.
  9878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9879. */
  9880. export class IncrementValueAction extends Action {
  9881. /**
  9882. * The path of the property to increment in the target.
  9883. */
  9884. propertyPath: string;
  9885. /**
  9886. * The value we should increment the property by.
  9887. */
  9888. value: any;
  9889. private _target;
  9890. private _effectiveTarget;
  9891. private _property;
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param target defines the object containing the property
  9896. * @param propertyPath defines the path of the property to increment in the target
  9897. * @param value defines the value value we should increment the property by
  9898. * @param condition defines the trigger related conditions
  9899. */
  9900. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9901. /** @hidden */
  9902. _prepare(): void;
  9903. /**
  9904. * Execute the action and increment the target of the value amount.
  9905. */
  9906. execute(): void;
  9907. /**
  9908. * Serializes the actions and its related information.
  9909. * @param parent defines the object to serialize in
  9910. * @returns the serialized object
  9911. */
  9912. serialize(parent: any): any;
  9913. }
  9914. /**
  9915. * This defines an action responsible to start an animation once triggered.
  9916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9917. */
  9918. export class PlayAnimationAction extends Action {
  9919. /**
  9920. * Where the animation should start (animation frame)
  9921. */
  9922. from: number;
  9923. /**
  9924. * Where the animation should stop (animation frame)
  9925. */
  9926. to: number;
  9927. /**
  9928. * Define if the animation should loop or stop after the first play.
  9929. */
  9930. loop?: boolean;
  9931. private _target;
  9932. /**
  9933. * Instantiate the action
  9934. * @param triggerOptions defines the trigger options
  9935. * @param target defines the target animation or animation name
  9936. * @param from defines from where the animation should start (animation frame)
  9937. * @param end defines where the animation should stop (animation frame)
  9938. * @param loop defines if the animation should loop or stop after the first play
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and play the animation.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to stop an animation once triggered.
  9957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class StopAnimationAction extends Action {
  9960. private _target;
  9961. /**
  9962. * Instantiate the action
  9963. * @param triggerOptions defines the trigger options
  9964. * @param target defines the target animation or animation name
  9965. * @param condition defines the trigger related conditions
  9966. */
  9967. constructor(triggerOptions: any, target: any, condition?: Condition);
  9968. /** @hidden */
  9969. _prepare(): void;
  9970. /**
  9971. * Execute the action and stop the animation.
  9972. */
  9973. execute(): void;
  9974. /**
  9975. * Serializes the actions and its related information.
  9976. * @param parent defines the object to serialize in
  9977. * @returns the serialized object
  9978. */
  9979. serialize(parent: any): any;
  9980. }
  9981. /**
  9982. * This defines an action responsible that does nothing once triggered.
  9983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9984. */
  9985. export class DoNothingAction extends Action {
  9986. /**
  9987. * Instantiate the action
  9988. * @param triggerOptions defines the trigger options
  9989. * @param condition defines the trigger related conditions
  9990. */
  9991. constructor(triggerOptions?: any, condition?: Condition);
  9992. /**
  9993. * Execute the action and do nothing.
  9994. */
  9995. execute(): void;
  9996. /**
  9997. * Serializes the actions and its related information.
  9998. * @param parent defines the object to serialize in
  9999. * @returns the serialized object
  10000. */
  10001. serialize(parent: any): any;
  10002. }
  10003. /**
  10004. * This defines an action responsible to trigger several actions once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class CombineAction extends Action {
  10008. /**
  10009. * The list of aggregated animations to run.
  10010. */
  10011. children: Action[];
  10012. /**
  10013. * Instantiate the action
  10014. * @param triggerOptions defines the trigger options
  10015. * @param children defines the list of aggregated animations to run
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10019. /** @hidden */
  10020. _prepare(): void;
  10021. /**
  10022. * Execute the action and executes all the aggregated actions.
  10023. */
  10024. execute(evt: ActionEvent): void;
  10025. /**
  10026. * Serializes the actions and its related information.
  10027. * @param parent defines the object to serialize in
  10028. * @returns the serialized object
  10029. */
  10030. serialize(parent: any): any;
  10031. }
  10032. /**
  10033. * This defines an action responsible to run code (external event) once triggered.
  10034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10035. */
  10036. export class ExecuteCodeAction extends Action {
  10037. /**
  10038. * The callback function to run.
  10039. */
  10040. func: (evt: ActionEvent) => void;
  10041. /**
  10042. * Instantiate the action
  10043. * @param triggerOptions defines the trigger options
  10044. * @param func defines the callback function to run
  10045. * @param condition defines the trigger related conditions
  10046. */
  10047. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10048. /**
  10049. * Execute the action and run the attached code.
  10050. */
  10051. execute(evt: ActionEvent): void;
  10052. }
  10053. /**
  10054. * This defines an action responsible to set the parent property of the target once triggered.
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10056. */
  10057. export class SetParentAction extends Action {
  10058. private _parent;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the target containing the parent property
  10064. * @param parent defines from where the animation should start (animation frame)
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10068. /** @hidden */
  10069. _prepare(): void;
  10070. /**
  10071. * Execute the action and set the parent property.
  10072. */
  10073. execute(): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. }
  10082. declare module BABYLON {
  10083. /**
  10084. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10085. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10087. */
  10088. export class ActionManager extends AbstractActionManager {
  10089. /**
  10090. * Nothing
  10091. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10092. */
  10093. static readonly NothingTrigger: number;
  10094. /**
  10095. * On pick
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickTrigger: number;
  10099. /**
  10100. * On left pick
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLeftPickTrigger: number;
  10104. /**
  10105. * On right pick
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnRightPickTrigger: number;
  10109. /**
  10110. * On center pick
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnCenterPickTrigger: number;
  10114. /**
  10115. * On pick down
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnPickDownTrigger: number;
  10119. /**
  10120. * On double pick
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnDoublePickTrigger: number;
  10124. /**
  10125. * On pick up
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnPickUpTrigger: number;
  10129. /**
  10130. * On pick out.
  10131. * This trigger will only be raised if you also declared a OnPickDown
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10133. */
  10134. static readonly OnPickOutTrigger: number;
  10135. /**
  10136. * On long press
  10137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly OnLongPressTrigger: number;
  10140. /**
  10141. * On pointer over
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnPointerOverTrigger: number;
  10145. /**
  10146. * On pointer out
  10147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnPointerOutTrigger: number;
  10150. /**
  10151. * On every frame
  10152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnEveryFrameTrigger: number;
  10155. /**
  10156. * On intersection enter
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnIntersectionEnterTrigger: number;
  10160. /**
  10161. * On intersection exit
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnIntersectionExitTrigger: number;
  10165. /**
  10166. * On key down
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10168. */
  10169. static readonly OnKeyDownTrigger: number;
  10170. /**
  10171. * On key up
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10173. */
  10174. static readonly OnKeyUpTrigger: number;
  10175. private _scene;
  10176. /**
  10177. * Creates a new action manager
  10178. * @param scene defines the hosting scene
  10179. */
  10180. constructor(scene: Scene);
  10181. /**
  10182. * Releases all associated resources
  10183. */
  10184. dispose(): void;
  10185. /**
  10186. * Gets hosting scene
  10187. * @returns the hosting scene
  10188. */
  10189. getScene(): Scene;
  10190. /**
  10191. * Does this action manager handles actions of any of the given triggers
  10192. * @param triggers defines the triggers to be tested
  10193. * @return a boolean indicating whether one (or more) of the triggers is handled
  10194. */
  10195. hasSpecificTriggers(triggers: number[]): boolean;
  10196. /**
  10197. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10198. * speed.
  10199. * @param triggerA defines the trigger to be tested
  10200. * @param triggerB defines the trigger to be tested
  10201. * @return a boolean indicating whether one (or more) of the triggers is handled
  10202. */
  10203. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10204. /**
  10205. * Does this action manager handles actions of a given trigger
  10206. * @param trigger defines the trigger to be tested
  10207. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10208. * @return whether the trigger is handled
  10209. */
  10210. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10211. /**
  10212. * Does this action manager has pointer triggers
  10213. */
  10214. get hasPointerTriggers(): boolean;
  10215. /**
  10216. * Does this action manager has pick triggers
  10217. */
  10218. get hasPickTriggers(): boolean;
  10219. /**
  10220. * Registers an action to this action manager
  10221. * @param action defines the action to be registered
  10222. * @return the action amended (prepared) after registration
  10223. */
  10224. registerAction(action: IAction): Nullable<IAction>;
  10225. /**
  10226. * Unregisters an action to this action manager
  10227. * @param action defines the action to be unregistered
  10228. * @return a boolean indicating whether the action has been unregistered
  10229. */
  10230. unregisterAction(action: IAction): Boolean;
  10231. /**
  10232. * Process a specific trigger
  10233. * @param trigger defines the trigger to process
  10234. * @param evt defines the event details to be processed
  10235. */
  10236. processTrigger(trigger: number, evt?: IActionEvent): void;
  10237. /** @hidden */
  10238. _getEffectiveTarget(target: any, propertyPath: string): any;
  10239. /** @hidden */
  10240. _getProperty(propertyPath: string): string;
  10241. /**
  10242. * Serialize this manager to a JSON object
  10243. * @param name defines the property name to store this manager
  10244. * @returns a JSON representation of this manager
  10245. */
  10246. serialize(name: string): any;
  10247. /**
  10248. * Creates a new ActionManager from a JSON data
  10249. * @param parsedActions defines the JSON data to read from
  10250. * @param object defines the hosting mesh
  10251. * @param scene defines the hosting scene
  10252. */
  10253. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10254. /**
  10255. * Get a trigger name by index
  10256. * @param trigger defines the trigger index
  10257. * @returns a trigger name
  10258. */
  10259. static GetTriggerName(trigger: number): string;
  10260. }
  10261. }
  10262. declare module BABYLON {
  10263. /**
  10264. * Class used to represent a sprite
  10265. * @see https://doc.babylonjs.com/babylon101/sprites
  10266. */
  10267. export class Sprite implements IAnimatable {
  10268. /** defines the name */
  10269. name: string;
  10270. /** Gets or sets the current world position */
  10271. position: Vector3;
  10272. /** Gets or sets the main color */
  10273. color: Color4;
  10274. /** Gets or sets the width */
  10275. width: number;
  10276. /** Gets or sets the height */
  10277. height: number;
  10278. /** Gets or sets rotation angle */
  10279. angle: number;
  10280. /** Gets or sets the cell index in the sprite sheet */
  10281. cellIndex: number;
  10282. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10283. cellRef: string;
  10284. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10285. invertU: boolean;
  10286. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10287. invertV: boolean;
  10288. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10289. disposeWhenFinishedAnimating: boolean;
  10290. /** Gets the list of attached animations */
  10291. animations: Nullable<Array<Animation>>;
  10292. /** Gets or sets a boolean indicating if the sprite can be picked */
  10293. isPickable: boolean;
  10294. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10295. useAlphaForPicking: boolean;
  10296. /** @hidden */
  10297. _xOffset: number;
  10298. /** @hidden */
  10299. _yOffset: number;
  10300. /** @hidden */
  10301. _xSize: number;
  10302. /** @hidden */
  10303. _ySize: number;
  10304. /**
  10305. * Gets or sets the associated action manager
  10306. */
  10307. actionManager: Nullable<ActionManager>;
  10308. /**
  10309. * An event triggered when the control has been disposed
  10310. */
  10311. onDisposeObservable: Observable<Sprite>;
  10312. private _animationStarted;
  10313. private _loopAnimation;
  10314. private _fromIndex;
  10315. private _toIndex;
  10316. private _delay;
  10317. private _direction;
  10318. private _manager;
  10319. private _time;
  10320. private _onAnimationEnd;
  10321. /**
  10322. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10323. */
  10324. isVisible: boolean;
  10325. /**
  10326. * Gets or sets the sprite size
  10327. */
  10328. get size(): number;
  10329. set size(value: number);
  10330. /**
  10331. * Returns a boolean indicating if the animation is started
  10332. */
  10333. get animationStarted(): boolean;
  10334. /**
  10335. * Gets or sets the unique id of the sprite
  10336. */
  10337. uniqueId: number;
  10338. /**
  10339. * Gets the manager of this sprite
  10340. */
  10341. get manager(): ISpriteManager;
  10342. /**
  10343. * Creates a new Sprite
  10344. * @param name defines the name
  10345. * @param manager defines the manager
  10346. */
  10347. constructor(
  10348. /** defines the name */
  10349. name: string, manager: ISpriteManager);
  10350. /**
  10351. * Returns the string "Sprite"
  10352. * @returns "Sprite"
  10353. */
  10354. getClassName(): string;
  10355. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10356. get fromIndex(): number;
  10357. set fromIndex(value: number);
  10358. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10359. get toIndex(): number;
  10360. set toIndex(value: number);
  10361. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10362. get loopAnimation(): boolean;
  10363. set loopAnimation(value: boolean);
  10364. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10365. get delay(): number;
  10366. set delay(value: number);
  10367. /**
  10368. * Starts an animation
  10369. * @param from defines the initial key
  10370. * @param to defines the end key
  10371. * @param loop defines if the animation must loop
  10372. * @param delay defines the start delay (in ms)
  10373. * @param onAnimationEnd defines a callback to call when animation ends
  10374. */
  10375. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10376. /** Stops current animation (if any) */
  10377. stopAnimation(): void;
  10378. /** @hidden */
  10379. _animate(deltaTime: number): void;
  10380. /** Release associated resources */
  10381. dispose(): void;
  10382. /**
  10383. * Serializes the sprite to a JSON object
  10384. * @returns the JSON object
  10385. */
  10386. serialize(): any;
  10387. /**
  10388. * Parses a JSON object to create a new sprite
  10389. * @param parsedSprite The JSON object to parse
  10390. * @param manager defines the hosting manager
  10391. * @returns the new sprite
  10392. */
  10393. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10394. }
  10395. }
  10396. declare module BABYLON {
  10397. /**
  10398. * Information about the result of picking within a scene
  10399. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10400. */
  10401. export class PickingInfo {
  10402. /** @hidden */
  10403. _pickingUnavailable: boolean;
  10404. /**
  10405. * If the pick collided with an object
  10406. */
  10407. hit: boolean;
  10408. /**
  10409. * Distance away where the pick collided
  10410. */
  10411. distance: number;
  10412. /**
  10413. * The location of pick collision
  10414. */
  10415. pickedPoint: Nullable<Vector3>;
  10416. /**
  10417. * The mesh corresponding the the pick collision
  10418. */
  10419. pickedMesh: Nullable<AbstractMesh>;
  10420. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10421. bu: number;
  10422. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10423. bv: number;
  10424. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10425. faceId: number;
  10426. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10427. subMeshFaceId: number;
  10428. /** Id of the the submesh that was picked */
  10429. subMeshId: number;
  10430. /** If a sprite was picked, this will be the sprite the pick collided with */
  10431. pickedSprite: Nullable<Sprite>;
  10432. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10433. thinInstanceIndex: number;
  10434. /**
  10435. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10436. */
  10437. originMesh: Nullable<AbstractMesh>;
  10438. /**
  10439. * The ray that was used to perform the picking.
  10440. */
  10441. ray: Nullable<Ray>;
  10442. /**
  10443. * Gets the normal correspodning to the face the pick collided with
  10444. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10445. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10446. * @returns The normal correspodning to the face the pick collided with
  10447. */
  10448. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10449. /**
  10450. * Gets the texture coordinates of where the pick occured
  10451. * @returns the vector containing the coordnates of the texture
  10452. */
  10453. getTextureCoordinates(): Nullable<Vector2>;
  10454. }
  10455. }
  10456. declare module BABYLON {
  10457. /**
  10458. * Class representing a ray with position and direction
  10459. */
  10460. export class Ray {
  10461. /** origin point */
  10462. origin: Vector3;
  10463. /** direction */
  10464. direction: Vector3;
  10465. /** length of the ray */
  10466. length: number;
  10467. private static readonly _TmpVector3;
  10468. private _tmpRay;
  10469. /**
  10470. * Creates a new ray
  10471. * @param origin origin point
  10472. * @param direction direction
  10473. * @param length length of the ray
  10474. */
  10475. constructor(
  10476. /** origin point */
  10477. origin: Vector3,
  10478. /** direction */
  10479. direction: Vector3,
  10480. /** length of the ray */
  10481. length?: number);
  10482. /**
  10483. * Checks if the ray intersects a box
  10484. * This does not account for the ray lenght by design to improve perfs.
  10485. * @param minimum bound of the box
  10486. * @param maximum bound of the box
  10487. * @param intersectionTreshold extra extend to be added to the box in all direction
  10488. * @returns if the box was hit
  10489. */
  10490. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10491. /**
  10492. * Checks if the ray intersects a box
  10493. * This does not account for the ray lenght by design to improve perfs.
  10494. * @param box the bounding box to check
  10495. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10496. * @returns if the box was hit
  10497. */
  10498. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10499. /**
  10500. * If the ray hits a sphere
  10501. * @param sphere the bounding sphere to check
  10502. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10503. * @returns true if it hits the sphere
  10504. */
  10505. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10506. /**
  10507. * If the ray hits a triange
  10508. * @param vertex0 triangle vertex
  10509. * @param vertex1 triangle vertex
  10510. * @param vertex2 triangle vertex
  10511. * @returns intersection information if hit
  10512. */
  10513. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10514. /**
  10515. * Checks if ray intersects a plane
  10516. * @param plane the plane to check
  10517. * @returns the distance away it was hit
  10518. */
  10519. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10520. /**
  10521. * Calculate the intercept of a ray on a given axis
  10522. * @param axis to check 'x' | 'y' | 'z'
  10523. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10524. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10525. */
  10526. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10527. /**
  10528. * Checks if ray intersects a mesh
  10529. * @param mesh the mesh to check
  10530. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10531. * @returns picking info of the intersecton
  10532. */
  10533. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10534. /**
  10535. * Checks if ray intersects a mesh
  10536. * @param meshes the meshes to check
  10537. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10538. * @param results array to store result in
  10539. * @returns Array of picking infos
  10540. */
  10541. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10542. private _comparePickingInfo;
  10543. private static smallnum;
  10544. private static rayl;
  10545. /**
  10546. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10547. * @param sega the first point of the segment to test the intersection against
  10548. * @param segb the second point of the segment to test the intersection against
  10549. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10550. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10551. */
  10552. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10553. /**
  10554. * Update the ray from viewport position
  10555. * @param x position
  10556. * @param y y position
  10557. * @param viewportWidth viewport width
  10558. * @param viewportHeight viewport height
  10559. * @param world world matrix
  10560. * @param view view matrix
  10561. * @param projection projection matrix
  10562. * @returns this ray updated
  10563. */
  10564. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10565. /**
  10566. * Creates a ray with origin and direction of 0,0,0
  10567. * @returns the new ray
  10568. */
  10569. static Zero(): Ray;
  10570. /**
  10571. * Creates a new ray from screen space and viewport
  10572. * @param x position
  10573. * @param y y position
  10574. * @param viewportWidth viewport width
  10575. * @param viewportHeight viewport height
  10576. * @param world world matrix
  10577. * @param view view matrix
  10578. * @param projection projection matrix
  10579. * @returns new ray
  10580. */
  10581. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10582. /**
  10583. * 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
  10584. * transformed to the given world matrix.
  10585. * @param origin The origin point
  10586. * @param end The end point
  10587. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10588. * @returns the new ray
  10589. */
  10590. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10591. /**
  10592. * Transforms a ray by a matrix
  10593. * @param ray ray to transform
  10594. * @param matrix matrix to apply
  10595. * @returns the resulting new ray
  10596. */
  10597. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10598. /**
  10599. * Transforms a ray by a matrix
  10600. * @param ray ray to transform
  10601. * @param matrix matrix to apply
  10602. * @param result ray to store result in
  10603. */
  10604. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10605. /**
  10606. * Unproject a ray from screen space to object space
  10607. * @param sourceX defines the screen space x coordinate to use
  10608. * @param sourceY defines the screen space y coordinate to use
  10609. * @param viewportWidth defines the current width of the viewport
  10610. * @param viewportHeight defines the current height of the viewport
  10611. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10612. * @param view defines the view matrix to use
  10613. * @param projection defines the projection matrix to use
  10614. */
  10615. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10616. }
  10617. /**
  10618. * Type used to define predicate used to select faces when a mesh intersection is detected
  10619. */
  10620. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10621. interface Scene {
  10622. /** @hidden */
  10623. _tempPickingRay: Nullable<Ray>;
  10624. /** @hidden */
  10625. _cachedRayForTransform: Ray;
  10626. /** @hidden */
  10627. _pickWithRayInverseMatrix: Matrix;
  10628. /** @hidden */
  10629. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10630. /** @hidden */
  10631. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10632. /** @hidden */
  10633. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10634. }
  10635. }
  10636. declare module BABYLON {
  10637. /**
  10638. * Groups all the scene component constants in one place to ease maintenance.
  10639. * @hidden
  10640. */
  10641. export class SceneComponentConstants {
  10642. static readonly NAME_EFFECTLAYER: string;
  10643. static readonly NAME_LAYER: string;
  10644. static readonly NAME_LENSFLARESYSTEM: string;
  10645. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10646. static readonly NAME_PARTICLESYSTEM: string;
  10647. static readonly NAME_GAMEPAD: string;
  10648. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10649. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10650. static readonly NAME_PREPASSRENDERER: string;
  10651. static readonly NAME_DEPTHRENDERER: string;
  10652. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10653. static readonly NAME_SPRITE: string;
  10654. static readonly NAME_OUTLINERENDERER: string;
  10655. static readonly NAME_PROCEDURALTEXTURE: string;
  10656. static readonly NAME_SHADOWGENERATOR: string;
  10657. static readonly NAME_OCTREE: string;
  10658. static readonly NAME_PHYSICSENGINE: string;
  10659. static readonly NAME_AUDIO: string;
  10660. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10661. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10662. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10663. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10664. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10665. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10666. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10667. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10668. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10669. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10670. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10671. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10672. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10673. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10674. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10675. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10676. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10677. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10678. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10679. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10680. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10681. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10682. static readonly STEP_AFTERRENDER_AUDIO: number;
  10683. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10684. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10685. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10686. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10687. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10688. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10689. static readonly STEP_POINTERMOVE_SPRITE: number;
  10690. static readonly STEP_POINTERDOWN_SPRITE: number;
  10691. static readonly STEP_POINTERUP_SPRITE: number;
  10692. }
  10693. /**
  10694. * This represents a scene component.
  10695. *
  10696. * This is used to decouple the dependency the scene is having on the different workloads like
  10697. * layers, post processes...
  10698. */
  10699. export interface ISceneComponent {
  10700. /**
  10701. * The name of the component. Each component must have a unique name.
  10702. */
  10703. name: string;
  10704. /**
  10705. * The scene the component belongs to.
  10706. */
  10707. scene: Scene;
  10708. /**
  10709. * Register the component to one instance of a scene.
  10710. */
  10711. register(): void;
  10712. /**
  10713. * Rebuilds the elements related to this component in case of
  10714. * context lost for instance.
  10715. */
  10716. rebuild(): void;
  10717. /**
  10718. * Disposes the component and the associated ressources.
  10719. */
  10720. dispose(): void;
  10721. }
  10722. /**
  10723. * This represents a SERIALIZABLE scene component.
  10724. *
  10725. * This extends Scene Component to add Serialization methods on top.
  10726. */
  10727. export interface ISceneSerializableComponent extends ISceneComponent {
  10728. /**
  10729. * Adds all the elements from the container to the scene
  10730. * @param container the container holding the elements
  10731. */
  10732. addFromContainer(container: AbstractScene): void;
  10733. /**
  10734. * Removes all the elements in the container from the scene
  10735. * @param container contains the elements to remove
  10736. * @param dispose if the removed element should be disposed (default: false)
  10737. */
  10738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10739. /**
  10740. * Serializes the component data to the specified json object
  10741. * @param serializationObject The object to serialize to
  10742. */
  10743. serialize(serializationObject: any): void;
  10744. }
  10745. /**
  10746. * Strong typing of a Mesh related stage step action
  10747. */
  10748. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10749. /**
  10750. * Strong typing of a Evaluate Sub Mesh related stage step action
  10751. */
  10752. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10753. /**
  10754. * Strong typing of a Active Mesh related stage step action
  10755. */
  10756. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10757. /**
  10758. * Strong typing of a Camera related stage step action
  10759. */
  10760. export type CameraStageAction = (camera: Camera) => void;
  10761. /**
  10762. * Strong typing of a Camera Frame buffer related stage step action
  10763. */
  10764. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10765. /**
  10766. * Strong typing of a Render Target related stage step action
  10767. */
  10768. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10769. /**
  10770. * Strong typing of a RenderingGroup related stage step action
  10771. */
  10772. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10773. /**
  10774. * Strong typing of a Mesh Render related stage step action
  10775. */
  10776. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10777. /**
  10778. * Strong typing of a simple stage step action
  10779. */
  10780. export type SimpleStageAction = () => void;
  10781. /**
  10782. * Strong typing of a render target action.
  10783. */
  10784. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10785. /**
  10786. * Strong typing of a pointer move action.
  10787. */
  10788. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10789. /**
  10790. * Strong typing of a pointer up/down action.
  10791. */
  10792. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10793. /**
  10794. * Representation of a stage in the scene (Basically a list of ordered steps)
  10795. * @hidden
  10796. */
  10797. export class Stage<T extends Function> extends Array<{
  10798. index: number;
  10799. component: ISceneComponent;
  10800. action: T;
  10801. }> {
  10802. /**
  10803. * Hide ctor from the rest of the world.
  10804. * @param items The items to add.
  10805. */
  10806. private constructor();
  10807. /**
  10808. * Creates a new Stage.
  10809. * @returns A new instance of a Stage
  10810. */
  10811. static Create<T extends Function>(): Stage<T>;
  10812. /**
  10813. * Registers a step in an ordered way in the targeted stage.
  10814. * @param index Defines the position to register the step in
  10815. * @param component Defines the component attached to the step
  10816. * @param action Defines the action to launch during the step
  10817. */
  10818. registerStep(index: number, component: ISceneComponent, action: T): void;
  10819. /**
  10820. * Clears all the steps from the stage.
  10821. */
  10822. clear(): void;
  10823. }
  10824. }
  10825. declare module BABYLON {
  10826. interface Scene {
  10827. /** @hidden */
  10828. _pointerOverSprite: Nullable<Sprite>;
  10829. /** @hidden */
  10830. _pickedDownSprite: Nullable<Sprite>;
  10831. /** @hidden */
  10832. _tempSpritePickingRay: Nullable<Ray>;
  10833. /**
  10834. * All of the sprite managers added to this scene
  10835. * @see https://doc.babylonjs.com/babylon101/sprites
  10836. */
  10837. spriteManagers: Array<ISpriteManager>;
  10838. /**
  10839. * An event triggered when sprites rendering is about to start
  10840. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10841. */
  10842. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10843. /**
  10844. * An event triggered when sprites rendering is done
  10845. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10846. */
  10847. onAfterSpritesRenderingObservable: Observable<Scene>;
  10848. /** @hidden */
  10849. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10850. /** Launch a ray to try to pick a sprite in the scene
  10851. * @param x position on screen
  10852. * @param y position on screen
  10853. * @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
  10854. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10855. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10856. * @returns a PickingInfo
  10857. */
  10858. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10859. /** Use the given ray to pick a sprite in the scene
  10860. * @param ray The ray (in world space) to use to pick meshes
  10861. * @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
  10862. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10863. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10864. * @returns a PickingInfo
  10865. */
  10866. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10867. /** @hidden */
  10868. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10869. /** Launch a ray to try to pick sprites 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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10874. * @returns a PickingInfo array
  10875. */
  10876. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10877. /** Use the given ray to pick sprites in the scene
  10878. * @param ray The ray (in world space) to use to pick meshes
  10879. * @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
  10880. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10881. * @returns a PickingInfo array
  10882. */
  10883. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10884. /**
  10885. * Force the sprite under the pointer
  10886. * @param sprite defines the sprite to use
  10887. */
  10888. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10889. /**
  10890. * Gets the sprite under the pointer
  10891. * @returns a Sprite or null if no sprite is under the pointer
  10892. */
  10893. getPointerOverSprite(): Nullable<Sprite>;
  10894. }
  10895. /**
  10896. * Defines the sprite scene component responsible to manage sprites
  10897. * in a given scene.
  10898. */
  10899. export class SpriteSceneComponent implements ISceneComponent {
  10900. /**
  10901. * The component name helpfull to identify the component in the list of scene components.
  10902. */
  10903. readonly name: string;
  10904. /**
  10905. * The scene the component belongs to.
  10906. */
  10907. scene: Scene;
  10908. /** @hidden */
  10909. private _spritePredicate;
  10910. /**
  10911. * Creates a new instance of the component for the given scene
  10912. * @param scene Defines the scene to register the component in
  10913. */
  10914. constructor(scene: Scene);
  10915. /**
  10916. * Registers the component in a given scene
  10917. */
  10918. register(): void;
  10919. /**
  10920. * Rebuilds the elements related to this component in case of
  10921. * context lost for instance.
  10922. */
  10923. rebuild(): void;
  10924. /**
  10925. * Disposes the component and the associated ressources.
  10926. */
  10927. dispose(): void;
  10928. private _pickSpriteButKeepRay;
  10929. private _pointerMove;
  10930. private _pointerDown;
  10931. private _pointerUp;
  10932. }
  10933. }
  10934. declare module BABYLON {
  10935. /** @hidden */
  10936. export var fogFragmentDeclaration: {
  10937. name: string;
  10938. shader: string;
  10939. };
  10940. }
  10941. declare module BABYLON {
  10942. /** @hidden */
  10943. export var fogFragment: {
  10944. name: string;
  10945. shader: string;
  10946. };
  10947. }
  10948. declare module BABYLON {
  10949. /** @hidden */
  10950. export var spritesPixelShader: {
  10951. name: string;
  10952. shader: string;
  10953. };
  10954. }
  10955. declare module BABYLON {
  10956. /** @hidden */
  10957. export var fogVertexDeclaration: {
  10958. name: string;
  10959. shader: string;
  10960. };
  10961. }
  10962. declare module BABYLON {
  10963. /** @hidden */
  10964. export var spritesVertexShader: {
  10965. name: string;
  10966. shader: string;
  10967. };
  10968. }
  10969. declare module BABYLON {
  10970. /**
  10971. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10972. */
  10973. export interface ISpriteManager extends IDisposable {
  10974. /**
  10975. * Gets manager's name
  10976. */
  10977. name: string;
  10978. /**
  10979. * Restricts the camera to viewing objects with the same layerMask.
  10980. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10981. */
  10982. layerMask: number;
  10983. /**
  10984. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10985. */
  10986. isPickable: boolean;
  10987. /**
  10988. * Gets the hosting scene
  10989. */
  10990. scene: Scene;
  10991. /**
  10992. * Specifies the rendering group id for this mesh (0 by default)
  10993. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10994. */
  10995. renderingGroupId: number;
  10996. /**
  10997. * Defines the list of sprites managed by the manager.
  10998. */
  10999. sprites: Array<Sprite>;
  11000. /**
  11001. * Gets or sets the spritesheet texture
  11002. */
  11003. texture: Texture;
  11004. /** Defines the default width of a cell in the spritesheet */
  11005. cellWidth: number;
  11006. /** Defines the default height of a cell in the spritesheet */
  11007. cellHeight: number;
  11008. /**
  11009. * Tests the intersection of a sprite with a specific ray.
  11010. * @param ray The ray we are sending to test the collision
  11011. * @param camera The camera space we are sending rays in
  11012. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11013. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11014. * @returns picking info or null.
  11015. */
  11016. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11017. /**
  11018. * Intersects the sprites with a ray
  11019. * @param ray defines the ray to intersect with
  11020. * @param camera defines the current active camera
  11021. * @param predicate defines a predicate used to select candidate sprites
  11022. * @returns null if no hit or a PickingInfo array
  11023. */
  11024. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11025. /**
  11026. * Renders the list of sprites on screen.
  11027. */
  11028. render(): void;
  11029. }
  11030. /**
  11031. * Class used to manage multiple sprites on the same spritesheet
  11032. * @see https://doc.babylonjs.com/babylon101/sprites
  11033. */
  11034. export class SpriteManager implements ISpriteManager {
  11035. /** defines the manager's name */
  11036. name: string;
  11037. /** Define the Url to load snippets */
  11038. static SnippetUrl: string;
  11039. /** Snippet ID if the manager was created from the snippet server */
  11040. snippetId: string;
  11041. /** Gets the list of sprites */
  11042. sprites: Sprite[];
  11043. /** Gets or sets the rendering group id (0 by default) */
  11044. renderingGroupId: number;
  11045. /** Gets or sets camera layer mask */
  11046. layerMask: number;
  11047. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11048. fogEnabled: boolean;
  11049. /** Gets or sets a boolean indicating if the sprites are pickable */
  11050. isPickable: boolean;
  11051. /** Defines the default width of a cell in the spritesheet */
  11052. cellWidth: number;
  11053. /** Defines the default height of a cell in the spritesheet */
  11054. cellHeight: number;
  11055. /** Associative array from JSON sprite data file */
  11056. private _cellData;
  11057. /** Array of sprite names from JSON sprite data file */
  11058. private _spriteMap;
  11059. /** True when packed cell data from JSON file is ready*/
  11060. private _packedAndReady;
  11061. private _textureContent;
  11062. private _useInstancing;
  11063. /**
  11064. * An event triggered when the manager is disposed.
  11065. */
  11066. onDisposeObservable: Observable<SpriteManager>;
  11067. private _onDisposeObserver;
  11068. /**
  11069. * Callback called when the manager is disposed
  11070. */
  11071. set onDispose(callback: () => void);
  11072. private _capacity;
  11073. private _fromPacked;
  11074. private _spriteTexture;
  11075. private _epsilon;
  11076. private _scene;
  11077. private _vertexData;
  11078. private _buffer;
  11079. private _vertexBuffers;
  11080. private _spriteBuffer;
  11081. private _indexBuffer;
  11082. private _effectBase;
  11083. private _effectFog;
  11084. private _vertexBufferSize;
  11085. /**
  11086. * Gets or sets the unique id of the sprite
  11087. */
  11088. uniqueId: number;
  11089. /**
  11090. * Gets the array of sprites
  11091. */
  11092. get children(): Sprite[];
  11093. /**
  11094. * Gets the hosting scene
  11095. */
  11096. get scene(): Scene;
  11097. /**
  11098. * Gets the capacity of the manager
  11099. */
  11100. get capacity(): number;
  11101. /**
  11102. * Gets or sets the spritesheet texture
  11103. */
  11104. get texture(): Texture;
  11105. set texture(value: Texture);
  11106. private _blendMode;
  11107. /**
  11108. * Blend mode use to render the particle, it can be any of
  11109. * the static Constants.ALPHA_x properties provided in this class.
  11110. * Default value is Constants.ALPHA_COMBINE
  11111. */
  11112. get blendMode(): number;
  11113. set blendMode(blendMode: number);
  11114. /** Disables writing to the depth buffer when rendering the sprites.
  11115. * It can be handy to disable depth writing when using textures without alpha channel
  11116. * and setting some specific blend modes.
  11117. */
  11118. disableDepthWrite: boolean;
  11119. /**
  11120. * Creates a new sprite manager
  11121. * @param name defines the manager's name
  11122. * @param imgUrl defines the sprite sheet url
  11123. * @param capacity defines the maximum allowed number of sprites
  11124. * @param cellSize defines the size of a sprite cell
  11125. * @param scene defines the hosting scene
  11126. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11127. * @param samplingMode defines the smapling mode to use with spritesheet
  11128. * @param fromPacked set to false; do not alter
  11129. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11130. */
  11131. constructor(
  11132. /** defines the manager's name */
  11133. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11134. /**
  11135. * Returns the string "SpriteManager"
  11136. * @returns "SpriteManager"
  11137. */
  11138. getClassName(): string;
  11139. private _makePacked;
  11140. private _appendSpriteVertex;
  11141. private _checkTextureAlpha;
  11142. /**
  11143. * Intersects the sprites with a ray
  11144. * @param ray defines the ray to intersect with
  11145. * @param camera defines the current active camera
  11146. * @param predicate defines a predicate used to select candidate sprites
  11147. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11148. * @returns null if no hit or a PickingInfo
  11149. */
  11150. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11151. /**
  11152. * Intersects the sprites with a ray
  11153. * @param ray defines the ray to intersect with
  11154. * @param camera defines the current active camera
  11155. * @param predicate defines a predicate used to select candidate sprites
  11156. * @returns null if no hit or a PickingInfo array
  11157. */
  11158. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11159. /**
  11160. * Render all child sprites
  11161. */
  11162. render(): void;
  11163. /**
  11164. * Release associated resources
  11165. */
  11166. dispose(): void;
  11167. /**
  11168. * Serializes the sprite manager to a JSON object
  11169. * @param serializeTexture defines if the texture must be serialized as well
  11170. * @returns the JSON object
  11171. */
  11172. serialize(serializeTexture?: boolean): any;
  11173. /**
  11174. * Parses a JSON object to create a new sprite manager.
  11175. * @param parsedManager The JSON object to parse
  11176. * @param scene The scene to create the sprite managerin
  11177. * @param rootUrl The root url to use to load external dependencies like texture
  11178. * @returns the new sprite manager
  11179. */
  11180. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11181. /**
  11182. * Creates a sprite manager from a snippet saved in a remote file
  11183. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11184. * @param url defines the url to load from
  11185. * @param scene defines the hosting scene
  11186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11187. * @returns a promise that will resolve to the new sprite manager
  11188. */
  11189. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11190. /**
  11191. * Creates a sprite manager from a snippet saved by the sprite editor
  11192. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11193. * @param scene defines the hosting scene
  11194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11195. * @returns a promise that will resolve to the new sprite manager
  11196. */
  11197. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11198. }
  11199. }
  11200. declare module BABYLON {
  11201. /** Interface used by value gradients (color, factor, ...) */
  11202. export interface IValueGradient {
  11203. /**
  11204. * Gets or sets the gradient value (between 0 and 1)
  11205. */
  11206. gradient: number;
  11207. }
  11208. /** Class used to store color4 gradient */
  11209. export class ColorGradient implements IValueGradient {
  11210. /**
  11211. * Gets or sets the gradient value (between 0 and 1)
  11212. */
  11213. gradient: number;
  11214. /**
  11215. * Gets or sets first associated color
  11216. */
  11217. color1: Color4;
  11218. /**
  11219. * Gets or sets second associated color
  11220. */
  11221. color2?: Color4 | undefined;
  11222. /**
  11223. * Creates a new color4 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color1 gets or sets first associated color
  11226. * @param color2 gets or sets first second color
  11227. */
  11228. constructor(
  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. * Will get a color picked randomly between color1 and color2.
  11243. * If color2 is undefined then color1 will be used
  11244. * @param result defines the target Color4 to store the result in
  11245. */
  11246. getColorToRef(result: Color4): void;
  11247. }
  11248. /** Class used to store color 3 gradient */
  11249. export class Color3Gradient implements IValueGradient {
  11250. /**
  11251. * Gets or sets the gradient value (between 0 and 1)
  11252. */
  11253. gradient: number;
  11254. /**
  11255. * Gets or sets the associated color
  11256. */
  11257. color: Color3;
  11258. /**
  11259. * Creates a new color3 gradient
  11260. * @param gradient gets or sets the gradient value (between 0 and 1)
  11261. * @param color gets or sets associated color
  11262. */
  11263. constructor(
  11264. /**
  11265. * Gets or sets the gradient value (between 0 and 1)
  11266. */
  11267. gradient: number,
  11268. /**
  11269. * Gets or sets the associated color
  11270. */
  11271. color: Color3);
  11272. }
  11273. /** Class used to store factor gradient */
  11274. export class FactorGradient implements IValueGradient {
  11275. /**
  11276. * Gets or sets the gradient value (between 0 and 1)
  11277. */
  11278. gradient: number;
  11279. /**
  11280. * Gets or sets first associated factor
  11281. */
  11282. factor1: number;
  11283. /**
  11284. * Gets or sets second associated factor
  11285. */
  11286. factor2?: number | undefined;
  11287. /**
  11288. * Creates a new factor gradient
  11289. * @param gradient gets or sets the gradient value (between 0 and 1)
  11290. * @param factor1 gets or sets first associated factor
  11291. * @param factor2 gets or sets second associated factor
  11292. */
  11293. constructor(
  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. * Will get a number picked randomly between factor1 and factor2.
  11308. * If factor2 is undefined then factor1 will be used
  11309. * @returns the picked number
  11310. */
  11311. getFactor(): number;
  11312. }
  11313. /**
  11314. * Helper used to simplify some generic gradient tasks
  11315. */
  11316. export class GradientHelper {
  11317. /**
  11318. * Gets the current gradient from an array of IValueGradient
  11319. * @param ratio defines the current ratio to get
  11320. * @param gradients defines the array of IValueGradient
  11321. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11322. */
  11323. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11324. }
  11325. }
  11326. declare module BABYLON {
  11327. interface ThinEngine {
  11328. /**
  11329. * Creates a raw texture
  11330. * @param data defines the data to store in the texture
  11331. * @param width defines the width of the texture
  11332. * @param height defines the height of the texture
  11333. * @param format defines the format of the data
  11334. * @param generateMipMaps defines if the engine should generate the mip levels
  11335. * @param invertY defines if data must be stored with Y axis inverted
  11336. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11337. * @param compression defines the compression used (null by default)
  11338. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11339. * @returns the raw texture inside an InternalTexture
  11340. */
  11341. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11342. /**
  11343. * Update a raw texture
  11344. * @param texture defines the texture to update
  11345. * @param data defines the data to store in the texture
  11346. * @param format defines the format of the data
  11347. * @param invertY defines if data must be stored with Y axis inverted
  11348. */
  11349. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11350. /**
  11351. * Update a raw texture
  11352. * @param texture defines the texture to update
  11353. * @param data defines the data to store in the texture
  11354. * @param format defines the format of the data
  11355. * @param invertY defines if data must be stored with Y axis inverted
  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. */
  11359. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11360. /**
  11361. * Creates a new raw cube texture
  11362. * @param data defines the array of data to use to create each face
  11363. * @param size defines the size of the textures
  11364. * @param format defines the format of the data
  11365. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11366. * @param generateMipMaps defines if the engine should generate the mip levels
  11367. * @param invertY defines if data must be stored with Y axis inverted
  11368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11369. * @param compression defines the compression used (null by default)
  11370. * @returns the cube texture as an InternalTexture
  11371. */
  11372. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11373. /**
  11374. * Update a raw cube texture
  11375. * @param texture defines the texture to udpdate
  11376. * @param data defines the data to store
  11377. * @param format defines the data format
  11378. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11379. * @param invertY defines if data must be stored with Y axis inverted
  11380. */
  11381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11382. /**
  11383. * Update a raw cube texture
  11384. * @param texture defines the texture to udpdate
  11385. * @param data defines the data to store
  11386. * @param format defines the data format
  11387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11388. * @param invertY defines if data must be stored with Y axis inverted
  11389. * @param compression defines the compression used (null by default)
  11390. */
  11391. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  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. * @param compression defines the compression used (null by default)
  11400. * @param level defines which level of the texture to update
  11401. */
  11402. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @returns the cube texture as an InternalTexture
  11416. */
  11417. 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;
  11418. /**
  11419. * Creates a new raw cube texture from a specified url
  11420. * @param url defines the url where the data is located
  11421. * @param scene defines the current scene
  11422. * @param size defines the size of the textures
  11423. * @param format defines the format of the data
  11424. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11425. * @param noMipmap defines if the engine should avoid generating the mip levels
  11426. * @param callback defines a callback used to extract texture data from loaded data
  11427. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11428. * @param onLoad defines a callback called when texture is loaded
  11429. * @param onError defines a callback called if there is an error
  11430. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. * @returns the cube texture as an InternalTexture
  11433. */
  11434. 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;
  11435. /**
  11436. * Creates a new raw 3D texture
  11437. * @param data defines the data used to create the texture
  11438. * @param width defines the width of the texture
  11439. * @param height defines the height of the texture
  11440. * @param depth defines the depth of the texture
  11441. * @param format defines the format of the texture
  11442. * @param generateMipMaps defines if the engine must generate mip levels
  11443. * @param invertY defines if data must be stored with Y axis inverted
  11444. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11445. * @param compression defines the compressed used (can be null)
  11446. * @param textureType defines the compressed used (can be null)
  11447. * @returns a new raw 3D texture (stored in an InternalTexture)
  11448. */
  11449. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11450. /**
  11451. * Update a raw 3D texture
  11452. * @param texture defines the texture to update
  11453. * @param data defines the data to store
  11454. * @param format defines the data format
  11455. * @param invertY defines if data must be stored with Y axis inverted
  11456. */
  11457. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11458. /**
  11459. * Update a raw 3D texture
  11460. * @param texture defines the texture to update
  11461. * @param data defines the data to store
  11462. * @param format defines the data format
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param compression defines the used compression (can be null)
  11465. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11466. */
  11467. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11468. /**
  11469. * Creates a new raw 2D array texture
  11470. * @param data defines the data used to create the texture
  11471. * @param width defines the width of the texture
  11472. * @param height defines the height of the texture
  11473. * @param depth defines the number of layers of the texture
  11474. * @param format defines the format of the texture
  11475. * @param generateMipMaps defines if the engine must generate mip levels
  11476. * @param invertY defines if data must be stored with Y axis inverted
  11477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11478. * @param compression defines the compressed used (can be null)
  11479. * @param textureType defines the compressed used (can be null)
  11480. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11481. */
  11482. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11483. /**
  11484. * Update a raw 2D array texture
  11485. * @param texture defines the texture to update
  11486. * @param data defines the data to store
  11487. * @param format defines the data format
  11488. * @param invertY defines if data must be stored with Y axis inverted
  11489. */
  11490. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11491. /**
  11492. * Update a raw 2D array texture
  11493. * @param texture defines the texture to update
  11494. * @param data defines the data to store
  11495. * @param format defines the data format
  11496. * @param invertY defines if data must be stored with Y axis inverted
  11497. * @param compression defines the used compression (can be null)
  11498. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11499. */
  11500. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /**
  11505. * Raw texture can help creating a texture directly from an array of data.
  11506. * This can be super useful if you either get the data from an uncompressed source or
  11507. * if you wish to create your texture pixel by pixel.
  11508. */
  11509. export class RawTexture extends Texture {
  11510. /**
  11511. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11512. */
  11513. format: number;
  11514. /**
  11515. * Instantiates a new RawTexture.
  11516. * Raw texture can help creating a texture directly from an array of data.
  11517. * This can be super useful if you either get the data from an uncompressed source or
  11518. * if you wish to create your texture pixel by pixel.
  11519. * @param data define the array of data to use to create the texture
  11520. * @param width define the width of the texture
  11521. * @param height define the height of the texture
  11522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11523. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11524. * @param generateMipMaps define whether mip maps should be generated or not
  11525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11528. */
  11529. constructor(data: ArrayBufferView, width: number, height: number,
  11530. /**
  11531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11532. */
  11533. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11534. /**
  11535. * Updates the texture underlying data.
  11536. * @param data Define the new data of the texture
  11537. */
  11538. update(data: ArrayBufferView): void;
  11539. /**
  11540. * Creates a luminance texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @returns the luminance texture
  11549. */
  11550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11551. /**
  11552. * Creates a luminance alpha texture from some data.
  11553. * @param data Define the texture data
  11554. * @param width Define the width of the texture
  11555. * @param height Define the height of the texture
  11556. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11560. * @returns the luminance alpha texture
  11561. */
  11562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11563. /**
  11564. * Creates an alpha texture from some data.
  11565. * @param data Define the texture data
  11566. * @param width Define the width of the texture
  11567. * @param height Define the height of the texture
  11568. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11572. * @returns the alpha texture
  11573. */
  11574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11575. /**
  11576. * Creates a RGB texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGB alpha texture
  11586. */
  11587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a RGBA texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the RGBA texture
  11599. */
  11600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. /**
  11602. * Creates a R texture from some data.
  11603. * @param data Define the texture data
  11604. * @param width Define the width of the texture
  11605. * @param height Define the height of the texture
  11606. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11611. * @returns the R texture
  11612. */
  11613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11614. }
  11615. }
  11616. declare module BABYLON {
  11617. interface ThinEngine {
  11618. /**
  11619. * Update a dynamic index buffer
  11620. * @param indexBuffer defines the target index buffer
  11621. * @param indices defines the data to update
  11622. * @param offset defines the offset in the target index buffer where update should start
  11623. */
  11624. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11625. /**
  11626. * Updates a dynamic vertex buffer.
  11627. * @param vertexBuffer the vertex buffer to update
  11628. * @param data the data used to update the vertex buffer
  11629. * @param byteOffset the byte offset of the data
  11630. * @param byteLength the byte length of the data
  11631. */
  11632. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11633. }
  11634. }
  11635. declare module BABYLON {
  11636. interface AbstractScene {
  11637. /**
  11638. * The list of procedural textures added to the scene
  11639. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11640. */
  11641. proceduralTextures: Array<ProceduralTexture>;
  11642. }
  11643. /**
  11644. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11645. * in a given scene.
  11646. */
  11647. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11648. /**
  11649. * The component name helpfull to identify the component in the list of scene components.
  11650. */
  11651. readonly name: string;
  11652. /**
  11653. * The scene the component belongs to.
  11654. */
  11655. scene: Scene;
  11656. /**
  11657. * Creates a new instance of the component for the given scene
  11658. * @param scene Defines the scene to register the component in
  11659. */
  11660. constructor(scene: Scene);
  11661. /**
  11662. * Registers the component in a given scene
  11663. */
  11664. register(): void;
  11665. /**
  11666. * Rebuilds the elements related to this component in case of
  11667. * context lost for instance.
  11668. */
  11669. rebuild(): void;
  11670. /**
  11671. * Disposes the component and the associated ressources.
  11672. */
  11673. dispose(): void;
  11674. private _beforeClear;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. interface ThinEngine {
  11679. /**
  11680. * Creates a new render target cube texture
  11681. * @param size defines the size of the texture
  11682. * @param options defines the options used to create the texture
  11683. * @returns a new render target cube texture stored in an InternalTexture
  11684. */
  11685. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11686. }
  11687. }
  11688. declare module BABYLON {
  11689. /** @hidden */
  11690. export var proceduralVertexShader: {
  11691. name: string;
  11692. shader: string;
  11693. };
  11694. }
  11695. declare module BABYLON {
  11696. /**
  11697. * 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.
  11698. * This is the base class of any Procedural texture and contains most of the shareable code.
  11699. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11700. */
  11701. export class ProceduralTexture extends Texture {
  11702. /**
  11703. * Define if the texture is enabled or not (disabled texture will not render)
  11704. */
  11705. isEnabled: boolean;
  11706. /**
  11707. * Define if the texture must be cleared before rendering (default is true)
  11708. */
  11709. autoClear: boolean;
  11710. /**
  11711. * Callback called when the texture is generated
  11712. */
  11713. onGenerated: () => void;
  11714. /**
  11715. * Event raised when the texture is generated
  11716. */
  11717. onGeneratedObservable: Observable<ProceduralTexture>;
  11718. /**
  11719. * Event raised before the texture is generated
  11720. */
  11721. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11722. /**
  11723. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11724. */
  11725. nodeMaterialSource: Nullable<NodeMaterial>;
  11726. /** @hidden */
  11727. _generateMipMaps: boolean;
  11728. /** @hidden **/
  11729. _effect: Effect;
  11730. /** @hidden */
  11731. _textures: {
  11732. [key: string]: Texture;
  11733. };
  11734. /** @hidden */
  11735. protected _fallbackTexture: Nullable<Texture>;
  11736. private _size;
  11737. private _currentRefreshId;
  11738. private _frameId;
  11739. private _refreshRate;
  11740. private _vertexBuffers;
  11741. private _indexBuffer;
  11742. private _uniforms;
  11743. private _samplers;
  11744. private _fragment;
  11745. private _floats;
  11746. private _ints;
  11747. private _floatsArrays;
  11748. private _colors3;
  11749. private _colors4;
  11750. private _vectors2;
  11751. private _vectors3;
  11752. private _matrices;
  11753. private _fallbackTextureUsed;
  11754. private _fullEngine;
  11755. private _cachedDefines;
  11756. private _contentUpdateId;
  11757. private _contentData;
  11758. /**
  11759. * Instantiates a new procedural texture.
  11760. * 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.
  11761. * This is the base class of any Procedural texture and contains most of the shareable code.
  11762. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11763. * @param name Define the name of the texture
  11764. * @param size Define the size of the texture to create
  11765. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11766. * @param scene Define the scene the texture belongs to
  11767. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11768. * @param generateMipMaps Define if the texture should creates mip maps or not
  11769. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11770. */
  11771. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11772. /**
  11773. * The effect that is created when initializing the post process.
  11774. * @returns The created effect corresponding the the postprocess.
  11775. */
  11776. getEffect(): Effect;
  11777. /**
  11778. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11779. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11780. */
  11781. getContent(): Nullable<ArrayBufferView>;
  11782. private _createIndexBuffer;
  11783. /** @hidden */
  11784. _rebuild(): void;
  11785. /**
  11786. * Resets the texture in order to recreate its associated resources.
  11787. * This can be called in case of context loss
  11788. */
  11789. reset(): void;
  11790. protected _getDefines(): string;
  11791. /**
  11792. * Is the texture ready to be used ? (rendered at least once)
  11793. * @returns true if ready, otherwise, false.
  11794. */
  11795. isReady(): boolean;
  11796. /**
  11797. * Resets the refresh counter of the texture and start bak from scratch.
  11798. * Could be useful to regenerate the texture if it is setup to render only once.
  11799. */
  11800. resetRefreshCounter(): void;
  11801. /**
  11802. * Set the fragment shader to use in order to render the texture.
  11803. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11804. */
  11805. setFragment(fragment: any): void;
  11806. /**
  11807. * Define the refresh rate of the texture or the rendering frequency.
  11808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11809. */
  11810. get refreshRate(): number;
  11811. set refreshRate(value: number);
  11812. /** @hidden */
  11813. _shouldRender(): boolean;
  11814. /**
  11815. * Get the size the texture is rendering at.
  11816. * @returns the size (on cube texture it is always squared)
  11817. */
  11818. getRenderSize(): RenderTargetTextureSize;
  11819. /**
  11820. * Resize the texture to new value.
  11821. * @param size Define the new size the texture should have
  11822. * @param generateMipMaps Define whether the new texture should create mip maps
  11823. */
  11824. resize(size: number, generateMipMaps: boolean): void;
  11825. private _checkUniform;
  11826. /**
  11827. * Set a texture in the shader program used to render.
  11828. * @param name Define the name of the uniform samplers as defined in the shader
  11829. * @param texture Define the texture to bind to this sampler
  11830. * @return the texture itself allowing "fluent" like uniform updates
  11831. */
  11832. setTexture(name: string, texture: Texture): ProceduralTexture;
  11833. /**
  11834. * Set a float in the shader.
  11835. * @param name Define the name of the uniform as defined in the shader
  11836. * @param value Define the value to give to the uniform
  11837. * @return the texture itself allowing "fluent" like uniform updates
  11838. */
  11839. setFloat(name: string, value: number): ProceduralTexture;
  11840. /**
  11841. * Set a int in the shader.
  11842. * @param name Define the name of the uniform as defined in the shader
  11843. * @param value Define the value to give to the uniform
  11844. * @return the texture itself allowing "fluent" like uniform updates
  11845. */
  11846. setInt(name: string, value: number): ProceduralTexture;
  11847. /**
  11848. * Set an array of floats in the shader.
  11849. * @param name Define the name of the uniform as defined in the shader
  11850. * @param value Define the value to give to the uniform
  11851. * @return the texture itself allowing "fluent" like uniform updates
  11852. */
  11853. setFloats(name: string, value: number[]): ProceduralTexture;
  11854. /**
  11855. * Set a vec3 in the shader from a Color3.
  11856. * @param name Define the name of the uniform as defined in the shader
  11857. * @param value Define the value to give to the uniform
  11858. * @return the texture itself allowing "fluent" like uniform updates
  11859. */
  11860. setColor3(name: string, value: Color3): ProceduralTexture;
  11861. /**
  11862. * Set a vec4 in the shader from a Color4.
  11863. * @param name Define the name of the uniform as defined in the shader
  11864. * @param value Define the value to give to the uniform
  11865. * @return the texture itself allowing "fluent" like uniform updates
  11866. */
  11867. setColor4(name: string, value: Color4): ProceduralTexture;
  11868. /**
  11869. * Set a vec2 in the shader from a Vector2.
  11870. * @param name Define the name of the uniform as defined in the shader
  11871. * @param value Define the value to give to the uniform
  11872. * @return the texture itself allowing "fluent" like uniform updates
  11873. */
  11874. setVector2(name: string, value: Vector2): ProceduralTexture;
  11875. /**
  11876. * Set a vec3 in the shader from a Vector3.
  11877. * @param name Define the name of the uniform as defined in the shader
  11878. * @param value Define the value to give to the uniform
  11879. * @return the texture itself allowing "fluent" like uniform updates
  11880. */
  11881. setVector3(name: string, value: Vector3): ProceduralTexture;
  11882. /**
  11883. * Set a mat4 in the shader from a MAtrix.
  11884. * @param name Define the name of the uniform as defined in the shader
  11885. * @param value Define the value to give to the uniform
  11886. * @return the texture itself allowing "fluent" like uniform updates
  11887. */
  11888. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11889. /**
  11890. * Render the texture to its associated render target.
  11891. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11892. */
  11893. render(useCameraPostProcess?: boolean): void;
  11894. /**
  11895. * Clone the texture.
  11896. * @returns the cloned texture
  11897. */
  11898. clone(): ProceduralTexture;
  11899. /**
  11900. * Dispose the texture and release its asoociated resources.
  11901. */
  11902. dispose(): void;
  11903. }
  11904. }
  11905. declare module BABYLON {
  11906. /**
  11907. * This represents the base class for particle system in Babylon.
  11908. * 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.
  11909. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11910. * @example https://doc.babylonjs.com/babylon101/particles
  11911. */
  11912. export class BaseParticleSystem {
  11913. /**
  11914. * Source color is added to the destination color without alpha affecting the result
  11915. */
  11916. static BLENDMODE_ONEONE: number;
  11917. /**
  11918. * Blend current color and particle color using particle’s alpha
  11919. */
  11920. static BLENDMODE_STANDARD: number;
  11921. /**
  11922. * Add current color and particle color multiplied by particle’s alpha
  11923. */
  11924. static BLENDMODE_ADD: number;
  11925. /**
  11926. * Multiply current color with particle color
  11927. */
  11928. static BLENDMODE_MULTIPLY: number;
  11929. /**
  11930. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11931. */
  11932. static BLENDMODE_MULTIPLYADD: number;
  11933. /**
  11934. * List of animations used by the particle system.
  11935. */
  11936. animations: Animation[];
  11937. /**
  11938. * Gets or sets the unique id of the particle system
  11939. */
  11940. uniqueId: number;
  11941. /**
  11942. * The id of the Particle system.
  11943. */
  11944. id: string;
  11945. /**
  11946. * The friendly name of the Particle system.
  11947. */
  11948. name: string;
  11949. /**
  11950. * Snippet ID if the particle system was created from the snippet server
  11951. */
  11952. snippetId: string;
  11953. /**
  11954. * The rendering group used by the Particle system to chose when to render.
  11955. */
  11956. renderingGroupId: number;
  11957. /**
  11958. * The emitter represents the Mesh or position we are attaching the particle system to.
  11959. */
  11960. emitter: Nullable<AbstractMesh | Vector3>;
  11961. /**
  11962. * The maximum number of particles to emit per frame
  11963. */
  11964. emitRate: number;
  11965. /**
  11966. * If you want to launch only a few particles at once, that can be done, as well.
  11967. */
  11968. manualEmitCount: number;
  11969. /**
  11970. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11971. */
  11972. updateSpeed: number;
  11973. /**
  11974. * The amount of time the particle system is running (depends of the overall update speed).
  11975. */
  11976. targetStopDuration: number;
  11977. /**
  11978. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11979. */
  11980. disposeOnStop: boolean;
  11981. /**
  11982. * Minimum power of emitting particles.
  11983. */
  11984. minEmitPower: number;
  11985. /**
  11986. * Maximum power of emitting particles.
  11987. */
  11988. maxEmitPower: number;
  11989. /**
  11990. * Minimum life time of emitting particles.
  11991. */
  11992. minLifeTime: number;
  11993. /**
  11994. * Maximum life time of emitting particles.
  11995. */
  11996. maxLifeTime: number;
  11997. /**
  11998. * Minimum Size of emitting particles.
  11999. */
  12000. minSize: number;
  12001. /**
  12002. * Maximum Size of emitting particles.
  12003. */
  12004. maxSize: number;
  12005. /**
  12006. * Minimum scale of emitting particles on X axis.
  12007. */
  12008. minScaleX: number;
  12009. /**
  12010. * Maximum scale of emitting particles on X axis.
  12011. */
  12012. maxScaleX: number;
  12013. /**
  12014. * Minimum scale of emitting particles on Y axis.
  12015. */
  12016. minScaleY: number;
  12017. /**
  12018. * Maximum scale of emitting particles on Y axis.
  12019. */
  12020. maxScaleY: number;
  12021. /**
  12022. * Gets or sets the minimal initial rotation in radians.
  12023. */
  12024. minInitialRotation: number;
  12025. /**
  12026. * Gets or sets the maximal initial rotation in radians.
  12027. */
  12028. maxInitialRotation: number;
  12029. /**
  12030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12031. */
  12032. minAngularSpeed: number;
  12033. /**
  12034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12035. */
  12036. maxAngularSpeed: number;
  12037. /**
  12038. * The texture used to render each particle. (this can be a spritesheet)
  12039. */
  12040. particleTexture: Nullable<BaseTexture>;
  12041. /**
  12042. * The layer mask we are rendering the particles through.
  12043. */
  12044. layerMask: number;
  12045. /**
  12046. * This can help using your own shader to render the particle system.
  12047. * The according effect will be created
  12048. */
  12049. customShader: any;
  12050. /**
  12051. * By default particle system starts as soon as they are created. This prevents the
  12052. * automatic start to happen and let you decide when to start emitting particles.
  12053. */
  12054. preventAutoStart: boolean;
  12055. private _noiseTexture;
  12056. /**
  12057. * Gets or sets a texture used to add random noise to particle positions
  12058. */
  12059. get noiseTexture(): Nullable<ProceduralTexture>;
  12060. set noiseTexture(value: Nullable<ProceduralTexture>);
  12061. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12062. noiseStrength: Vector3;
  12063. /**
  12064. * Callback triggered when the particle animation is ending.
  12065. */
  12066. onAnimationEnd: Nullable<() => void>;
  12067. /**
  12068. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12069. */
  12070. blendMode: number;
  12071. /**
  12072. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12073. * to override the particles.
  12074. */
  12075. forceDepthWrite: boolean;
  12076. /** 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 */
  12077. preWarmCycles: number;
  12078. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12079. preWarmStepOffset: number;
  12080. /**
  12081. * 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)
  12082. */
  12083. spriteCellChangeSpeed: number;
  12084. /**
  12085. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12086. */
  12087. startSpriteCellID: number;
  12088. /**
  12089. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12090. */
  12091. endSpriteCellID: number;
  12092. /**
  12093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12094. */
  12095. spriteCellWidth: number;
  12096. /**
  12097. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12098. */
  12099. spriteCellHeight: number;
  12100. /**
  12101. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12102. */
  12103. spriteRandomStartCell: boolean;
  12104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12105. translationPivot: Vector2;
  12106. /** @hidden */
  12107. protected _isAnimationSheetEnabled: boolean;
  12108. /**
  12109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12110. */
  12111. beginAnimationOnStart: boolean;
  12112. /**
  12113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12114. */
  12115. beginAnimationFrom: number;
  12116. /**
  12117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12118. */
  12119. beginAnimationTo: number;
  12120. /**
  12121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12122. */
  12123. beginAnimationLoop: boolean;
  12124. /**
  12125. * Gets or sets a world offset applied to all particles
  12126. */
  12127. worldOffset: Vector3;
  12128. /**
  12129. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12130. */
  12131. get isAnimationSheetEnabled(): boolean;
  12132. set isAnimationSheetEnabled(value: boolean);
  12133. /**
  12134. * Get hosting scene
  12135. * @returns the scene
  12136. */
  12137. getScene(): Nullable<Scene>;
  12138. /**
  12139. * You can use gravity if you want to give an orientation to your particles.
  12140. */
  12141. gravity: Vector3;
  12142. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12143. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12144. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12145. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12146. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12147. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12148. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12149. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12150. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12151. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12152. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12153. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12154. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12155. /**
  12156. * Defines the delay in milliseconds before starting the system (0 by default)
  12157. */
  12158. startDelay: number;
  12159. /**
  12160. * Gets the current list of drag gradients.
  12161. * You must use addDragGradient and removeDragGradient to udpate this list
  12162. * @returns the list of drag gradients
  12163. */
  12164. getDragGradients(): Nullable<Array<FactorGradient>>;
  12165. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12166. limitVelocityDamping: number;
  12167. /**
  12168. * Gets the current list of limit velocity gradients.
  12169. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12170. * @returns the list of limit velocity gradients
  12171. */
  12172. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12173. /**
  12174. * Gets the current list of color gradients.
  12175. * You must use addColorGradient and removeColorGradient to udpate this list
  12176. * @returns the list of color gradients
  12177. */
  12178. getColorGradients(): Nullable<Array<ColorGradient>>;
  12179. /**
  12180. * Gets the current list of size gradients.
  12181. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12182. * @returns the list of size gradients
  12183. */
  12184. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12185. /**
  12186. * Gets the current list of color remap gradients.
  12187. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12188. * @returns the list of color remap gradients
  12189. */
  12190. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12191. /**
  12192. * Gets the current list of alpha remap gradients.
  12193. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12194. * @returns the list of alpha remap gradients
  12195. */
  12196. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12197. /**
  12198. * Gets the current list of life time gradients.
  12199. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12200. * @returns the list of life time gradients
  12201. */
  12202. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12203. /**
  12204. * Gets the current list of angular speed gradients.
  12205. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12206. * @returns the list of angular speed gradients
  12207. */
  12208. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12209. /**
  12210. * Gets the current list of velocity gradients.
  12211. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12212. * @returns the list of velocity gradients
  12213. */
  12214. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12215. /**
  12216. * Gets the current list of start size gradients.
  12217. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12218. * @returns the list of start size gradients
  12219. */
  12220. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12221. /**
  12222. * Gets the current list of emit rate gradients.
  12223. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12224. * @returns the list of emit rate gradients
  12225. */
  12226. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12227. /**
  12228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12230. */
  12231. get direction1(): Vector3;
  12232. set direction1(value: Vector3);
  12233. /**
  12234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12236. */
  12237. get direction2(): Vector3;
  12238. set direction2(value: Vector3);
  12239. /**
  12240. * 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.
  12241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12242. */
  12243. get minEmitBox(): Vector3;
  12244. set minEmitBox(value: Vector3);
  12245. /**
  12246. * 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.
  12247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12248. */
  12249. get maxEmitBox(): Vector3;
  12250. set maxEmitBox(value: Vector3);
  12251. /**
  12252. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12253. */
  12254. color1: Color4;
  12255. /**
  12256. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12257. */
  12258. color2: Color4;
  12259. /**
  12260. * Color the particle will have at the end of its lifetime
  12261. */
  12262. colorDead: Color4;
  12263. /**
  12264. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12265. */
  12266. textureMask: Color4;
  12267. /**
  12268. * The particle emitter type defines the emitter used by the particle system.
  12269. * It can be for example box, sphere, or cone...
  12270. */
  12271. particleEmitterType: IParticleEmitterType;
  12272. /** @hidden */
  12273. _isSubEmitter: boolean;
  12274. /**
  12275. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12276. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12277. */
  12278. billboardMode: number;
  12279. protected _isBillboardBased: boolean;
  12280. /**
  12281. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12282. */
  12283. get isBillboardBased(): boolean;
  12284. set isBillboardBased(value: boolean);
  12285. /**
  12286. * The scene the particle system belongs to.
  12287. */
  12288. protected _scene: Nullable<Scene>;
  12289. /**
  12290. * The engine the particle system belongs to.
  12291. */
  12292. protected _engine: ThinEngine;
  12293. /**
  12294. * Local cache of defines for image processing.
  12295. */
  12296. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12297. /**
  12298. * Default configuration related to image processing available in the standard Material.
  12299. */
  12300. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12301. /**
  12302. * Gets the image processing configuration used either in this material.
  12303. */
  12304. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12305. /**
  12306. * Sets the Default image processing configuration used either in the this material.
  12307. *
  12308. * If sets to null, the scene one is in use.
  12309. */
  12310. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12311. /**
  12312. * Attaches a new image processing configuration to the Standard Material.
  12313. * @param configuration
  12314. */
  12315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12316. /** @hidden */
  12317. protected _reset(): void;
  12318. /** @hidden */
  12319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12320. /**
  12321. * Instantiates a particle system.
  12322. * 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.
  12323. * @param name The name of the particle system
  12324. */
  12325. constructor(name: string);
  12326. /**
  12327. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12330. * @returns the emitter
  12331. */
  12332. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12333. /**
  12334. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12335. * @param radius The radius of the hemisphere to emit from
  12336. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12337. * @returns the emitter
  12338. */
  12339. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12340. /**
  12341. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12342. * @param radius The radius of the sphere to emit from
  12343. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12344. * @returns the emitter
  12345. */
  12346. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12347. /**
  12348. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12349. * @param radius The radius of the sphere to emit from
  12350. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12351. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12352. * @returns the emitter
  12353. */
  12354. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12355. /**
  12356. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12357. * @param radius The radius of the emission cylinder
  12358. * @param height The height of the emission cylinder
  12359. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12360. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12361. * @returns the emitter
  12362. */
  12363. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12364. /**
  12365. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12366. * @param radius The radius of the cylinder to emit from
  12367. * @param height The height of the emission cylinder
  12368. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12371. * @returns the emitter
  12372. */
  12373. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12374. /**
  12375. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12376. * @param radius The radius of the cone to emit from
  12377. * @param angle The base angle of the cone
  12378. * @returns the emitter
  12379. */
  12380. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12381. /**
  12382. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12385. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12386. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12387. * @returns the emitter
  12388. */
  12389. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12390. }
  12391. }
  12392. declare module BABYLON {
  12393. /**
  12394. * Type of sub emitter
  12395. */
  12396. export enum SubEmitterType {
  12397. /**
  12398. * Attached to the particle over it's lifetime
  12399. */
  12400. ATTACHED = 0,
  12401. /**
  12402. * Created when the particle dies
  12403. */
  12404. END = 1
  12405. }
  12406. /**
  12407. * Sub emitter class used to emit particles from an existing particle
  12408. */
  12409. export class SubEmitter {
  12410. /**
  12411. * the particle system to be used by the sub emitter
  12412. */
  12413. particleSystem: ParticleSystem;
  12414. /**
  12415. * Type of the submitter (Default: END)
  12416. */
  12417. type: SubEmitterType;
  12418. /**
  12419. * 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)
  12420. * Note: This only is supported when using an emitter of type Mesh
  12421. */
  12422. inheritDirection: boolean;
  12423. /**
  12424. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12425. */
  12426. inheritedVelocityAmount: number;
  12427. /**
  12428. * Creates a sub emitter
  12429. * @param particleSystem the particle system to be used by the sub emitter
  12430. */
  12431. constructor(
  12432. /**
  12433. * the particle system to be used by the sub emitter
  12434. */
  12435. particleSystem: ParticleSystem);
  12436. /**
  12437. * Clones the sub emitter
  12438. * @returns the cloned sub emitter
  12439. */
  12440. clone(): SubEmitter;
  12441. /**
  12442. * Serialize current object to a JSON object
  12443. * @returns the serialized object
  12444. */
  12445. serialize(): any;
  12446. /** @hidden */
  12447. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12448. /**
  12449. * Creates a new SubEmitter from a serialized JSON version
  12450. * @param serializationObject defines the JSON object to read from
  12451. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12452. * @param rootUrl defines the rootUrl for data loading
  12453. * @returns a new SubEmitter
  12454. */
  12455. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12456. /** Release associated resources */
  12457. dispose(): void;
  12458. }
  12459. }
  12460. declare module BABYLON {
  12461. /** @hidden */
  12462. export var imageProcessingDeclaration: {
  12463. name: string;
  12464. shader: string;
  12465. };
  12466. }
  12467. declare module BABYLON {
  12468. /** @hidden */
  12469. export var imageProcessingFunctions: {
  12470. name: string;
  12471. shader: string;
  12472. };
  12473. }
  12474. declare module BABYLON {
  12475. /** @hidden */
  12476. export var particlesPixelShader: {
  12477. name: string;
  12478. shader: string;
  12479. };
  12480. }
  12481. declare module BABYLON {
  12482. /** @hidden */
  12483. export var particlesVertexShader: {
  12484. name: string;
  12485. shader: string;
  12486. };
  12487. }
  12488. declare module BABYLON {
  12489. /**
  12490. * Interface used to define entities containing multiple clip planes
  12491. */
  12492. export interface IClipPlanesHolder {
  12493. /**
  12494. * Gets or sets the active clipplane 1
  12495. */
  12496. clipPlane: Nullable<Plane>;
  12497. /**
  12498. * Gets or sets the active clipplane 2
  12499. */
  12500. clipPlane2: Nullable<Plane>;
  12501. /**
  12502. * Gets or sets the active clipplane 3
  12503. */
  12504. clipPlane3: Nullable<Plane>;
  12505. /**
  12506. * Gets or sets the active clipplane 4
  12507. */
  12508. clipPlane4: Nullable<Plane>;
  12509. /**
  12510. * Gets or sets the active clipplane 5
  12511. */
  12512. clipPlane5: Nullable<Plane>;
  12513. /**
  12514. * Gets or sets the active clipplane 6
  12515. */
  12516. clipPlane6: Nullable<Plane>;
  12517. }
  12518. }
  12519. declare module BABYLON {
  12520. /**
  12521. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12522. *
  12523. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12524. *
  12525. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12526. */
  12527. export class ThinMaterialHelper {
  12528. /**
  12529. * Binds the clip plane information from the holder to the effect.
  12530. * @param effect The effect we are binding the data to
  12531. * @param holder The entity containing the clip plane information
  12532. */
  12533. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12534. }
  12535. }
  12536. declare module BABYLON {
  12537. interface ThinEngine {
  12538. /**
  12539. * Sets alpha constants used by some alpha blending modes
  12540. * @param r defines the red component
  12541. * @param g defines the green component
  12542. * @param b defines the blue component
  12543. * @param a defines the alpha component
  12544. */
  12545. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12546. /**
  12547. * Sets the current alpha mode
  12548. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12550. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12551. */
  12552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12553. /**
  12554. * Gets the current alpha mode
  12555. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12556. * @returns the current alpha mode
  12557. */
  12558. getAlphaMode(): number;
  12559. /**
  12560. * Sets the current alpha equation
  12561. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12562. */
  12563. setAlphaEquation(equation: number): void;
  12564. /**
  12565. * Gets the current alpha equation.
  12566. * @returns the current alpha equation
  12567. */
  12568. getAlphaEquation(): number;
  12569. }
  12570. }
  12571. declare module BABYLON {
  12572. /**
  12573. * This represents a particle system in Babylon.
  12574. * 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.
  12575. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12576. * @example https://doc.babylonjs.com/babylon101/particles
  12577. */
  12578. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12579. /**
  12580. * Billboard mode will only apply to Y axis
  12581. */
  12582. static readonly BILLBOARDMODE_Y: number;
  12583. /**
  12584. * Billboard mode will apply to all axes
  12585. */
  12586. static readonly BILLBOARDMODE_ALL: number;
  12587. /**
  12588. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12589. */
  12590. static readonly BILLBOARDMODE_STRETCHED: number;
  12591. /**
  12592. * This function can be defined to provide custom update for active particles.
  12593. * This function will be called instead of regular update (age, position, color, etc.).
  12594. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12595. */
  12596. updateFunction: (particles: Particle[]) => void;
  12597. private _emitterWorldMatrix;
  12598. /**
  12599. * This function can be defined to specify initial direction for every new particle.
  12600. * It by default use the emitterType defined function
  12601. */
  12602. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12603. /**
  12604. * This function can be defined to specify initial position for every new particle.
  12605. * It by default use the emitterType defined function
  12606. */
  12607. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12608. /**
  12609. * @hidden
  12610. */
  12611. _inheritedVelocityOffset: Vector3;
  12612. /**
  12613. * An event triggered when the system is disposed
  12614. */
  12615. onDisposeObservable: Observable<IParticleSystem>;
  12616. private _onDisposeObserver;
  12617. /**
  12618. * Sets a callback that will be triggered when the system is disposed
  12619. */
  12620. set onDispose(callback: () => void);
  12621. private _particles;
  12622. private _epsilon;
  12623. private _capacity;
  12624. private _stockParticles;
  12625. private _newPartsExcess;
  12626. private _vertexData;
  12627. private _vertexBuffer;
  12628. private _vertexBuffers;
  12629. private _spriteBuffer;
  12630. private _indexBuffer;
  12631. private _effect;
  12632. private _customEffect;
  12633. private _cachedDefines;
  12634. private _scaledColorStep;
  12635. private _colorDiff;
  12636. private _scaledDirection;
  12637. private _scaledGravity;
  12638. private _currentRenderId;
  12639. private _alive;
  12640. private _useInstancing;
  12641. private _started;
  12642. private _stopped;
  12643. private _actualFrame;
  12644. private _scaledUpdateSpeed;
  12645. private _vertexBufferSize;
  12646. /** @hidden */
  12647. _currentEmitRateGradient: Nullable<FactorGradient>;
  12648. /** @hidden */
  12649. _currentEmitRate1: number;
  12650. /** @hidden */
  12651. _currentEmitRate2: number;
  12652. /** @hidden */
  12653. _currentStartSizeGradient: Nullable<FactorGradient>;
  12654. /** @hidden */
  12655. _currentStartSize1: number;
  12656. /** @hidden */
  12657. _currentStartSize2: number;
  12658. private readonly _rawTextureWidth;
  12659. private _rampGradientsTexture;
  12660. private _useRampGradients;
  12661. /** Gets or sets a matrix to use to compute projection */
  12662. defaultProjectionMatrix: Matrix;
  12663. /** Gets or sets a matrix to use to compute view */
  12664. defaultViewMatrix: Matrix;
  12665. /** Gets or sets a boolean indicating that ramp gradients must be used
  12666. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12667. */
  12668. get useRampGradients(): boolean;
  12669. set useRampGradients(value: boolean);
  12670. /**
  12671. * 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.
  12672. * 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: [])
  12673. */
  12674. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12675. private _subEmitters;
  12676. /**
  12677. * @hidden
  12678. * If the particle systems emitter should be disposed when the particle system is disposed
  12679. */
  12680. _disposeEmitterOnDispose: boolean;
  12681. /**
  12682. * The current active Sub-systems, this property is used by the root particle system only.
  12683. */
  12684. activeSubSystems: Array<ParticleSystem>;
  12685. /**
  12686. * Specifies if the particles are updated in emitter local space or world space
  12687. */
  12688. isLocal: boolean;
  12689. private _rootParticleSystem;
  12690. /**
  12691. * Gets the current list of active particles
  12692. */
  12693. get particles(): Particle[];
  12694. /**
  12695. * Gets the number of particles active at the same time.
  12696. * @returns The number of active particles.
  12697. */
  12698. getActiveCount(): number;
  12699. /**
  12700. * Returns the string "ParticleSystem"
  12701. * @returns a string containing the class name
  12702. */
  12703. getClassName(): string;
  12704. /**
  12705. * Gets a boolean indicating that the system is stopping
  12706. * @returns true if the system is currently stopping
  12707. */
  12708. isStopping(): boolean;
  12709. /**
  12710. * Gets the custom effect used to render the particles
  12711. * @param blendMode Blend mode for which the effect should be retrieved
  12712. * @returns The effect
  12713. */
  12714. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12715. /**
  12716. * Sets the custom effect used to render the particles
  12717. * @param effect The effect to set
  12718. * @param blendMode Blend mode for which the effect should be set
  12719. */
  12720. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12721. /** @hidden */
  12722. private _onBeforeDrawParticlesObservable;
  12723. /**
  12724. * Observable that will be called just before the particles are drawn
  12725. */
  12726. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12727. /**
  12728. * Gets the name of the particle vertex shader
  12729. */
  12730. get vertexShaderName(): string;
  12731. /**
  12732. * Instantiates a particle system.
  12733. * 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.
  12734. * @param name The name of the particle system
  12735. * @param capacity The max number of particles alive at the same time
  12736. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12737. * @param customEffect a custom effect used to change the way particles are rendered by default
  12738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12739. * @param epsilon Offset used to render the particles
  12740. */
  12741. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12742. private _addFactorGradient;
  12743. private _removeFactorGradient;
  12744. /**
  12745. * Adds a new life time gradient
  12746. * @param gradient defines the gradient to use (between 0 and 1)
  12747. * @param factor defines the life time factor to affect to the specified gradient
  12748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12749. * @returns the current particle system
  12750. */
  12751. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12752. /**
  12753. * Remove a specific life time gradient
  12754. * @param gradient defines the gradient to remove
  12755. * @returns the current particle system
  12756. */
  12757. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12758. /**
  12759. * Adds a new size gradient
  12760. * @param gradient defines the gradient to use (between 0 and 1)
  12761. * @param factor defines the size factor to affect to the specified gradient
  12762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12763. * @returns the current particle system
  12764. */
  12765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12766. /**
  12767. * Remove a specific size gradient
  12768. * @param gradient defines the gradient to remove
  12769. * @returns the current particle system
  12770. */
  12771. removeSizeGradient(gradient: number): IParticleSystem;
  12772. /**
  12773. * Adds a new color remap gradient
  12774. * @param gradient defines the gradient to use (between 0 and 1)
  12775. * @param min defines the color remap minimal range
  12776. * @param max defines the color remap maximal range
  12777. * @returns the current particle system
  12778. */
  12779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12780. /**
  12781. * Remove a specific color remap gradient
  12782. * @param gradient defines the gradient to remove
  12783. * @returns the current particle system
  12784. */
  12785. removeColorRemapGradient(gradient: number): IParticleSystem;
  12786. /**
  12787. * Adds a new alpha remap gradient
  12788. * @param gradient defines the gradient to use (between 0 and 1)
  12789. * @param min defines the alpha remap minimal range
  12790. * @param max defines the alpha remap maximal range
  12791. * @returns the current particle system
  12792. */
  12793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12794. /**
  12795. * Remove a specific alpha remap gradient
  12796. * @param gradient defines the gradient to remove
  12797. * @returns the current particle system
  12798. */
  12799. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12800. /**
  12801. * Adds a new angular speed gradient
  12802. * @param gradient defines the gradient to use (between 0 and 1)
  12803. * @param factor defines the angular speed to affect to the specified gradient
  12804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12805. * @returns the current particle system
  12806. */
  12807. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12808. /**
  12809. * Remove a specific angular speed gradient
  12810. * @param gradient defines the gradient to remove
  12811. * @returns the current particle system
  12812. */
  12813. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12814. /**
  12815. * Adds a new velocity gradient
  12816. * @param gradient defines the gradient to use (between 0 and 1)
  12817. * @param factor defines the velocity to affect to the specified gradient
  12818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12819. * @returns the current particle system
  12820. */
  12821. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12822. /**
  12823. * Remove a specific velocity gradient
  12824. * @param gradient defines the gradient to remove
  12825. * @returns the current particle system
  12826. */
  12827. removeVelocityGradient(gradient: number): IParticleSystem;
  12828. /**
  12829. * Adds a new limit velocity gradient
  12830. * @param gradient defines the gradient to use (between 0 and 1)
  12831. * @param factor defines the limit velocity value to affect to the specified gradient
  12832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12833. * @returns the current particle system
  12834. */
  12835. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12836. /**
  12837. * Remove a specific limit velocity gradient
  12838. * @param gradient defines the gradient to remove
  12839. * @returns the current particle system
  12840. */
  12841. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12842. /**
  12843. * Adds a new drag gradient
  12844. * @param gradient defines the gradient to use (between 0 and 1)
  12845. * @param factor defines the drag value to affect to the specified gradient
  12846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12847. * @returns the current particle system
  12848. */
  12849. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12850. /**
  12851. * Remove a specific drag gradient
  12852. * @param gradient defines the gradient to remove
  12853. * @returns the current particle system
  12854. */
  12855. removeDragGradient(gradient: number): IParticleSystem;
  12856. /**
  12857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12858. * @param gradient defines the gradient to use (between 0 and 1)
  12859. * @param factor defines the emit rate value to affect to the specified gradient
  12860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12861. * @returns the current particle system
  12862. */
  12863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12864. /**
  12865. * Remove a specific emit rate gradient
  12866. * @param gradient defines the gradient to remove
  12867. * @returns the current particle system
  12868. */
  12869. removeEmitRateGradient(gradient: number): IParticleSystem;
  12870. /**
  12871. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12872. * @param gradient defines the gradient to use (between 0 and 1)
  12873. * @param factor defines the start size value to affect to the specified gradient
  12874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12875. * @returns the current particle system
  12876. */
  12877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12878. /**
  12879. * Remove a specific start size gradient
  12880. * @param gradient defines the gradient to remove
  12881. * @returns the current particle system
  12882. */
  12883. removeStartSizeGradient(gradient: number): IParticleSystem;
  12884. private _createRampGradientTexture;
  12885. /**
  12886. * Gets the current list of ramp gradients.
  12887. * You must use addRampGradient and removeRampGradient to udpate this list
  12888. * @returns the list of ramp gradients
  12889. */
  12890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12891. /** Force the system to rebuild all gradients that need to be resync */
  12892. forceRefreshGradients(): void;
  12893. private _syncRampGradientTexture;
  12894. /**
  12895. * Adds a new ramp gradient used to remap particle colors
  12896. * @param gradient defines the gradient to use (between 0 and 1)
  12897. * @param color defines the color to affect to the specified gradient
  12898. * @returns the current particle system
  12899. */
  12900. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12901. /**
  12902. * Remove a specific ramp gradient
  12903. * @param gradient defines the gradient to remove
  12904. * @returns the current particle system
  12905. */
  12906. removeRampGradient(gradient: number): ParticleSystem;
  12907. /**
  12908. * Adds a new color gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param color1 defines the color to affect to the specified gradient
  12911. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12912. * @returns this particle system
  12913. */
  12914. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12915. /**
  12916. * Remove a specific color gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns this particle system
  12919. */
  12920. removeColorGradient(gradient: number): IParticleSystem;
  12921. private _fetchR;
  12922. protected _reset(): void;
  12923. private _resetEffect;
  12924. private _createVertexBuffers;
  12925. private _createIndexBuffer;
  12926. /**
  12927. * Gets the maximum number of particles active at the same time.
  12928. * @returns The max number of active particles.
  12929. */
  12930. getCapacity(): number;
  12931. /**
  12932. * Gets whether there are still active particles in the system.
  12933. * @returns True if it is alive, otherwise false.
  12934. */
  12935. isAlive(): boolean;
  12936. /**
  12937. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12938. * @returns True if it has been started, otherwise false.
  12939. */
  12940. isStarted(): boolean;
  12941. private _prepareSubEmitterInternalArray;
  12942. /**
  12943. * Starts the particle system and begins to emit
  12944. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12945. */
  12946. start(delay?: number): void;
  12947. /**
  12948. * Stops the particle system.
  12949. * @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.
  12950. */
  12951. stop(stopSubEmitters?: boolean): void;
  12952. /**
  12953. * Remove all active particles
  12954. */
  12955. reset(): void;
  12956. /**
  12957. * @hidden (for internal use only)
  12958. */
  12959. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12960. /**
  12961. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12962. * Its lifetime will start back at 0.
  12963. */
  12964. recycleParticle: (particle: Particle) => void;
  12965. private _stopSubEmitters;
  12966. private _createParticle;
  12967. private _removeFromRoot;
  12968. private _emitFromParticle;
  12969. private _update;
  12970. /** @hidden */
  12971. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12972. /** @hidden */
  12973. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12974. /**
  12975. * Fill the defines array according to the current settings of the particle system
  12976. * @param defines Array to be updated
  12977. * @param blendMode blend mode to take into account when updating the array
  12978. */
  12979. fillDefines(defines: Array<string>, blendMode: number): void;
  12980. /**
  12981. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12982. * @param uniforms Uniforms array to fill
  12983. * @param attributes Attributes array to fill
  12984. * @param samplers Samplers array to fill
  12985. */
  12986. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12987. /** @hidden */
  12988. private _getEffect;
  12989. /**
  12990. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12991. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12992. */
  12993. animate(preWarmOnly?: boolean): void;
  12994. private _appendParticleVertices;
  12995. /**
  12996. * Rebuilds the particle system.
  12997. */
  12998. rebuild(): void;
  12999. /**
  13000. * Is this system ready to be used/rendered
  13001. * @return true if the system is ready
  13002. */
  13003. isReady(): boolean;
  13004. private _render;
  13005. /**
  13006. * Renders the particle system in its current state.
  13007. * @returns the current number of particles
  13008. */
  13009. render(): number;
  13010. /**
  13011. * Disposes the particle system and free the associated resources
  13012. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13013. */
  13014. dispose(disposeTexture?: boolean): void;
  13015. /**
  13016. * Clones the particle system.
  13017. * @param name The name of the cloned object
  13018. * @param newEmitter The new emitter to use
  13019. * @returns the cloned particle system
  13020. */
  13021. clone(name: string, newEmitter: any): ParticleSystem;
  13022. /**
  13023. * Serializes the particle system to a JSON object
  13024. * @param serializeTexture defines if the texture must be serialized as well
  13025. * @returns the JSON object
  13026. */
  13027. serialize(serializeTexture?: boolean): any;
  13028. /** @hidden */
  13029. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13030. /** @hidden */
  13031. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13032. /**
  13033. * Parses a JSON object to create a particle system.
  13034. * @param parsedParticleSystem The JSON object to parse
  13035. * @param sceneOrEngine The scene or the engine to create the particle system in
  13036. * @param rootUrl The root url to use to load external dependencies like texture
  13037. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13038. * @returns the Parsed particle system
  13039. */
  13040. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13041. }
  13042. }
  13043. declare module BABYLON {
  13044. /**
  13045. * A particle represents one of the element emitted by a particle system.
  13046. * This is mainly define by its coordinates, direction, velocity and age.
  13047. */
  13048. export class Particle {
  13049. /**
  13050. * The particle system the particle belongs to.
  13051. */
  13052. particleSystem: ParticleSystem;
  13053. private static _Count;
  13054. /**
  13055. * Unique ID of the particle
  13056. */
  13057. id: number;
  13058. /**
  13059. * The world position of the particle in the scene.
  13060. */
  13061. position: Vector3;
  13062. /**
  13063. * The world direction of the particle in the scene.
  13064. */
  13065. direction: Vector3;
  13066. /**
  13067. * The color of the particle.
  13068. */
  13069. color: Color4;
  13070. /**
  13071. * The color change of the particle per step.
  13072. */
  13073. colorStep: Color4;
  13074. /**
  13075. * Defines how long will the life of the particle be.
  13076. */
  13077. lifeTime: number;
  13078. /**
  13079. * The current age of the particle.
  13080. */
  13081. age: number;
  13082. /**
  13083. * The current size of the particle.
  13084. */
  13085. size: number;
  13086. /**
  13087. * The current scale of the particle.
  13088. */
  13089. scale: Vector2;
  13090. /**
  13091. * The current angle of the particle.
  13092. */
  13093. angle: number;
  13094. /**
  13095. * Defines how fast is the angle changing.
  13096. */
  13097. angularSpeed: number;
  13098. /**
  13099. * Defines the cell index used by the particle to be rendered from a sprite.
  13100. */
  13101. cellIndex: number;
  13102. /**
  13103. * The information required to support color remapping
  13104. */
  13105. remapData: Vector4;
  13106. /** @hidden */
  13107. _randomCellOffset?: number;
  13108. /** @hidden */
  13109. _initialDirection: Nullable<Vector3>;
  13110. /** @hidden */
  13111. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13112. /** @hidden */
  13113. _initialStartSpriteCellID: number;
  13114. /** @hidden */
  13115. _initialEndSpriteCellID: number;
  13116. /** @hidden */
  13117. _currentColorGradient: Nullable<ColorGradient>;
  13118. /** @hidden */
  13119. _currentColor1: Color4;
  13120. /** @hidden */
  13121. _currentColor2: Color4;
  13122. /** @hidden */
  13123. _currentSizeGradient: Nullable<FactorGradient>;
  13124. /** @hidden */
  13125. _currentSize1: number;
  13126. /** @hidden */
  13127. _currentSize2: number;
  13128. /** @hidden */
  13129. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13130. /** @hidden */
  13131. _currentAngularSpeed1: number;
  13132. /** @hidden */
  13133. _currentAngularSpeed2: number;
  13134. /** @hidden */
  13135. _currentVelocityGradient: Nullable<FactorGradient>;
  13136. /** @hidden */
  13137. _currentVelocity1: number;
  13138. /** @hidden */
  13139. _currentVelocity2: number;
  13140. /** @hidden */
  13141. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13142. /** @hidden */
  13143. _currentLimitVelocity1: number;
  13144. /** @hidden */
  13145. _currentLimitVelocity2: number;
  13146. /** @hidden */
  13147. _currentDragGradient: Nullable<FactorGradient>;
  13148. /** @hidden */
  13149. _currentDrag1: number;
  13150. /** @hidden */
  13151. _currentDrag2: number;
  13152. /** @hidden */
  13153. _randomNoiseCoordinates1: Vector3;
  13154. /** @hidden */
  13155. _randomNoiseCoordinates2: Vector3;
  13156. /** @hidden */
  13157. _localPosition?: Vector3;
  13158. /**
  13159. * Creates a new instance Particle
  13160. * @param particleSystem the particle system the particle belongs to
  13161. */
  13162. constructor(
  13163. /**
  13164. * The particle system the particle belongs to.
  13165. */
  13166. particleSystem: ParticleSystem);
  13167. private updateCellInfoFromSystem;
  13168. /**
  13169. * Defines how the sprite cell index is updated for the particle
  13170. */
  13171. updateCellIndex(): void;
  13172. /** @hidden */
  13173. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13174. /** @hidden */
  13175. _inheritParticleInfoToSubEmitters(): void;
  13176. /** @hidden */
  13177. _reset(): void;
  13178. /**
  13179. * Copy the properties of particle to another one.
  13180. * @param other the particle to copy the information to.
  13181. */
  13182. copyTo(other: Particle): void;
  13183. }
  13184. }
  13185. declare module BABYLON {
  13186. /**
  13187. * Particle emitter represents a volume emitting particles.
  13188. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13189. */
  13190. export interface IParticleEmitterType {
  13191. /**
  13192. * Called by the particle System when the direction is computed for the created particle.
  13193. * @param worldMatrix is the world matrix of the particle system
  13194. * @param directionToUpdate is the direction vector to update with the result
  13195. * @param particle is the particle we are computed the direction for
  13196. * @param isLocal defines if the direction should be set in local space
  13197. */
  13198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13199. /**
  13200. * Called by the particle System when the position is computed for the created particle.
  13201. * @param worldMatrix is the world matrix of the particle system
  13202. * @param positionToUpdate is the position vector to update with the result
  13203. * @param particle is the particle we are computed the position for
  13204. * @param isLocal defines if the position should be set in local space
  13205. */
  13206. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13207. /**
  13208. * Clones the current emitter and returns a copy of it
  13209. * @returns the new emitter
  13210. */
  13211. clone(): IParticleEmitterType;
  13212. /**
  13213. * Called by the GPUParticleSystem to setup the update shader
  13214. * @param effect defines the update shader
  13215. */
  13216. applyToShader(effect: Effect): void;
  13217. /**
  13218. * Returns a string to use to update the GPU particles update shader
  13219. * @returns the effect defines string
  13220. */
  13221. getEffectDefines(): string;
  13222. /**
  13223. * Returns a string representing the class name
  13224. * @returns a string containing the class name
  13225. */
  13226. getClassName(): string;
  13227. /**
  13228. * Serializes the particle system to a JSON object.
  13229. * @returns the JSON object
  13230. */
  13231. serialize(): any;
  13232. /**
  13233. * Parse properties from a JSON object
  13234. * @param serializationObject defines the JSON object
  13235. * @param scene defines the hosting scene
  13236. */
  13237. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13238. }
  13239. }
  13240. declare module BABYLON {
  13241. /**
  13242. * Particle emitter emitting particles from the inside of a box.
  13243. * It emits the particles randomly between 2 given directions.
  13244. */
  13245. export class BoxParticleEmitter implements IParticleEmitterType {
  13246. /**
  13247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13248. */
  13249. direction1: Vector3;
  13250. /**
  13251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13252. */
  13253. direction2: Vector3;
  13254. /**
  13255. * 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.
  13256. */
  13257. minEmitBox: Vector3;
  13258. /**
  13259. * 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.
  13260. */
  13261. maxEmitBox: Vector3;
  13262. /**
  13263. * Creates a new instance BoxParticleEmitter
  13264. */
  13265. constructor();
  13266. /**
  13267. * Called by the particle System when the direction is computed for the created particle.
  13268. * @param worldMatrix is the world matrix of the particle system
  13269. * @param directionToUpdate is the direction vector to update with the result
  13270. * @param particle is the particle we are computed the direction for
  13271. * @param isLocal defines if the direction should be set in local space
  13272. */
  13273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13274. /**
  13275. * Called by the particle System when the position is computed for the created particle.
  13276. * @param worldMatrix is the world matrix of the particle system
  13277. * @param positionToUpdate is the position vector to update with the result
  13278. * @param particle is the particle we are computed the position for
  13279. * @param isLocal defines if the position should be set in local space
  13280. */
  13281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13282. /**
  13283. * Clones the current emitter and returns a copy of it
  13284. * @returns the new emitter
  13285. */
  13286. clone(): BoxParticleEmitter;
  13287. /**
  13288. * Called by the GPUParticleSystem to setup the update shader
  13289. * @param effect defines the update shader
  13290. */
  13291. applyToShader(effect: Effect): void;
  13292. /**
  13293. * Returns a string to use to update the GPU particles update shader
  13294. * @returns a string containng the defines string
  13295. */
  13296. getEffectDefines(): string;
  13297. /**
  13298. * Returns the string "BoxParticleEmitter"
  13299. * @returns a string containing the class name
  13300. */
  13301. getClassName(): string;
  13302. /**
  13303. * Serializes the particle system to a JSON object.
  13304. * @returns the JSON object
  13305. */
  13306. serialize(): any;
  13307. /**
  13308. * Parse properties from a JSON object
  13309. * @param serializationObject defines the JSON object
  13310. */
  13311. parse(serializationObject: any): void;
  13312. }
  13313. }
  13314. declare module BABYLON {
  13315. /**
  13316. * Particle emitter emitting particles from the inside of a cone.
  13317. * It emits the particles alongside the cone volume from the base to the particle.
  13318. * The emission direction might be randomized.
  13319. */
  13320. export class ConeParticleEmitter implements IParticleEmitterType {
  13321. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13322. directionRandomizer: number;
  13323. private _radius;
  13324. private _angle;
  13325. private _height;
  13326. /**
  13327. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13328. */
  13329. radiusRange: number;
  13330. /**
  13331. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13332. */
  13333. heightRange: number;
  13334. /**
  13335. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13336. */
  13337. emitFromSpawnPointOnly: boolean;
  13338. /**
  13339. * Gets or sets the radius of the emission cone
  13340. */
  13341. get radius(): number;
  13342. set radius(value: number);
  13343. /**
  13344. * Gets or sets the angle of the emission cone
  13345. */
  13346. get angle(): number;
  13347. set angle(value: number);
  13348. private _buildHeight;
  13349. /**
  13350. * Creates a new instance ConeParticleEmitter
  13351. * @param radius the radius of the emission cone (1 by default)
  13352. * @param angle the cone base angle (PI by default)
  13353. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13354. */
  13355. constructor(radius?: number, angle?: number,
  13356. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13357. directionRandomizer?: number);
  13358. /**
  13359. * Called by the particle System when the direction is computed for the created particle.
  13360. * @param worldMatrix is the world matrix of the particle system
  13361. * @param directionToUpdate is the direction vector to update with the result
  13362. * @param particle is the particle we are computed the direction for
  13363. * @param isLocal defines if the direction should be set in local space
  13364. */
  13365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13366. /**
  13367. * Called by the particle System when the position is computed for the created particle.
  13368. * @param worldMatrix is the world matrix of the particle system
  13369. * @param positionToUpdate is the position vector to update with the result
  13370. * @param particle is the particle we are computed the position for
  13371. * @param isLocal defines if the position should be set in local space
  13372. */
  13373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13374. /**
  13375. * Clones the current emitter and returns a copy of it
  13376. * @returns the new emitter
  13377. */
  13378. clone(): ConeParticleEmitter;
  13379. /**
  13380. * Called by the GPUParticleSystem to setup the update shader
  13381. * @param effect defines the update shader
  13382. */
  13383. applyToShader(effect: Effect): void;
  13384. /**
  13385. * Returns a string to use to update the GPU particles update shader
  13386. * @returns a string containng the defines string
  13387. */
  13388. getEffectDefines(): string;
  13389. /**
  13390. * Returns the string "ConeParticleEmitter"
  13391. * @returns a string containing the class name
  13392. */
  13393. getClassName(): string;
  13394. /**
  13395. * Serializes the particle system to a JSON object.
  13396. * @returns the JSON object
  13397. */
  13398. serialize(): any;
  13399. /**
  13400. * Parse properties from a JSON object
  13401. * @param serializationObject defines the JSON object
  13402. */
  13403. parse(serializationObject: any): void;
  13404. }
  13405. }
  13406. declare module BABYLON {
  13407. /**
  13408. * Particle emitter emitting particles from the inside of a cylinder.
  13409. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13410. */
  13411. export class CylinderParticleEmitter implements IParticleEmitterType {
  13412. /**
  13413. * The radius of the emission cylinder.
  13414. */
  13415. radius: number;
  13416. /**
  13417. * The height of the emission cylinder.
  13418. */
  13419. height: number;
  13420. /**
  13421. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13422. */
  13423. radiusRange: number;
  13424. /**
  13425. * How much to randomize the particle direction [0-1].
  13426. */
  13427. directionRandomizer: number;
  13428. /**
  13429. * Creates a new instance CylinderParticleEmitter
  13430. * @param radius the radius of the emission cylinder (1 by default)
  13431. * @param height the height of the emission cylinder (1 by default)
  13432. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13433. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13434. */
  13435. constructor(
  13436. /**
  13437. * The radius of the emission cylinder.
  13438. */
  13439. radius?: number,
  13440. /**
  13441. * The height of the emission cylinder.
  13442. */
  13443. height?: number,
  13444. /**
  13445. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13446. */
  13447. radiusRange?: number,
  13448. /**
  13449. * How much to randomize the particle direction [0-1].
  13450. */
  13451. directionRandomizer?: number);
  13452. /**
  13453. * Called by the particle System when the direction is computed for the created particle.
  13454. * @param worldMatrix is the world matrix of the particle system
  13455. * @param directionToUpdate is the direction vector to update with the result
  13456. * @param particle is the particle we are computed the direction for
  13457. * @param isLocal defines if the direction should be set in local space
  13458. */
  13459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13460. /**
  13461. * Called by the particle System when the position is computed for the created particle.
  13462. * @param worldMatrix is the world matrix of the particle system
  13463. * @param positionToUpdate is the position vector to update with the result
  13464. * @param particle is the particle we are computed the position for
  13465. * @param isLocal defines if the position should be set in local space
  13466. */
  13467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13468. /**
  13469. * Clones the current emitter and returns a copy of it
  13470. * @returns the new emitter
  13471. */
  13472. clone(): CylinderParticleEmitter;
  13473. /**
  13474. * Called by the GPUParticleSystem to setup the update shader
  13475. * @param effect defines the update shader
  13476. */
  13477. applyToShader(effect: Effect): void;
  13478. /**
  13479. * Returns a string to use to update the GPU particles update shader
  13480. * @returns a string containng the defines string
  13481. */
  13482. getEffectDefines(): string;
  13483. /**
  13484. * Returns the string "CylinderParticleEmitter"
  13485. * @returns a string containing the class name
  13486. */
  13487. getClassName(): string;
  13488. /**
  13489. * Serializes the particle system to a JSON object.
  13490. * @returns the JSON object
  13491. */
  13492. serialize(): any;
  13493. /**
  13494. * Parse properties from a JSON object
  13495. * @param serializationObject defines the JSON object
  13496. */
  13497. parse(serializationObject: any): void;
  13498. }
  13499. /**
  13500. * Particle emitter emitting particles from the inside of a cylinder.
  13501. * It emits the particles randomly between two vectors.
  13502. */
  13503. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13504. /**
  13505. * The min limit of the emission direction.
  13506. */
  13507. direction1: Vector3;
  13508. /**
  13509. * The max limit of the emission direction.
  13510. */
  13511. direction2: Vector3;
  13512. /**
  13513. * Creates a new instance CylinderDirectedParticleEmitter
  13514. * @param radius the radius of the emission cylinder (1 by default)
  13515. * @param height the height of the emission cylinder (1 by default)
  13516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13517. * @param direction1 the min limit of the emission direction (up vector by default)
  13518. * @param direction2 the max limit of the emission direction (up vector by default)
  13519. */
  13520. constructor(radius?: number, height?: number, radiusRange?: number,
  13521. /**
  13522. * The min limit of the emission direction.
  13523. */
  13524. direction1?: Vector3,
  13525. /**
  13526. * The max limit of the emission direction.
  13527. */
  13528. direction2?: Vector3);
  13529. /**
  13530. * Called by the particle System when the direction is computed for the created particle.
  13531. * @param worldMatrix is the world matrix of the particle system
  13532. * @param directionToUpdate is the direction vector to update with the result
  13533. * @param particle is the particle we are computed the direction for
  13534. */
  13535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13536. /**
  13537. * Clones the current emitter and returns a copy of it
  13538. * @returns the new emitter
  13539. */
  13540. clone(): CylinderDirectedParticleEmitter;
  13541. /**
  13542. * Called by the GPUParticleSystem to setup the update shader
  13543. * @param effect defines the update shader
  13544. */
  13545. applyToShader(effect: Effect): void;
  13546. /**
  13547. * Returns a string to use to update the GPU particles update shader
  13548. * @returns a string containng the defines string
  13549. */
  13550. getEffectDefines(): string;
  13551. /**
  13552. * Returns the string "CylinderDirectedParticleEmitter"
  13553. * @returns a string containing the class name
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Serializes the particle system to a JSON object.
  13558. * @returns the JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Parse properties from a JSON object
  13563. * @param serializationObject defines the JSON object
  13564. */
  13565. parse(serializationObject: any): void;
  13566. }
  13567. }
  13568. declare module BABYLON {
  13569. /**
  13570. * Particle emitter emitting particles from the inside of a hemisphere.
  13571. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13572. */
  13573. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13574. /**
  13575. * The radius of the emission hemisphere.
  13576. */
  13577. radius: number;
  13578. /**
  13579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13580. */
  13581. radiusRange: number;
  13582. /**
  13583. * How much to randomize the particle direction [0-1].
  13584. */
  13585. directionRandomizer: number;
  13586. /**
  13587. * Creates a new instance HemisphericParticleEmitter
  13588. * @param radius the radius of the emission hemisphere (1 by default)
  13589. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13590. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13591. */
  13592. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  13607. * @param worldMatrix is the world matrix of the particle system
  13608. * @param directionToUpdate is the direction vector to update with the result
  13609. * @param particle is the particle we are computed the direction for
  13610. * @param isLocal defines if the direction should be set in local space
  13611. */
  13612. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13613. /**
  13614. * Called by the particle System when the position is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param positionToUpdate is the position vector to update with the result
  13617. * @param particle is the particle we are computed the position for
  13618. * @param isLocal defines if the position should be set in local space
  13619. */
  13620. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Clones the current emitter and returns a copy of it
  13623. * @returns the new emitter
  13624. */
  13625. clone(): HemisphericParticleEmitter;
  13626. /**
  13627. * Called by the GPUParticleSystem to setup the update shader
  13628. * @param effect defines the update shader
  13629. */
  13630. applyToShader(effect: Effect): void;
  13631. /**
  13632. * Returns a string to use to update the GPU particles update shader
  13633. * @returns a string containng the defines string
  13634. */
  13635. getEffectDefines(): string;
  13636. /**
  13637. * Returns the string "HemisphericParticleEmitter"
  13638. * @returns a string containing the class name
  13639. */
  13640. getClassName(): string;
  13641. /**
  13642. * Serializes the particle system to a JSON object.
  13643. * @returns the JSON object
  13644. */
  13645. serialize(): any;
  13646. /**
  13647. * Parse properties from a JSON object
  13648. * @param serializationObject defines the JSON object
  13649. */
  13650. parse(serializationObject: any): void;
  13651. }
  13652. }
  13653. declare module BABYLON {
  13654. /**
  13655. * Particle emitter emitting particles from a point.
  13656. * It emits the particles randomly between 2 given directions.
  13657. */
  13658. export class PointParticleEmitter implements IParticleEmitterType {
  13659. /**
  13660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13661. */
  13662. direction1: Vector3;
  13663. /**
  13664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13665. */
  13666. direction2: Vector3;
  13667. /**
  13668. * Creates a new instance PointParticleEmitter
  13669. */
  13670. constructor();
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. * @param isLocal defines if the direction should be set in local space
  13677. */
  13678. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13679. /**
  13680. * Called by the particle System when the position is computed for the created particle.
  13681. * @param worldMatrix is the world matrix of the particle system
  13682. * @param positionToUpdate is the position vector to update with the result
  13683. * @param particle is the particle we are computed the position for
  13684. * @param isLocal defines if the position should be set in local space
  13685. */
  13686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13687. /**
  13688. * Clones the current emitter and returns a copy of it
  13689. * @returns the new emitter
  13690. */
  13691. clone(): PointParticleEmitter;
  13692. /**
  13693. * Called by the GPUParticleSystem to setup the update shader
  13694. * @param effect defines the update shader
  13695. */
  13696. applyToShader(effect: Effect): void;
  13697. /**
  13698. * Returns a string to use to update the GPU particles update shader
  13699. * @returns a string containng the defines string
  13700. */
  13701. getEffectDefines(): string;
  13702. /**
  13703. * Returns the string "PointParticleEmitter"
  13704. * @returns a string containing the class name
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Serializes the particle system to a JSON object.
  13709. * @returns the JSON object
  13710. */
  13711. serialize(): any;
  13712. /**
  13713. * Parse properties from a JSON object
  13714. * @param serializationObject defines the JSON object
  13715. */
  13716. parse(serializationObject: any): void;
  13717. }
  13718. }
  13719. declare module BABYLON {
  13720. /**
  13721. * Particle emitter emitting particles from the inside of a sphere.
  13722. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13723. */
  13724. export class SphereParticleEmitter implements IParticleEmitterType {
  13725. /**
  13726. * The radius of the emission sphere.
  13727. */
  13728. radius: number;
  13729. /**
  13730. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13731. */
  13732. radiusRange: number;
  13733. /**
  13734. * How much to randomize the particle direction [0-1].
  13735. */
  13736. directionRandomizer: number;
  13737. /**
  13738. * Creates a new instance SphereParticleEmitter
  13739. * @param radius the radius of the emission sphere (1 by default)
  13740. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13741. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13742. */
  13743. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  13758. * @param worldMatrix is the world matrix of the particle system
  13759. * @param directionToUpdate is the direction vector to update with the result
  13760. * @param particle is the particle we are computed the direction for
  13761. * @param isLocal defines if the direction should be set in local space
  13762. */
  13763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13764. /**
  13765. * Called by the particle System when the position is computed for the created particle.
  13766. * @param worldMatrix is the world matrix of the particle system
  13767. * @param positionToUpdate is the position vector to update with the result
  13768. * @param particle is the particle we are computed the position for
  13769. * @param isLocal defines if the position should be set in local space
  13770. */
  13771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13772. /**
  13773. * Clones the current emitter and returns a copy of it
  13774. * @returns the new emitter
  13775. */
  13776. clone(): SphereParticleEmitter;
  13777. /**
  13778. * Called by the GPUParticleSystem to setup the update shader
  13779. * @param effect defines the update shader
  13780. */
  13781. applyToShader(effect: Effect): void;
  13782. /**
  13783. * Returns a string to use to update the GPU particles update shader
  13784. * @returns a string containng the defines string
  13785. */
  13786. getEffectDefines(): string;
  13787. /**
  13788. * Returns the string "SphereParticleEmitter"
  13789. * @returns a string containing the class name
  13790. */
  13791. getClassName(): string;
  13792. /**
  13793. * Serializes the particle system to a JSON object.
  13794. * @returns the JSON object
  13795. */
  13796. serialize(): any;
  13797. /**
  13798. * Parse properties from a JSON object
  13799. * @param serializationObject defines the JSON object
  13800. */
  13801. parse(serializationObject: any): void;
  13802. }
  13803. /**
  13804. * Particle emitter emitting particles from the inside of a sphere.
  13805. * It emits the particles randomly between two vectors.
  13806. */
  13807. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13808. /**
  13809. * The min limit of the emission direction.
  13810. */
  13811. direction1: Vector3;
  13812. /**
  13813. * The max limit of the emission direction.
  13814. */
  13815. direction2: Vector3;
  13816. /**
  13817. * Creates a new instance SphereDirectedParticleEmitter
  13818. * @param radius the radius of the emission sphere (1 by default)
  13819. * @param direction1 the min limit of the emission direction (up vector by default)
  13820. * @param direction2 the max limit of the emission direction (up vector by default)
  13821. */
  13822. constructor(radius?: number,
  13823. /**
  13824. * The min limit of the emission direction.
  13825. */
  13826. direction1?: Vector3,
  13827. /**
  13828. * The max limit of the emission direction.
  13829. */
  13830. direction2?: Vector3);
  13831. /**
  13832. * Called by the particle System when the direction is computed for the created particle.
  13833. * @param worldMatrix is the world matrix of the particle system
  13834. * @param directionToUpdate is the direction vector to update with the result
  13835. * @param particle is the particle we are computed the direction for
  13836. */
  13837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13838. /**
  13839. * Clones the current emitter and returns a copy of it
  13840. * @returns the new emitter
  13841. */
  13842. clone(): SphereDirectedParticleEmitter;
  13843. /**
  13844. * Called by the GPUParticleSystem to setup the update shader
  13845. * @param effect defines the update shader
  13846. */
  13847. applyToShader(effect: Effect): void;
  13848. /**
  13849. * Returns a string to use to update the GPU particles update shader
  13850. * @returns a string containng the defines string
  13851. */
  13852. getEffectDefines(): string;
  13853. /**
  13854. * Returns the string "SphereDirectedParticleEmitter"
  13855. * @returns a string containing the class name
  13856. */
  13857. getClassName(): string;
  13858. /**
  13859. * Serializes the particle system to a JSON object.
  13860. * @returns the JSON object
  13861. */
  13862. serialize(): any;
  13863. /**
  13864. * Parse properties from a JSON object
  13865. * @param serializationObject defines the JSON object
  13866. */
  13867. parse(serializationObject: any): void;
  13868. }
  13869. }
  13870. declare module BABYLON {
  13871. /**
  13872. * Particle emitter emitting particles from a custom list of positions.
  13873. */
  13874. export class CustomParticleEmitter implements IParticleEmitterType {
  13875. /**
  13876. * Gets or sets the position generator that will create the inital position of each particle.
  13877. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13878. */
  13879. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13880. /**
  13881. * Gets or sets the destination generator that will create the final destination of each particle.
  13882. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13883. */
  13884. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13885. /**
  13886. * Creates a new instance CustomParticleEmitter
  13887. */
  13888. constructor();
  13889. /**
  13890. * Called by the particle System when the direction is computed for the created particle.
  13891. * @param worldMatrix is the world matrix of the particle system
  13892. * @param directionToUpdate is the direction vector to update with the result
  13893. * @param particle is the particle we are computed the direction for
  13894. * @param isLocal defines if the direction should be set in local space
  13895. */
  13896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13897. /**
  13898. * Called by the particle System when the position is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param positionToUpdate is the position vector to update with the result
  13901. * @param particle is the particle we are computed the position for
  13902. * @param isLocal defines if the position should be set in local space
  13903. */
  13904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Clones the current emitter and returns a copy of it
  13907. * @returns the new emitter
  13908. */
  13909. clone(): CustomParticleEmitter;
  13910. /**
  13911. * Called by the GPUParticleSystem to setup the update shader
  13912. * @param effect defines the update shader
  13913. */
  13914. applyToShader(effect: Effect): void;
  13915. /**
  13916. * Returns a string to use to update the GPU particles update shader
  13917. * @returns a string containng the defines string
  13918. */
  13919. getEffectDefines(): string;
  13920. /**
  13921. * Returns the string "PointParticleEmitter"
  13922. * @returns a string containing the class name
  13923. */
  13924. getClassName(): string;
  13925. /**
  13926. * Serializes the particle system to a JSON object.
  13927. * @returns the JSON object
  13928. */
  13929. serialize(): any;
  13930. /**
  13931. * Parse properties from a JSON object
  13932. * @param serializationObject defines the JSON object
  13933. */
  13934. parse(serializationObject: any): void;
  13935. }
  13936. }
  13937. declare module BABYLON {
  13938. /**
  13939. * Particle emitter emitting particles from the inside of a box.
  13940. * It emits the particles randomly between 2 given directions.
  13941. */
  13942. export class MeshParticleEmitter implements IParticleEmitterType {
  13943. private _indices;
  13944. private _positions;
  13945. private _normals;
  13946. private _storedNormal;
  13947. private _mesh;
  13948. /**
  13949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13950. */
  13951. direction1: Vector3;
  13952. /**
  13953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13954. */
  13955. direction2: Vector3;
  13956. /**
  13957. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13958. */
  13959. useMeshNormalsForDirection: boolean;
  13960. /** Defines the mesh to use as source */
  13961. get mesh(): Nullable<AbstractMesh>;
  13962. set mesh(value: Nullable<AbstractMesh>);
  13963. /**
  13964. * Creates a new instance MeshParticleEmitter
  13965. * @param mesh defines the mesh to use as source
  13966. */
  13967. constructor(mesh?: Nullable<AbstractMesh>);
  13968. /**
  13969. * Called by the particle System when the direction is computed for the created particle.
  13970. * @param worldMatrix is the world matrix of the particle system
  13971. * @param directionToUpdate is the direction vector to update with the result
  13972. * @param particle is the particle we are computed the direction for
  13973. * @param isLocal defines if the direction should be set in local space
  13974. */
  13975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13976. /**
  13977. * Called by the particle System when the position is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param positionToUpdate is the position vector to update with the result
  13980. * @param particle is the particle we are computed the position for
  13981. * @param isLocal defines if the position should be set in local space
  13982. */
  13983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Clones the current emitter and returns a copy of it
  13986. * @returns the new emitter
  13987. */
  13988. clone(): MeshParticleEmitter;
  13989. /**
  13990. * Called by the GPUParticleSystem to setup the update shader
  13991. * @param effect defines the update shader
  13992. */
  13993. applyToShader(effect: Effect): void;
  13994. /**
  13995. * Returns a string to use to update the GPU particles update shader
  13996. * @returns a string containng the defines string
  13997. */
  13998. getEffectDefines(): string;
  13999. /**
  14000. * Returns the string "BoxParticleEmitter"
  14001. * @returns a string containing the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Serializes the particle system to a JSON object.
  14006. * @returns the JSON object
  14007. */
  14008. serialize(): any;
  14009. /**
  14010. * Parse properties from a JSON object
  14011. * @param serializationObject defines the JSON object
  14012. * @param scene defines the hosting scene
  14013. */
  14014. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14015. }
  14016. }
  14017. declare module BABYLON {
  14018. /**
  14019. * Interface representing a particle system in Babylon.js.
  14020. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14021. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14022. */
  14023. export interface IParticleSystem {
  14024. /**
  14025. * List of animations used by the particle system.
  14026. */
  14027. animations: Animation[];
  14028. /**
  14029. * The id of the Particle system.
  14030. */
  14031. id: string;
  14032. /**
  14033. * The name of the Particle system.
  14034. */
  14035. name: string;
  14036. /**
  14037. * The emitter represents the Mesh or position we are attaching the particle system to.
  14038. */
  14039. emitter: Nullable<AbstractMesh | Vector3>;
  14040. /**
  14041. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14042. */
  14043. isBillboardBased: boolean;
  14044. /**
  14045. * The rendering group used by the Particle system to chose when to render.
  14046. */
  14047. renderingGroupId: number;
  14048. /**
  14049. * The layer mask we are rendering the particles through.
  14050. */
  14051. layerMask: number;
  14052. /**
  14053. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14054. */
  14055. updateSpeed: number;
  14056. /**
  14057. * The amount of time the particle system is running (depends of the overall update speed).
  14058. */
  14059. targetStopDuration: number;
  14060. /**
  14061. * The texture used to render each particle. (this can be a spritesheet)
  14062. */
  14063. particleTexture: Nullable<BaseTexture>;
  14064. /**
  14065. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14066. */
  14067. blendMode: number;
  14068. /**
  14069. * Minimum life time of emitting particles.
  14070. */
  14071. minLifeTime: number;
  14072. /**
  14073. * Maximum life time of emitting particles.
  14074. */
  14075. maxLifeTime: number;
  14076. /**
  14077. * Minimum Size of emitting particles.
  14078. */
  14079. minSize: number;
  14080. /**
  14081. * Maximum Size of emitting particles.
  14082. */
  14083. maxSize: number;
  14084. /**
  14085. * Minimum scale of emitting particles on X axis.
  14086. */
  14087. minScaleX: number;
  14088. /**
  14089. * Maximum scale of emitting particles on X axis.
  14090. */
  14091. maxScaleX: number;
  14092. /**
  14093. * Minimum scale of emitting particles on Y axis.
  14094. */
  14095. minScaleY: number;
  14096. /**
  14097. * Maximum scale of emitting particles on Y axis.
  14098. */
  14099. maxScaleY: number;
  14100. /**
  14101. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14102. */
  14103. color1: Color4;
  14104. /**
  14105. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14106. */
  14107. color2: Color4;
  14108. /**
  14109. * Color the particle will have at the end of its lifetime.
  14110. */
  14111. colorDead: Color4;
  14112. /**
  14113. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14114. */
  14115. emitRate: number;
  14116. /**
  14117. * You can use gravity if you want to give an orientation to your particles.
  14118. */
  14119. gravity: Vector3;
  14120. /**
  14121. * Minimum power of emitting particles.
  14122. */
  14123. minEmitPower: number;
  14124. /**
  14125. * Maximum power of emitting particles.
  14126. */
  14127. maxEmitPower: number;
  14128. /**
  14129. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14130. */
  14131. minAngularSpeed: number;
  14132. /**
  14133. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14134. */
  14135. maxAngularSpeed: number;
  14136. /**
  14137. * Gets or sets the minimal initial rotation in radians.
  14138. */
  14139. minInitialRotation: number;
  14140. /**
  14141. * Gets or sets the maximal initial rotation in radians.
  14142. */
  14143. maxInitialRotation: number;
  14144. /**
  14145. * The particle emitter type defines the emitter used by the particle system.
  14146. * It can be for example box, sphere, or cone...
  14147. */
  14148. particleEmitterType: Nullable<IParticleEmitterType>;
  14149. /**
  14150. * Defines the delay in milliseconds before starting the system (0 by default)
  14151. */
  14152. startDelay: number;
  14153. /**
  14154. * 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
  14155. */
  14156. preWarmCycles: number;
  14157. /**
  14158. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14159. */
  14160. preWarmStepOffset: number;
  14161. /**
  14162. * 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)
  14163. */
  14164. spriteCellChangeSpeed: number;
  14165. /**
  14166. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14167. */
  14168. startSpriteCellID: number;
  14169. /**
  14170. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14171. */
  14172. endSpriteCellID: number;
  14173. /**
  14174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14175. */
  14176. spriteCellWidth: number;
  14177. /**
  14178. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14179. */
  14180. spriteCellHeight: number;
  14181. /**
  14182. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14183. */
  14184. spriteRandomStartCell: boolean;
  14185. /**
  14186. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14187. */
  14188. isAnimationSheetEnabled: boolean;
  14189. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14190. translationPivot: Vector2;
  14191. /**
  14192. * Gets or sets a texture used to add random noise to particle positions
  14193. */
  14194. noiseTexture: Nullable<BaseTexture>;
  14195. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14196. noiseStrength: Vector3;
  14197. /**
  14198. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14199. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14200. */
  14201. billboardMode: number;
  14202. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14203. limitVelocityDamping: number;
  14204. /**
  14205. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14206. */
  14207. beginAnimationOnStart: boolean;
  14208. /**
  14209. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14210. */
  14211. beginAnimationFrom: number;
  14212. /**
  14213. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14214. */
  14215. beginAnimationTo: number;
  14216. /**
  14217. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14218. */
  14219. beginAnimationLoop: boolean;
  14220. /**
  14221. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14222. */
  14223. disposeOnStop: boolean;
  14224. /**
  14225. * Specifies if the particles are updated in emitter local space or world space
  14226. */
  14227. isLocal: boolean;
  14228. /** Snippet ID if the particle system was created from the snippet server */
  14229. snippetId: string;
  14230. /** Gets or sets a matrix to use to compute projection */
  14231. defaultProjectionMatrix: Matrix;
  14232. /**
  14233. * Gets the maximum number of particles active at the same time.
  14234. * @returns The max number of active particles.
  14235. */
  14236. getCapacity(): number;
  14237. /**
  14238. * Gets the number of particles active at the same time.
  14239. * @returns The number of active particles.
  14240. */
  14241. getActiveCount(): number;
  14242. /**
  14243. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14244. * @returns True if it has been started, otherwise false.
  14245. */
  14246. isStarted(): boolean;
  14247. /**
  14248. * Animates the particle system for this frame.
  14249. */
  14250. animate(): void;
  14251. /**
  14252. * Renders the particle system in its current state.
  14253. * @returns the current number of particles
  14254. */
  14255. render(): number;
  14256. /**
  14257. * Dispose the particle system and frees its associated resources.
  14258. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14259. */
  14260. dispose(disposeTexture?: boolean): void;
  14261. /**
  14262. * An event triggered when the system is disposed
  14263. */
  14264. onDisposeObservable: Observable<IParticleSystem>;
  14265. /**
  14266. * Clones the particle system.
  14267. * @param name The name of the cloned object
  14268. * @param newEmitter The new emitter to use
  14269. * @returns the cloned particle system
  14270. */
  14271. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14272. /**
  14273. * Serializes the particle system to a JSON object
  14274. * @param serializeTexture defines if the texture must be serialized as well
  14275. * @returns the JSON object
  14276. */
  14277. serialize(serializeTexture: boolean): any;
  14278. /**
  14279. * Rebuild the particle system
  14280. */
  14281. rebuild(): void;
  14282. /** Force the system to rebuild all gradients that need to be resync */
  14283. forceRefreshGradients(): void;
  14284. /**
  14285. * Starts the particle system and begins to emit
  14286. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14287. */
  14288. start(delay?: number): void;
  14289. /**
  14290. * Stops the particle system.
  14291. */
  14292. stop(): void;
  14293. /**
  14294. * Remove all active particles
  14295. */
  14296. reset(): void;
  14297. /**
  14298. * Gets a boolean indicating that the system is stopping
  14299. * @returns true if the system is currently stopping
  14300. */
  14301. isStopping(): boolean;
  14302. /**
  14303. * Is this system ready to be used/rendered
  14304. * @return true if the system is ready
  14305. */
  14306. isReady(): boolean;
  14307. /**
  14308. * Returns the string "ParticleSystem"
  14309. * @returns a string containing the class name
  14310. */
  14311. getClassName(): string;
  14312. /**
  14313. * Gets the custom effect used to render the particles
  14314. * @param blendMode Blend mode for which the effect should be retrieved
  14315. * @returns The effect
  14316. */
  14317. getCustomEffect(blendMode: number): Nullable<Effect>;
  14318. /**
  14319. * Sets the custom effect used to render the particles
  14320. * @param effect The effect to set
  14321. * @param blendMode Blend mode for which the effect should be set
  14322. */
  14323. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14324. /**
  14325. * Fill the defines array according to the current settings of the particle system
  14326. * @param defines Array to be updated
  14327. * @param blendMode blend mode to take into account when updating the array
  14328. */
  14329. fillDefines(defines: Array<string>, blendMode: number): void;
  14330. /**
  14331. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14332. * @param uniforms Uniforms array to fill
  14333. * @param attributes Attributes array to fill
  14334. * @param samplers Samplers array to fill
  14335. */
  14336. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14337. /**
  14338. * Observable that will be called just before the particles are drawn
  14339. */
  14340. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14341. /**
  14342. * Gets the name of the particle vertex shader
  14343. */
  14344. vertexShaderName: string;
  14345. /**
  14346. * Adds a new color gradient
  14347. * @param gradient defines the gradient to use (between 0 and 1)
  14348. * @param color1 defines the color to affect to the specified gradient
  14349. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14350. * @returns the current particle system
  14351. */
  14352. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14353. /**
  14354. * Remove a specific color gradient
  14355. * @param gradient defines the gradient to remove
  14356. * @returns the current particle system
  14357. */
  14358. removeColorGradient(gradient: number): IParticleSystem;
  14359. /**
  14360. * Adds a new size gradient
  14361. * @param gradient defines the gradient to use (between 0 and 1)
  14362. * @param factor defines the size factor to affect to the specified gradient
  14363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14364. * @returns the current particle system
  14365. */
  14366. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14367. /**
  14368. * Remove a specific size gradient
  14369. * @param gradient defines the gradient to remove
  14370. * @returns the current particle system
  14371. */
  14372. removeSizeGradient(gradient: number): IParticleSystem;
  14373. /**
  14374. * Gets the current list of color gradients.
  14375. * You must use addColorGradient and removeColorGradient to udpate this list
  14376. * @returns the list of color gradients
  14377. */
  14378. getColorGradients(): Nullable<Array<ColorGradient>>;
  14379. /**
  14380. * Gets the current list of size gradients.
  14381. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14382. * @returns the list of size gradients
  14383. */
  14384. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of angular speed gradients.
  14387. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14388. * @returns the list of angular speed gradients
  14389. */
  14390. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Adds a new angular speed gradient
  14393. * @param gradient defines the gradient to use (between 0 and 1)
  14394. * @param factor defines the angular speed to affect to the specified gradient
  14395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14396. * @returns the current particle system
  14397. */
  14398. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14399. /**
  14400. * Remove a specific angular speed gradient
  14401. * @param gradient defines the gradient to remove
  14402. * @returns the current particle system
  14403. */
  14404. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14405. /**
  14406. * Gets the current list of velocity gradients.
  14407. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14408. * @returns the list of velocity gradients
  14409. */
  14410. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14411. /**
  14412. * Adds a new velocity gradient
  14413. * @param gradient defines the gradient to use (between 0 and 1)
  14414. * @param factor defines the velocity to affect to the specified gradient
  14415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14416. * @returns the current particle system
  14417. */
  14418. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14419. /**
  14420. * Remove a specific velocity gradient
  14421. * @param gradient defines the gradient to remove
  14422. * @returns the current particle system
  14423. */
  14424. removeVelocityGradient(gradient: number): IParticleSystem;
  14425. /**
  14426. * Gets the current list of limit velocity gradients.
  14427. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14428. * @returns the list of limit velocity gradients
  14429. */
  14430. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14431. /**
  14432. * Adds a new limit velocity gradient
  14433. * @param gradient defines the gradient to use (between 0 and 1)
  14434. * @param factor defines the limit velocity to affect to the specified gradient
  14435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14436. * @returns the current particle system
  14437. */
  14438. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14439. /**
  14440. * Remove a specific limit velocity gradient
  14441. * @param gradient defines the gradient to remove
  14442. * @returns the current particle system
  14443. */
  14444. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14445. /**
  14446. * Adds a new drag gradient
  14447. * @param gradient defines the gradient to use (between 0 and 1)
  14448. * @param factor defines the drag to affect to the specified gradient
  14449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14450. * @returns the current particle system
  14451. */
  14452. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14453. /**
  14454. * Remove a specific drag gradient
  14455. * @param gradient defines the gradient to remove
  14456. * @returns the current particle system
  14457. */
  14458. removeDragGradient(gradient: number): IParticleSystem;
  14459. /**
  14460. * Gets the current list of drag gradients.
  14461. * You must use addDragGradient and removeDragGradient to udpate this list
  14462. * @returns the list of drag gradients
  14463. */
  14464. getDragGradients(): Nullable<Array<FactorGradient>>;
  14465. /**
  14466. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14467. * @param gradient defines the gradient to use (between 0 and 1)
  14468. * @param factor defines the emit rate to affect to the specified gradient
  14469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14470. * @returns the current particle system
  14471. */
  14472. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14473. /**
  14474. * Remove a specific emit rate gradient
  14475. * @param gradient defines the gradient to remove
  14476. * @returns the current particle system
  14477. */
  14478. removeEmitRateGradient(gradient: number): IParticleSystem;
  14479. /**
  14480. * Gets the current list of emit rate gradients.
  14481. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14482. * @returns the list of emit rate gradients
  14483. */
  14484. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14485. /**
  14486. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14487. * @param gradient defines the gradient to use (between 0 and 1)
  14488. * @param factor defines the start size to affect to the specified gradient
  14489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14490. * @returns the current particle system
  14491. */
  14492. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14493. /**
  14494. * Remove a specific start size gradient
  14495. * @param gradient defines the gradient to remove
  14496. * @returns the current particle system
  14497. */
  14498. removeStartSizeGradient(gradient: number): IParticleSystem;
  14499. /**
  14500. * Gets the current list of start size gradients.
  14501. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14502. * @returns the list of start size gradients
  14503. */
  14504. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14505. /**
  14506. * Adds a new life time gradient
  14507. * @param gradient defines the gradient to use (between 0 and 1)
  14508. * @param factor defines the life time factor to affect to the specified gradient
  14509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14510. * @returns the current particle system
  14511. */
  14512. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14513. /**
  14514. * Remove a specific life time gradient
  14515. * @param gradient defines the gradient to remove
  14516. * @returns the current particle system
  14517. */
  14518. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14519. /**
  14520. * Gets the current list of life time gradients.
  14521. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14522. * @returns the list of life time gradients
  14523. */
  14524. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14525. /**
  14526. * Gets the current list of color gradients.
  14527. * You must use addColorGradient and removeColorGradient to udpate this list
  14528. * @returns the list of color gradients
  14529. */
  14530. getColorGradients(): Nullable<Array<ColorGradient>>;
  14531. /**
  14532. * Adds a new ramp gradient used to remap particle colors
  14533. * @param gradient defines the gradient to use (between 0 and 1)
  14534. * @param color defines the color to affect to the specified gradient
  14535. * @returns the current particle system
  14536. */
  14537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14538. /**
  14539. * Gets the current list of ramp gradients.
  14540. * You must use addRampGradient and removeRampGradient to udpate this list
  14541. * @returns the list of ramp gradients
  14542. */
  14543. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14544. /** Gets or sets a boolean indicating that ramp gradients must be used
  14545. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14546. */
  14547. useRampGradients: boolean;
  14548. /**
  14549. * Adds a new color remap gradient
  14550. * @param gradient defines the gradient to use (between 0 and 1)
  14551. * @param min defines the color remap minimal range
  14552. * @param max defines the color remap maximal range
  14553. * @returns the current particle system
  14554. */
  14555. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14556. /**
  14557. * Gets the current list of color remap gradients.
  14558. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14559. * @returns the list of color remap gradients
  14560. */
  14561. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Adds a new alpha remap gradient
  14564. * @param gradient defines the gradient to use (between 0 and 1)
  14565. * @param min defines the alpha remap minimal range
  14566. * @param max defines the alpha remap maximal range
  14567. * @returns the current particle system
  14568. */
  14569. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of alpha remap gradients.
  14572. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14573. * @returns the list of alpha remap gradients
  14574. */
  14575. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. /**
  14641. * Get hosting scene
  14642. * @returns the scene
  14643. */
  14644. getScene(): Nullable<Scene>;
  14645. }
  14646. }
  14647. declare module BABYLON {
  14648. /**
  14649. * 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.
  14650. * @see https://doc.babylonjs.com/how_to/transformnode
  14651. */
  14652. export class TransformNode extends Node {
  14653. /**
  14654. * Object will not rotate to face the camera
  14655. */
  14656. static BILLBOARDMODE_NONE: number;
  14657. /**
  14658. * Object will rotate to face the camera but only on the x axis
  14659. */
  14660. static BILLBOARDMODE_X: number;
  14661. /**
  14662. * Object will rotate to face the camera but only on the y axis
  14663. */
  14664. static BILLBOARDMODE_Y: number;
  14665. /**
  14666. * Object will rotate to face the camera but only on the z axis
  14667. */
  14668. static BILLBOARDMODE_Z: number;
  14669. /**
  14670. * Object will rotate to face the camera
  14671. */
  14672. static BILLBOARDMODE_ALL: number;
  14673. /**
  14674. * Object will rotate to face the camera's position instead of orientation
  14675. */
  14676. static BILLBOARDMODE_USE_POSITION: number;
  14677. private static _TmpRotation;
  14678. private static _TmpScaling;
  14679. private static _TmpTranslation;
  14680. private _forward;
  14681. private _forwardInverted;
  14682. private _up;
  14683. private _right;
  14684. private _rightInverted;
  14685. private _position;
  14686. private _rotation;
  14687. private _rotationQuaternion;
  14688. protected _scaling: Vector3;
  14689. protected _isDirty: boolean;
  14690. private _transformToBoneReferal;
  14691. private _isAbsoluteSynced;
  14692. private _billboardMode;
  14693. /**
  14694. * Gets or sets the billboard mode. Default is 0.
  14695. *
  14696. * | Value | Type | Description |
  14697. * | --- | --- | --- |
  14698. * | 0 | BILLBOARDMODE_NONE | |
  14699. * | 1 | BILLBOARDMODE_X | |
  14700. * | 2 | BILLBOARDMODE_Y | |
  14701. * | 4 | BILLBOARDMODE_Z | |
  14702. * | 7 | BILLBOARDMODE_ALL | |
  14703. *
  14704. */
  14705. get billboardMode(): number;
  14706. set billboardMode(value: number);
  14707. private _preserveParentRotationForBillboard;
  14708. /**
  14709. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14710. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14711. */
  14712. get preserveParentRotationForBillboard(): boolean;
  14713. set preserveParentRotationForBillboard(value: boolean);
  14714. /**
  14715. * 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
  14716. */
  14717. scalingDeterminant: number;
  14718. private _infiniteDistance;
  14719. /**
  14720. * Gets or sets the distance of the object to max, often used by skybox
  14721. */
  14722. get infiniteDistance(): boolean;
  14723. set infiniteDistance(value: boolean);
  14724. /**
  14725. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14726. * By default the system will update normals to compensate
  14727. */
  14728. ignoreNonUniformScaling: boolean;
  14729. /**
  14730. * 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
  14731. */
  14732. reIntegrateRotationIntoRotationQuaternion: boolean;
  14733. /** @hidden */
  14734. _poseMatrix: Nullable<Matrix>;
  14735. /** @hidden */
  14736. _localMatrix: Matrix;
  14737. private _usePivotMatrix;
  14738. private _absolutePosition;
  14739. private _absoluteScaling;
  14740. private _absoluteRotationQuaternion;
  14741. private _pivotMatrix;
  14742. private _pivotMatrixInverse;
  14743. /** @hidden */
  14744. _postMultiplyPivotMatrix: boolean;
  14745. protected _isWorldMatrixFrozen: boolean;
  14746. /** @hidden */
  14747. _indexInSceneTransformNodesArray: number;
  14748. /**
  14749. * An event triggered after the world matrix is updated
  14750. */
  14751. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14752. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14753. /**
  14754. * Gets a string identifying the name of the class
  14755. * @returns "TransformNode" string
  14756. */
  14757. getClassName(): string;
  14758. /**
  14759. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14760. */
  14761. get position(): Vector3;
  14762. set position(newPosition: Vector3);
  14763. /**
  14764. * 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)).
  14765. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14766. */
  14767. get rotation(): Vector3;
  14768. set rotation(newRotation: Vector3);
  14769. /**
  14770. * 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)).
  14771. */
  14772. get scaling(): Vector3;
  14773. set scaling(newScaling: Vector3);
  14774. /**
  14775. * 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).
  14776. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14777. */
  14778. get rotationQuaternion(): Nullable<Quaternion>;
  14779. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14780. /**
  14781. * The forward direction of that transform in world space.
  14782. */
  14783. get forward(): Vector3;
  14784. /**
  14785. * The up direction of that transform in world space.
  14786. */
  14787. get up(): Vector3;
  14788. /**
  14789. * The right direction of that transform in world space.
  14790. */
  14791. get right(): Vector3;
  14792. /**
  14793. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14794. * @param matrix the matrix to copy the pose from
  14795. * @returns this TransformNode.
  14796. */
  14797. updatePoseMatrix(matrix: Matrix): TransformNode;
  14798. /**
  14799. * Returns the mesh Pose matrix.
  14800. * @returns the pose matrix
  14801. */
  14802. getPoseMatrix(): Matrix;
  14803. /** @hidden */
  14804. _isSynchronized(): boolean;
  14805. /** @hidden */
  14806. _initCache(): void;
  14807. /**
  14808. * Flag the transform node as dirty (Forcing it to update everything)
  14809. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14810. * @returns this transform node
  14811. */
  14812. markAsDirty(property: string): TransformNode;
  14813. /**
  14814. * Returns the current mesh absolute position.
  14815. * Returns a Vector3.
  14816. */
  14817. get absolutePosition(): Vector3;
  14818. /**
  14819. * Returns the current mesh absolute scaling.
  14820. * Returns a Vector3.
  14821. */
  14822. get absoluteScaling(): Vector3;
  14823. /**
  14824. * Returns the current mesh absolute rotation.
  14825. * Returns a Quaternion.
  14826. */
  14827. get absoluteRotationQuaternion(): Quaternion;
  14828. /**
  14829. * Sets a new matrix to apply before all other transformation
  14830. * @param matrix defines the transform matrix
  14831. * @returns the current TransformNode
  14832. */
  14833. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14834. /**
  14835. * Sets a new pivot matrix to the current node
  14836. * @param matrix defines the new pivot matrix to use
  14837. * @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
  14838. * @returns the current TransformNode
  14839. */
  14840. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14841. /**
  14842. * Returns the mesh pivot matrix.
  14843. * Default : Identity.
  14844. * @returns the matrix
  14845. */
  14846. getPivotMatrix(): Matrix;
  14847. /**
  14848. * Instantiate (when possible) or clone that node with its hierarchy
  14849. * @param newParent defines the new parent to use for the instance (or clone)
  14850. * @param options defines options to configure how copy is done
  14851. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14852. * @returns an instance (or a clone) of the current node with its hiearchy
  14853. */
  14854. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14855. doNotInstantiate: boolean;
  14856. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14857. /**
  14858. * Prevents the World matrix to be computed any longer
  14859. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14860. * @returns the TransformNode.
  14861. */
  14862. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14863. /**
  14864. * Allows back the World matrix computation.
  14865. * @returns the TransformNode.
  14866. */
  14867. unfreezeWorldMatrix(): this;
  14868. /**
  14869. * True if the World matrix has been frozen.
  14870. */
  14871. get isWorldMatrixFrozen(): boolean;
  14872. /**
  14873. * Retuns the mesh absolute position in the World.
  14874. * @returns a Vector3.
  14875. */
  14876. getAbsolutePosition(): Vector3;
  14877. /**
  14878. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14879. * @param absolutePosition the absolute position to set
  14880. * @returns the TransformNode.
  14881. */
  14882. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14883. /**
  14884. * Sets the mesh position in its local space.
  14885. * @param vector3 the position to set in localspace
  14886. * @returns the TransformNode.
  14887. */
  14888. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14889. /**
  14890. * Returns the mesh position in the local space from the current World matrix values.
  14891. * @returns a new Vector3.
  14892. */
  14893. getPositionExpressedInLocalSpace(): Vector3;
  14894. /**
  14895. * Translates the mesh along the passed Vector3 in its local space.
  14896. * @param vector3 the distance to translate in localspace
  14897. * @returns the TransformNode.
  14898. */
  14899. locallyTranslate(vector3: Vector3): TransformNode;
  14900. private static _lookAtVectorCache;
  14901. /**
  14902. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14903. * @param targetPoint the position (must be in same space as current mesh) to look at
  14904. * @param yawCor optional yaw (y-axis) correction in radians
  14905. * @param pitchCor optional pitch (x-axis) correction in radians
  14906. * @param rollCor optional roll (z-axis) correction in radians
  14907. * @param space the choosen space of the target
  14908. * @returns the TransformNode.
  14909. */
  14910. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14911. /**
  14912. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14913. * This Vector3 is expressed in the World space.
  14914. * @param localAxis axis to rotate
  14915. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14916. */
  14917. getDirection(localAxis: Vector3): Vector3;
  14918. /**
  14919. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14920. * localAxis is expressed in the mesh local space.
  14921. * result is computed in the Wordl space from the mesh World matrix.
  14922. * @param localAxis axis to rotate
  14923. * @param result the resulting transformnode
  14924. * @returns this TransformNode.
  14925. */
  14926. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14927. /**
  14928. * Sets this transform node rotation to the given local axis.
  14929. * @param localAxis the axis in local space
  14930. * @param yawCor optional yaw (y-axis) correction in radians
  14931. * @param pitchCor optional pitch (x-axis) correction in radians
  14932. * @param rollCor optional roll (z-axis) correction in radians
  14933. * @returns this TransformNode
  14934. */
  14935. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14936. /**
  14937. * Sets a new pivot point to the current node
  14938. * @param point defines the new pivot point to use
  14939. * @param space defines if the point is in world or local space (local by default)
  14940. * @returns the current TransformNode
  14941. */
  14942. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14943. /**
  14944. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14945. * @returns the pivot point
  14946. */
  14947. getPivotPoint(): Vector3;
  14948. /**
  14949. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14950. * @param result the vector3 to store the result
  14951. * @returns this TransformNode.
  14952. */
  14953. getPivotPointToRef(result: Vector3): TransformNode;
  14954. /**
  14955. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14956. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14957. */
  14958. getAbsolutePivotPoint(): Vector3;
  14959. /**
  14960. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14961. * @param result vector3 to store the result
  14962. * @returns this TransformNode.
  14963. */
  14964. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14965. /**
  14966. * Defines the passed node as the parent of the current node.
  14967. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14968. * @see https://doc.babylonjs.com/how_to/parenting
  14969. * @param node the node ot set as the parent
  14970. * @returns this TransformNode.
  14971. */
  14972. setParent(node: Nullable<Node>): TransformNode;
  14973. private _nonUniformScaling;
  14974. /**
  14975. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14976. */
  14977. get nonUniformScaling(): boolean;
  14978. /** @hidden */
  14979. _updateNonUniformScalingState(value: boolean): boolean;
  14980. /**
  14981. * Attach the current TransformNode to another TransformNode associated with a bone
  14982. * @param bone Bone affecting the TransformNode
  14983. * @param affectedTransformNode TransformNode associated with the bone
  14984. * @returns this object
  14985. */
  14986. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14987. /**
  14988. * Detach the transform node if its associated with a bone
  14989. * @returns this object
  14990. */
  14991. detachFromBone(): TransformNode;
  14992. private static _rotationAxisCache;
  14993. /**
  14994. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14995. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14996. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14997. * The passed axis is also normalized.
  14998. * @param axis the axis to rotate around
  14999. * @param amount the amount to rotate in radians
  15000. * @param space Space to rotate in (Default: local)
  15001. * @returns the TransformNode.
  15002. */
  15003. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15004. /**
  15005. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15006. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15007. * The passed axis is also normalized. .
  15008. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15009. * @param point the point to rotate around
  15010. * @param axis the axis to rotate around
  15011. * @param amount the amount to rotate in radians
  15012. * @returns the TransformNode
  15013. */
  15014. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15015. /**
  15016. * Translates the mesh along the axis vector for the passed distance in the given space.
  15017. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15018. * @param axis the axis to translate in
  15019. * @param distance the distance to translate
  15020. * @param space Space to rotate in (Default: local)
  15021. * @returns the TransformNode.
  15022. */
  15023. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15024. /**
  15025. * Adds a rotation step to the mesh current rotation.
  15026. * x, y, z are Euler angles expressed in radians.
  15027. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15028. * This means this rotation is made in the mesh local space only.
  15029. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15030. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15031. * ```javascript
  15032. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15033. * ```
  15034. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15035. * 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.
  15036. * @param x Rotation to add
  15037. * @param y Rotation to add
  15038. * @param z Rotation to add
  15039. * @returns the TransformNode.
  15040. */
  15041. addRotation(x: number, y: number, z: number): TransformNode;
  15042. /**
  15043. * @hidden
  15044. */
  15045. protected _getEffectiveParent(): Nullable<Node>;
  15046. /**
  15047. * Computes the world matrix of the node
  15048. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15049. * @returns the world matrix
  15050. */
  15051. computeWorldMatrix(force?: boolean): Matrix;
  15052. /**
  15053. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15054. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15055. */
  15056. resetLocalMatrix(independentOfChildren?: boolean): void;
  15057. protected _afterComputeWorldMatrix(): void;
  15058. /**
  15059. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15060. * @param func callback function to add
  15061. *
  15062. * @returns the TransformNode.
  15063. */
  15064. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15065. /**
  15066. * Removes a registered callback function.
  15067. * @param func callback function to remove
  15068. * @returns the TransformNode.
  15069. */
  15070. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15071. /**
  15072. * Gets the position of the current mesh in camera space
  15073. * @param camera defines the camera to use
  15074. * @returns a position
  15075. */
  15076. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15077. /**
  15078. * Returns the distance from the mesh to the active camera
  15079. * @param camera defines the camera to use
  15080. * @returns the distance
  15081. */
  15082. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15083. /**
  15084. * Clone the current transform node
  15085. * @param name Name of the new clone
  15086. * @param newParent New parent for the clone
  15087. * @param doNotCloneChildren Do not clone children hierarchy
  15088. * @returns the new transform node
  15089. */
  15090. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15091. /**
  15092. * Serializes the objects information.
  15093. * @param currentSerializationObject defines the object to serialize in
  15094. * @returns the serialized object
  15095. */
  15096. serialize(currentSerializationObject?: any): any;
  15097. /**
  15098. * Returns a new TransformNode object parsed from the source provided.
  15099. * @param parsedTransformNode is the source.
  15100. * @param scene the scne the object belongs to
  15101. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15102. * @returns a new TransformNode object parsed from the source provided.
  15103. */
  15104. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15105. /**
  15106. * Get all child-transformNodes of this node
  15107. * @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
  15108. * @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
  15109. * @returns an array of TransformNode
  15110. */
  15111. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15112. /**
  15113. * Releases resources associated with this transform node.
  15114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15116. */
  15117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15118. /**
  15119. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15120. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15121. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15122. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15123. * @returns the current mesh
  15124. */
  15125. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15126. private _syncAbsoluteScalingAndRotation;
  15127. }
  15128. }
  15129. declare module BABYLON {
  15130. /**
  15131. * Class used to override all child animations of a given target
  15132. */
  15133. export class AnimationPropertiesOverride {
  15134. /**
  15135. * Gets or sets a value indicating if animation blending must be used
  15136. */
  15137. enableBlending: boolean;
  15138. /**
  15139. * Gets or sets the blending speed to use when enableBlending is true
  15140. */
  15141. blendingSpeed: number;
  15142. /**
  15143. * Gets or sets the default loop mode to use
  15144. */
  15145. loopMode: number;
  15146. }
  15147. }
  15148. declare module BABYLON {
  15149. /**
  15150. * Class used to store bone information
  15151. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15152. */
  15153. export class Bone extends Node {
  15154. /**
  15155. * defines the bone name
  15156. */
  15157. name: string;
  15158. private static _tmpVecs;
  15159. private static _tmpQuat;
  15160. private static _tmpMats;
  15161. /**
  15162. * Gets the list of child bones
  15163. */
  15164. children: Bone[];
  15165. /** Gets the animations associated with this bone */
  15166. animations: Animation[];
  15167. /**
  15168. * Gets or sets bone length
  15169. */
  15170. length: number;
  15171. /**
  15172. * @hidden Internal only
  15173. * Set this value to map this bone to a different index in the transform matrices
  15174. * Set this value to -1 to exclude the bone from the transform matrices
  15175. */
  15176. _index: Nullable<number>;
  15177. private _skeleton;
  15178. private _localMatrix;
  15179. private _restPose;
  15180. private _bindPose;
  15181. private _baseMatrix;
  15182. private _absoluteTransform;
  15183. private _invertedAbsoluteTransform;
  15184. private _parent;
  15185. private _scalingDeterminant;
  15186. private _worldTransform;
  15187. private _localScaling;
  15188. private _localRotation;
  15189. private _localPosition;
  15190. private _needToDecompose;
  15191. private _needToCompose;
  15192. /** @hidden */
  15193. _linkedTransformNode: Nullable<TransformNode>;
  15194. /** @hidden */
  15195. _waitingTransformNodeId: Nullable<string>;
  15196. /** @hidden */
  15197. get _matrix(): Matrix;
  15198. /** @hidden */
  15199. set _matrix(value: Matrix);
  15200. /**
  15201. * Create a new bone
  15202. * @param name defines the bone name
  15203. * @param skeleton defines the parent skeleton
  15204. * @param parentBone defines the parent (can be null if the bone is the root)
  15205. * @param localMatrix defines the local matrix
  15206. * @param restPose defines the rest pose matrix
  15207. * @param baseMatrix defines the base matrix
  15208. * @param index defines index of the bone in the hiearchy
  15209. */
  15210. constructor(
  15211. /**
  15212. * defines the bone name
  15213. */
  15214. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15215. /**
  15216. * Gets the current object class name.
  15217. * @return the class name
  15218. */
  15219. getClassName(): string;
  15220. /**
  15221. * Gets the parent skeleton
  15222. * @returns a skeleton
  15223. */
  15224. getSkeleton(): Skeleton;
  15225. /**
  15226. * Gets parent bone
  15227. * @returns a bone or null if the bone is the root of the bone hierarchy
  15228. */
  15229. getParent(): Nullable<Bone>;
  15230. /**
  15231. * Returns an array containing the root bones
  15232. * @returns an array containing the root bones
  15233. */
  15234. getChildren(): Array<Bone>;
  15235. /**
  15236. * Gets the node index in matrix array generated for rendering
  15237. * @returns the node index
  15238. */
  15239. getIndex(): number;
  15240. /**
  15241. * Sets the parent bone
  15242. * @param parent defines the parent (can be null if the bone is the root)
  15243. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15244. */
  15245. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15246. /**
  15247. * Gets the local matrix
  15248. * @returns a matrix
  15249. */
  15250. getLocalMatrix(): Matrix;
  15251. /**
  15252. * Gets the base matrix (initial matrix which remains unchanged)
  15253. * @returns a matrix
  15254. */
  15255. getBaseMatrix(): Matrix;
  15256. /**
  15257. * Gets the rest pose matrix
  15258. * @returns a matrix
  15259. */
  15260. getRestPose(): Matrix;
  15261. /**
  15262. * Sets the rest pose matrix
  15263. * @param matrix the local-space rest pose to set for this bone
  15264. */
  15265. setRestPose(matrix: Matrix): void;
  15266. /**
  15267. * Gets the bind pose matrix
  15268. * @returns the bind pose matrix
  15269. */
  15270. getBindPose(): Matrix;
  15271. /**
  15272. * Sets the bind pose matrix
  15273. * @param matrix the local-space bind pose to set for this bone
  15274. */
  15275. setBindPose(matrix: Matrix): void;
  15276. /**
  15277. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15278. */
  15279. getWorldMatrix(): Matrix;
  15280. /**
  15281. * Sets the local matrix to rest pose matrix
  15282. */
  15283. returnToRest(): void;
  15284. /**
  15285. * Gets the inverse of the absolute transform matrix.
  15286. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15287. * @returns a matrix
  15288. */
  15289. getInvertedAbsoluteTransform(): Matrix;
  15290. /**
  15291. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15292. * @returns a matrix
  15293. */
  15294. getAbsoluteTransform(): Matrix;
  15295. /**
  15296. * Links with the given transform node.
  15297. * The local matrix of this bone is copied from the transform node every frame.
  15298. * @param transformNode defines the transform node to link to
  15299. */
  15300. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15301. /**
  15302. * Gets the node used to drive the bone's transformation
  15303. * @returns a transform node or null
  15304. */
  15305. getTransformNode(): Nullable<TransformNode>;
  15306. /** Gets or sets current position (in local space) */
  15307. get position(): Vector3;
  15308. set position(newPosition: Vector3);
  15309. /** Gets or sets current rotation (in local space) */
  15310. get rotation(): Vector3;
  15311. set rotation(newRotation: Vector3);
  15312. /** Gets or sets current rotation quaternion (in local space) */
  15313. get rotationQuaternion(): Quaternion;
  15314. set rotationQuaternion(newRotation: Quaternion);
  15315. /** Gets or sets current scaling (in local space) */
  15316. get scaling(): Vector3;
  15317. set scaling(newScaling: Vector3);
  15318. /**
  15319. * Gets the animation properties override
  15320. */
  15321. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15322. private _decompose;
  15323. private _compose;
  15324. /**
  15325. * Update the base and local matrices
  15326. * @param matrix defines the new base or local matrix
  15327. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15328. * @param updateLocalMatrix defines if the local matrix should be updated
  15329. */
  15330. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15331. /** @hidden */
  15332. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15333. /**
  15334. * Flag the bone as dirty (Forcing it to update everything)
  15335. */
  15336. markAsDirty(): void;
  15337. /** @hidden */
  15338. _markAsDirtyAndCompose(): void;
  15339. private _markAsDirtyAndDecompose;
  15340. /**
  15341. * Translate the bone in local or world space
  15342. * @param vec The amount to translate the bone
  15343. * @param space The space that the translation is in
  15344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15345. */
  15346. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15347. /**
  15348. * Set the postion of the bone in local or world space
  15349. * @param position The position to set the bone
  15350. * @param space The space that the position is in
  15351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15352. */
  15353. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15354. /**
  15355. * Set the absolute position of the bone (world space)
  15356. * @param position The position to set the bone
  15357. * @param mesh The mesh that this bone is attached to
  15358. */
  15359. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15360. /**
  15361. * Scale the bone on the x, y and z axes (in local space)
  15362. * @param x The amount to scale the bone on the x axis
  15363. * @param y The amount to scale the bone on the y axis
  15364. * @param z The amount to scale the bone on the z axis
  15365. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15366. */
  15367. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15368. /**
  15369. * Set the bone scaling in local space
  15370. * @param scale defines the scaling vector
  15371. */
  15372. setScale(scale: Vector3): void;
  15373. /**
  15374. * Gets the current scaling in local space
  15375. * @returns the current scaling vector
  15376. */
  15377. getScale(): Vector3;
  15378. /**
  15379. * Gets the current scaling in local space and stores it in a target vector
  15380. * @param result defines the target vector
  15381. */
  15382. getScaleToRef(result: Vector3): void;
  15383. /**
  15384. * Set the yaw, pitch, and roll of the bone in local or world space
  15385. * @param yaw The rotation of the bone on the y axis
  15386. * @param pitch The rotation of the bone on the x axis
  15387. * @param roll The rotation of the bone on the z axis
  15388. * @param space The space that the axes of rotation are in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. */
  15391. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15392. /**
  15393. * Add a rotation to the bone on an axis in local or world space
  15394. * @param axis The axis to rotate the bone on
  15395. * @param amount The amount to rotate the bone
  15396. * @param space The space that the axis is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. */
  15399. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15400. /**
  15401. * Set the rotation of the bone to a particular axis angle in local or world space
  15402. * @param axis The axis to rotate the bone on
  15403. * @param angle The angle that the bone should be rotated to
  15404. * @param space The space that the axis is in
  15405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15406. */
  15407. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15408. /**
  15409. * Set the euler rotation of the bone in local or world space
  15410. * @param rotation The euler rotation that the bone should be set to
  15411. * @param space The space that the rotation is in
  15412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15413. */
  15414. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15415. /**
  15416. * Set the quaternion rotation of the bone in local or world space
  15417. * @param quat The quaternion rotation that the bone should be set to
  15418. * @param space The space that the rotation is in
  15419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15420. */
  15421. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15422. /**
  15423. * Set the rotation matrix of the bone in local or world space
  15424. * @param rotMat The rotation matrix that the bone should be set to
  15425. * @param space The space that the rotation is in
  15426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15427. */
  15428. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15429. private _rotateWithMatrix;
  15430. private _getNegativeRotationToRef;
  15431. /**
  15432. * Get the position of the bone in local or world space
  15433. * @param space The space that the returned position is in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The position of the bone
  15436. */
  15437. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the position of the bone to a vector3 in local or world space
  15440. * @param space The space that the returned position is in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 to copy the position to
  15443. */
  15444. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15445. /**
  15446. * Get the absolute position of the bone (world space)
  15447. * @param mesh The mesh that this bone is attached to
  15448. * @returns The absolute position of the bone
  15449. */
  15450. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15451. /**
  15452. * Copy the absolute position of the bone (world space) to the result param
  15453. * @param mesh The mesh that this bone is attached to
  15454. * @param result The vector3 to copy the absolute position to
  15455. */
  15456. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15457. /**
  15458. * Compute the absolute transforms of this bone and its children
  15459. */
  15460. computeAbsoluteTransforms(): void;
  15461. /**
  15462. * Get the world direction from an axis that is in the local space of the bone
  15463. * @param localAxis The local direction that is used to compute the world direction
  15464. * @param mesh The mesh that this bone is attached to
  15465. * @returns The world direction
  15466. */
  15467. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15468. /**
  15469. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15470. * @param localAxis The local direction that is used to compute the world direction
  15471. * @param mesh The mesh that this bone is attached to
  15472. * @param result The vector3 that the world direction will be copied to
  15473. */
  15474. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15475. /**
  15476. * Get the euler rotation of the bone in local or world space
  15477. * @param space The space that the rotation should be in
  15478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15479. * @returns The euler rotation
  15480. */
  15481. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15482. /**
  15483. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15484. * @param space The space that the rotation should be in
  15485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15486. * @param result The vector3 that the rotation should be copied to
  15487. */
  15488. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15489. /**
  15490. * Get the quaternion rotation of the bone in either local or world space
  15491. * @param space The space that the rotation should be in
  15492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15493. * @returns The quaternion rotation
  15494. */
  15495. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15496. /**
  15497. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15498. * @param space The space that the rotation should be in
  15499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15500. * @param result The quaternion that the rotation should be copied to
  15501. */
  15502. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15503. /**
  15504. * Get the rotation matrix of the bone in local or world space
  15505. * @param space The space that the rotation should be in
  15506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15507. * @returns The rotation matrix
  15508. */
  15509. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15510. /**
  15511. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15512. * @param space The space that the rotation should be in
  15513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15514. * @param result The quaternion that the rotation should be copied to
  15515. */
  15516. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15517. /**
  15518. * Get the world position of a point that is in the local space of the bone
  15519. * @param position The local position
  15520. * @param mesh The mesh that this bone is attached to
  15521. * @returns The world position
  15522. */
  15523. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15524. /**
  15525. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15526. * @param position The local position
  15527. * @param mesh The mesh that this bone is attached to
  15528. * @param result The vector3 that the world position should be copied to
  15529. */
  15530. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15531. /**
  15532. * Get the local position of a point that is in world space
  15533. * @param position The world position
  15534. * @param mesh The mesh that this bone is attached to
  15535. * @returns The local position
  15536. */
  15537. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15538. /**
  15539. * Get the local position of a point that is in world space and copy it to the result param
  15540. * @param position The world position
  15541. * @param mesh The mesh that this bone is attached to
  15542. * @param result The vector3 that the local position should be copied to
  15543. */
  15544. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15545. /**
  15546. * Set the current local matrix as the restPose for this bone.
  15547. */
  15548. setCurrentPoseAsRest(): void;
  15549. }
  15550. }
  15551. declare module BABYLON {
  15552. /**
  15553. * Defines a runtime animation
  15554. */
  15555. export class RuntimeAnimation {
  15556. private _events;
  15557. /**
  15558. * The current frame of the runtime animation
  15559. */
  15560. private _currentFrame;
  15561. /**
  15562. * The animation used by the runtime animation
  15563. */
  15564. private _animation;
  15565. /**
  15566. * The target of the runtime animation
  15567. */
  15568. private _target;
  15569. /**
  15570. * The initiating animatable
  15571. */
  15572. private _host;
  15573. /**
  15574. * The original value of the runtime animation
  15575. */
  15576. private _originalValue;
  15577. /**
  15578. * The original blend value of the runtime animation
  15579. */
  15580. private _originalBlendValue;
  15581. /**
  15582. * The offsets cache of the runtime animation
  15583. */
  15584. private _offsetsCache;
  15585. /**
  15586. * The high limits cache of the runtime animation
  15587. */
  15588. private _highLimitsCache;
  15589. /**
  15590. * Specifies if the runtime animation has been stopped
  15591. */
  15592. private _stopped;
  15593. /**
  15594. * The blending factor of the runtime animation
  15595. */
  15596. private _blendingFactor;
  15597. /**
  15598. * The BabylonJS scene
  15599. */
  15600. private _scene;
  15601. /**
  15602. * The current value of the runtime animation
  15603. */
  15604. private _currentValue;
  15605. /** @hidden */
  15606. _animationState: _IAnimationState;
  15607. /**
  15608. * The active target of the runtime animation
  15609. */
  15610. private _activeTargets;
  15611. private _currentActiveTarget;
  15612. private _directTarget;
  15613. /**
  15614. * The target path of the runtime animation
  15615. */
  15616. private _targetPath;
  15617. /**
  15618. * The weight of the runtime animation
  15619. */
  15620. private _weight;
  15621. /**
  15622. * The ratio offset of the runtime animation
  15623. */
  15624. private _ratioOffset;
  15625. /**
  15626. * The previous delay of the runtime animation
  15627. */
  15628. private _previousDelay;
  15629. /**
  15630. * The previous ratio of the runtime animation
  15631. */
  15632. private _previousRatio;
  15633. private _enableBlending;
  15634. private _keys;
  15635. private _minFrame;
  15636. private _maxFrame;
  15637. private _minValue;
  15638. private _maxValue;
  15639. private _targetIsArray;
  15640. /**
  15641. * Gets the current frame of the runtime animation
  15642. */
  15643. get currentFrame(): number;
  15644. /**
  15645. * Gets the weight of the runtime animation
  15646. */
  15647. get weight(): number;
  15648. /**
  15649. * Gets the current value of the runtime animation
  15650. */
  15651. get currentValue(): any;
  15652. /**
  15653. * Gets the target path of the runtime animation
  15654. */
  15655. get targetPath(): string;
  15656. /**
  15657. * Gets the actual target of the runtime animation
  15658. */
  15659. get target(): any;
  15660. /**
  15661. * Gets the additive state of the runtime animation
  15662. */
  15663. get isAdditive(): boolean;
  15664. /** @hidden */
  15665. _onLoop: () => void;
  15666. /**
  15667. * Create a new RuntimeAnimation object
  15668. * @param target defines the target of the animation
  15669. * @param animation defines the source animation object
  15670. * @param scene defines the hosting scene
  15671. * @param host defines the initiating Animatable
  15672. */
  15673. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15674. private _preparePath;
  15675. /**
  15676. * Gets the animation from the runtime animation
  15677. */
  15678. get animation(): Animation;
  15679. /**
  15680. * Resets the runtime animation to the beginning
  15681. * @param restoreOriginal defines whether to restore the target property to the original value
  15682. */
  15683. reset(restoreOriginal?: boolean): void;
  15684. /**
  15685. * Specifies if the runtime animation is stopped
  15686. * @returns Boolean specifying if the runtime animation is stopped
  15687. */
  15688. isStopped(): boolean;
  15689. /**
  15690. * Disposes of the runtime animation
  15691. */
  15692. dispose(): void;
  15693. /**
  15694. * Apply the interpolated value to the target
  15695. * @param currentValue defines the value computed by the animation
  15696. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15697. */
  15698. setValue(currentValue: any, weight: number): void;
  15699. private _getOriginalValues;
  15700. private _setValue;
  15701. /**
  15702. * Gets the loop pmode of the runtime animation
  15703. * @returns Loop Mode
  15704. */
  15705. private _getCorrectLoopMode;
  15706. /**
  15707. * Move the current animation to a given frame
  15708. * @param frame defines the frame to move to
  15709. */
  15710. goToFrame(frame: number): void;
  15711. /**
  15712. * @hidden Internal use only
  15713. */
  15714. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15715. /**
  15716. * Execute the current animation
  15717. * @param delay defines the delay to add to the current frame
  15718. * @param from defines the lower bound of the animation range
  15719. * @param to defines the upper bound of the animation range
  15720. * @param loop defines if the current animation must loop
  15721. * @param speedRatio defines the current speed ratio
  15722. * @param weight defines the weight of the animation (default is -1 so no weight)
  15723. * @param onLoop optional callback called when animation loops
  15724. * @returns a boolean indicating if the animation is running
  15725. */
  15726. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15727. }
  15728. }
  15729. declare module BABYLON {
  15730. /**
  15731. * Class used to store an actual running animation
  15732. */
  15733. export class Animatable {
  15734. /** defines the target object */
  15735. target: any;
  15736. /** defines the starting frame number (default is 0) */
  15737. fromFrame: number;
  15738. /** defines the ending frame number (default is 100) */
  15739. toFrame: number;
  15740. /** defines if the animation must loop (default is false) */
  15741. loopAnimation: boolean;
  15742. /** defines a callback to call when animation ends if it is not looping */
  15743. onAnimationEnd?: (() => void) | null | undefined;
  15744. /** defines a callback to call when animation loops */
  15745. onAnimationLoop?: (() => void) | null | undefined;
  15746. /** defines whether the animation should be evaluated additively */
  15747. isAdditive: boolean;
  15748. private _localDelayOffset;
  15749. private _pausedDelay;
  15750. private _runtimeAnimations;
  15751. private _paused;
  15752. private _scene;
  15753. private _speedRatio;
  15754. private _weight;
  15755. private _syncRoot;
  15756. /**
  15757. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15758. * This will only apply for non looping animation (default is true)
  15759. */
  15760. disposeOnEnd: boolean;
  15761. /**
  15762. * Gets a boolean indicating if the animation has started
  15763. */
  15764. animationStarted: boolean;
  15765. /**
  15766. * Observer raised when the animation ends
  15767. */
  15768. onAnimationEndObservable: Observable<Animatable>;
  15769. /**
  15770. * Observer raised when the animation loops
  15771. */
  15772. onAnimationLoopObservable: Observable<Animatable>;
  15773. /**
  15774. * Gets the root Animatable used to synchronize and normalize animations
  15775. */
  15776. get syncRoot(): Nullable<Animatable>;
  15777. /**
  15778. * Gets the current frame of the first RuntimeAnimation
  15779. * Used to synchronize Animatables
  15780. */
  15781. get masterFrame(): number;
  15782. /**
  15783. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15784. */
  15785. get weight(): number;
  15786. set weight(value: number);
  15787. /**
  15788. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15789. */
  15790. get speedRatio(): number;
  15791. set speedRatio(value: number);
  15792. /**
  15793. * Creates a new Animatable
  15794. * @param scene defines the hosting scene
  15795. * @param target defines the target object
  15796. * @param fromFrame defines the starting frame number (default is 0)
  15797. * @param toFrame defines the ending frame number (default is 100)
  15798. * @param loopAnimation defines if the animation must loop (default is false)
  15799. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15800. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15801. * @param animations defines a group of animation to add to the new Animatable
  15802. * @param onAnimationLoop defines a callback to call when animation loops
  15803. * @param isAdditive defines whether the animation should be evaluated additively
  15804. */
  15805. constructor(scene: Scene,
  15806. /** defines the target object */
  15807. target: any,
  15808. /** defines the starting frame number (default is 0) */
  15809. fromFrame?: number,
  15810. /** defines the ending frame number (default is 100) */
  15811. toFrame?: number,
  15812. /** defines if the animation must loop (default is false) */
  15813. loopAnimation?: boolean, speedRatio?: number,
  15814. /** defines a callback to call when animation ends if it is not looping */
  15815. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15816. /** defines a callback to call when animation loops */
  15817. onAnimationLoop?: (() => void) | null | undefined,
  15818. /** defines whether the animation should be evaluated additively */
  15819. isAdditive?: boolean);
  15820. /**
  15821. * Synchronize and normalize current Animatable with a source Animatable
  15822. * This is useful when using animation weights and when animations are not of the same length
  15823. * @param root defines the root Animatable to synchronize with
  15824. * @returns the current Animatable
  15825. */
  15826. syncWith(root: Animatable): Animatable;
  15827. /**
  15828. * Gets the list of runtime animations
  15829. * @returns an array of RuntimeAnimation
  15830. */
  15831. getAnimations(): RuntimeAnimation[];
  15832. /**
  15833. * Adds more animations to the current animatable
  15834. * @param target defines the target of the animations
  15835. * @param animations defines the new animations to add
  15836. */
  15837. appendAnimations(target: any, animations: Animation[]): void;
  15838. /**
  15839. * Gets the source animation for a specific property
  15840. * @param property defines the propertyu to look for
  15841. * @returns null or the source animation for the given property
  15842. */
  15843. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15844. /**
  15845. * Gets the runtime animation for a specific property
  15846. * @param property defines the propertyu to look for
  15847. * @returns null or the runtime animation for the given property
  15848. */
  15849. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15850. /**
  15851. * Resets the animatable to its original state
  15852. */
  15853. reset(): void;
  15854. /**
  15855. * Allows the animatable to blend with current running animations
  15856. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15857. * @param blendingSpeed defines the blending speed to use
  15858. */
  15859. enableBlending(blendingSpeed: number): void;
  15860. /**
  15861. * Disable animation blending
  15862. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15863. */
  15864. disableBlending(): void;
  15865. /**
  15866. * Jump directly to a given frame
  15867. * @param frame defines the frame to jump to
  15868. */
  15869. goToFrame(frame: number): void;
  15870. /**
  15871. * Pause the animation
  15872. */
  15873. pause(): void;
  15874. /**
  15875. * Restart the animation
  15876. */
  15877. restart(): void;
  15878. private _raiseOnAnimationEnd;
  15879. /**
  15880. * Stop and delete the current animation
  15881. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15882. * @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)
  15883. */
  15884. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15885. /**
  15886. * Wait asynchronously for the animation to end
  15887. * @returns a promise which will be fullfilled when the animation ends
  15888. */
  15889. waitAsync(): Promise<Animatable>;
  15890. /** @hidden */
  15891. _animate(delay: number): boolean;
  15892. }
  15893. interface Scene {
  15894. /** @hidden */
  15895. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15896. /** @hidden */
  15897. _processLateAnimationBindingsForMatrices(holder: {
  15898. totalWeight: number;
  15899. totalAdditiveWeight: number;
  15900. animations: RuntimeAnimation[];
  15901. additiveAnimations: RuntimeAnimation[];
  15902. originalValue: Matrix;
  15903. }): any;
  15904. /** @hidden */
  15905. _processLateAnimationBindingsForQuaternions(holder: {
  15906. totalWeight: number;
  15907. totalAdditiveWeight: number;
  15908. animations: RuntimeAnimation[];
  15909. additiveAnimations: RuntimeAnimation[];
  15910. originalValue: Quaternion;
  15911. }, refQuaternion: Quaternion): Quaternion;
  15912. /** @hidden */
  15913. _processLateAnimationBindings(): void;
  15914. /**
  15915. * Will start the animation sequence of a given target
  15916. * @param target defines the target
  15917. * @param from defines from which frame should animation start
  15918. * @param to defines until which frame should animation run.
  15919. * @param weight defines the weight to apply to the animation (1.0 by default)
  15920. * @param loop defines if the animation loops
  15921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15922. * @param onAnimationEnd defines the function to be executed when the animation ends
  15923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15924. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15925. * @param onAnimationLoop defines the callback to call when an animation loops
  15926. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15927. * @returns the animatable object created for this animation
  15928. */
  15929. 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;
  15930. /**
  15931. * Will start the animation sequence of a given target
  15932. * @param target defines the target
  15933. * @param from defines from which frame should animation start
  15934. * @param to defines until which frame should animation run.
  15935. * @param loop defines if the animation loops
  15936. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15937. * @param onAnimationEnd defines the function to be executed when the animation ends
  15938. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15939. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15940. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15941. * @param onAnimationLoop defines the callback to call when an animation loops
  15942. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15943. * @returns the animatable object created for this animation
  15944. */
  15945. 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;
  15946. /**
  15947. * Will start the animation sequence of a given target and its hierarchy
  15948. * @param target defines the target
  15949. * @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.
  15950. * @param from defines from which frame should animation start
  15951. * @param to defines until which frame should animation run.
  15952. * @param loop defines if the animation loops
  15953. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15954. * @param onAnimationEnd defines the function to be executed when the animation ends
  15955. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15956. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15957. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15958. * @param onAnimationLoop defines the callback to call when an animation loops
  15959. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15960. * @returns the list of created animatables
  15961. */
  15962. 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[];
  15963. /**
  15964. * Begin a new animation on a given node
  15965. * @param target defines the target where the animation will take place
  15966. * @param animations defines the list of animations to start
  15967. * @param from defines the initial value
  15968. * @param to defines the final value
  15969. * @param loop defines if you want animation to loop (off by default)
  15970. * @param speedRatio defines the speed ratio to apply to all animations
  15971. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15972. * @param onAnimationLoop defines the callback to call when an animation loops
  15973. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15974. * @returns the list of created animatables
  15975. */
  15976. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15977. /**
  15978. * Begin a new animation on a given node and its hierarchy
  15979. * @param target defines the root node where the animation will take place
  15980. * @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.
  15981. * @param animations defines the list of animations to start
  15982. * @param from defines the initial value
  15983. * @param to defines the final value
  15984. * @param loop defines if you want animation to loop (off by default)
  15985. * @param speedRatio defines the speed ratio to apply to all animations
  15986. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15987. * @param onAnimationLoop defines the callback to call when an animation loops
  15988. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15989. * @returns the list of animatables created for all nodes
  15990. */
  15991. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15992. /**
  15993. * Gets the animatable associated with a specific target
  15994. * @param target defines the target of the animatable
  15995. * @returns the required animatable if found
  15996. */
  15997. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15998. /**
  15999. * Gets all animatables associated with a given target
  16000. * @param target defines the target to look animatables for
  16001. * @returns an array of Animatables
  16002. */
  16003. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16004. /**
  16005. * Stops and removes all animations that have been applied to the scene
  16006. */
  16007. stopAllAnimations(): void;
  16008. /**
  16009. * Gets the current delta time used by animation engine
  16010. */
  16011. deltaTime: number;
  16012. }
  16013. interface Bone {
  16014. /**
  16015. * Copy an animation range from another bone
  16016. * @param source defines the source bone
  16017. * @param rangeName defines the range name to copy
  16018. * @param frameOffset defines the frame offset
  16019. * @param rescaleAsRequired defines if rescaling must be applied if required
  16020. * @param skelDimensionsRatio defines the scaling ratio
  16021. * @returns true if operation was successful
  16022. */
  16023. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16024. }
  16025. }
  16026. declare module BABYLON {
  16027. /**
  16028. * Class used to handle skinning animations
  16029. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16030. */
  16031. export class Skeleton implements IAnimatable {
  16032. /** defines the skeleton name */
  16033. name: string;
  16034. /** defines the skeleton Id */
  16035. id: string;
  16036. /**
  16037. * Defines the list of child bones
  16038. */
  16039. bones: Bone[];
  16040. /**
  16041. * Defines an estimate of the dimension of the skeleton at rest
  16042. */
  16043. dimensionsAtRest: Vector3;
  16044. /**
  16045. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16046. */
  16047. needInitialSkinMatrix: boolean;
  16048. /**
  16049. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16050. */
  16051. overrideMesh: Nullable<AbstractMesh>;
  16052. /**
  16053. * Gets the list of animations attached to this skeleton
  16054. */
  16055. animations: Array<Animation>;
  16056. private _scene;
  16057. private _isDirty;
  16058. private _transformMatrices;
  16059. private _transformMatrixTexture;
  16060. private _meshesWithPoseMatrix;
  16061. private _animatables;
  16062. private _identity;
  16063. private _synchronizedWithMesh;
  16064. private _ranges;
  16065. private _lastAbsoluteTransformsUpdateId;
  16066. private _canUseTextureForBones;
  16067. private _uniqueId;
  16068. /** @hidden */
  16069. _numBonesWithLinkedTransformNode: number;
  16070. /** @hidden */
  16071. _hasWaitingData: Nullable<boolean>;
  16072. /** @hidden */
  16073. _waitingOverrideMeshId: Nullable<string>;
  16074. /**
  16075. * Specifies if the skeleton should be serialized
  16076. */
  16077. doNotSerialize: boolean;
  16078. private _useTextureToStoreBoneMatrices;
  16079. /**
  16080. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16081. * Please note that this option is not available if the hardware does not support it
  16082. */
  16083. get useTextureToStoreBoneMatrices(): boolean;
  16084. set useTextureToStoreBoneMatrices(value: boolean);
  16085. private _animationPropertiesOverride;
  16086. /**
  16087. * Gets or sets the animation properties override
  16088. */
  16089. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16090. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16091. /**
  16092. * List of inspectable custom properties (used by the Inspector)
  16093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16094. */
  16095. inspectableCustomProperties: IInspectable[];
  16096. /**
  16097. * An observable triggered before computing the skeleton's matrices
  16098. */
  16099. onBeforeComputeObservable: Observable<Skeleton>;
  16100. /**
  16101. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16102. */
  16103. get isUsingTextureForMatrices(): boolean;
  16104. /**
  16105. * Gets the unique ID of this skeleton
  16106. */
  16107. get uniqueId(): number;
  16108. /**
  16109. * Creates a new skeleton
  16110. * @param name defines the skeleton name
  16111. * @param id defines the skeleton Id
  16112. * @param scene defines the hosting scene
  16113. */
  16114. constructor(
  16115. /** defines the skeleton name */
  16116. name: string,
  16117. /** defines the skeleton Id */
  16118. id: string, scene: Scene);
  16119. /**
  16120. * Gets the current object class name.
  16121. * @return the class name
  16122. */
  16123. getClassName(): string;
  16124. /**
  16125. * Returns an array containing the root bones
  16126. * @returns an array containing the root bones
  16127. */
  16128. getChildren(): Array<Bone>;
  16129. /**
  16130. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16131. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16132. * @returns a Float32Array containing matrices data
  16133. */
  16134. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16135. /**
  16136. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16137. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16138. * @returns a raw texture containing the data
  16139. */
  16140. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16141. /**
  16142. * Gets the current hosting scene
  16143. * @returns a scene object
  16144. */
  16145. getScene(): Scene;
  16146. /**
  16147. * Gets a string representing the current skeleton data
  16148. * @param fullDetails defines a boolean indicating if we want a verbose version
  16149. * @returns a string representing the current skeleton data
  16150. */
  16151. toString(fullDetails?: boolean): string;
  16152. /**
  16153. * Get bone's index searching by name
  16154. * @param name defines bone's name to search for
  16155. * @return the indice of the bone. Returns -1 if not found
  16156. */
  16157. getBoneIndexByName(name: string): number;
  16158. /**
  16159. * Creater a new animation range
  16160. * @param name defines the name of the range
  16161. * @param from defines the start key
  16162. * @param to defines the end key
  16163. */
  16164. createAnimationRange(name: string, from: number, to: number): void;
  16165. /**
  16166. * Delete a specific animation range
  16167. * @param name defines the name of the range
  16168. * @param deleteFrames defines if frames must be removed as well
  16169. */
  16170. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16171. /**
  16172. * Gets a specific animation range
  16173. * @param name defines the name of the range to look for
  16174. * @returns the requested animation range or null if not found
  16175. */
  16176. getAnimationRange(name: string): Nullable<AnimationRange>;
  16177. /**
  16178. * Gets the list of all animation ranges defined on this skeleton
  16179. * @returns an array
  16180. */
  16181. getAnimationRanges(): Nullable<AnimationRange>[];
  16182. /**
  16183. * Copy animation range from a source skeleton.
  16184. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16185. * @param source defines the source skeleton
  16186. * @param name defines the name of the range to copy
  16187. * @param rescaleAsRequired defines if rescaling must be applied if required
  16188. * @returns true if operation was successful
  16189. */
  16190. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16191. /**
  16192. * Forces the skeleton to go to rest pose
  16193. */
  16194. returnToRest(): void;
  16195. private _getHighestAnimationFrame;
  16196. /**
  16197. * Begin a specific animation range
  16198. * @param name defines the name of the range to start
  16199. * @param loop defines if looping must be turned on (false by default)
  16200. * @param speedRatio defines the speed ratio to apply (1 by default)
  16201. * @param onAnimationEnd defines a callback which will be called when animation will end
  16202. * @returns a new animatable
  16203. */
  16204. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16205. /**
  16206. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16207. * @param skeleton defines the Skeleton containing the animation range to convert
  16208. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16209. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16210. * @returns the original skeleton
  16211. */
  16212. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16213. /** @hidden */
  16214. _markAsDirty(): void;
  16215. /** @hidden */
  16216. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16217. /** @hidden */
  16218. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16219. private _computeTransformMatrices;
  16220. /**
  16221. * Build all resources required to render a skeleton
  16222. */
  16223. prepare(): void;
  16224. /**
  16225. * Gets the list of animatables currently running for this skeleton
  16226. * @returns an array of animatables
  16227. */
  16228. getAnimatables(): IAnimatable[];
  16229. /**
  16230. * Clone the current skeleton
  16231. * @param name defines the name of the new skeleton
  16232. * @param id defines the id of the new skeleton
  16233. * @returns the new skeleton
  16234. */
  16235. clone(name: string, id?: string): Skeleton;
  16236. /**
  16237. * Enable animation blending for this skeleton
  16238. * @param blendingSpeed defines the blending speed to apply
  16239. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16240. */
  16241. enableBlending(blendingSpeed?: number): void;
  16242. /**
  16243. * Releases all resources associated with the current skeleton
  16244. */
  16245. dispose(): void;
  16246. /**
  16247. * Serialize the skeleton in a JSON object
  16248. * @returns a JSON object
  16249. */
  16250. serialize(): any;
  16251. /**
  16252. * Creates a new skeleton from serialized data
  16253. * @param parsedSkeleton defines the serialized data
  16254. * @param scene defines the hosting scene
  16255. * @returns a new skeleton
  16256. */
  16257. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16258. /**
  16259. * Compute all node absolute transforms
  16260. * @param forceUpdate defines if computation must be done even if cache is up to date
  16261. */
  16262. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16263. /**
  16264. * Gets the root pose matrix
  16265. * @returns a matrix
  16266. */
  16267. getPoseMatrix(): Nullable<Matrix>;
  16268. /**
  16269. * Sorts bones per internal index
  16270. */
  16271. sortBones(): void;
  16272. private _sortBones;
  16273. /**
  16274. * Set the current local matrix as the restPose for all bones in the skeleton.
  16275. */
  16276. setCurrentPoseAsRest(): void;
  16277. }
  16278. }
  16279. declare module BABYLON {
  16280. /**
  16281. * Creates an instance based on a source mesh.
  16282. */
  16283. export class InstancedMesh extends AbstractMesh {
  16284. private _sourceMesh;
  16285. private _currentLOD;
  16286. /** @hidden */
  16287. _indexInSourceMeshInstanceArray: number;
  16288. constructor(name: string, source: Mesh);
  16289. /**
  16290. * Returns the string "InstancedMesh".
  16291. */
  16292. getClassName(): string;
  16293. /** Gets the list of lights affecting that mesh */
  16294. get lightSources(): Light[];
  16295. _resyncLightSources(): void;
  16296. _resyncLightSource(light: Light): void;
  16297. _removeLightSource(light: Light, dispose: boolean): void;
  16298. /**
  16299. * If the source mesh receives shadows
  16300. */
  16301. get receiveShadows(): boolean;
  16302. /**
  16303. * The material of the source mesh
  16304. */
  16305. get material(): Nullable<Material>;
  16306. /**
  16307. * Visibility of the source mesh
  16308. */
  16309. get visibility(): number;
  16310. /**
  16311. * Skeleton of the source mesh
  16312. */
  16313. get skeleton(): Nullable<Skeleton>;
  16314. /**
  16315. * Rendering ground id of the source mesh
  16316. */
  16317. get renderingGroupId(): number;
  16318. set renderingGroupId(value: number);
  16319. /**
  16320. * Returns the total number of vertices (integer).
  16321. */
  16322. getTotalVertices(): number;
  16323. /**
  16324. * Returns a positive integer : the total number of indices in this mesh geometry.
  16325. * @returns the numner of indices or zero if the mesh has no geometry.
  16326. */
  16327. getTotalIndices(): number;
  16328. /**
  16329. * The source mesh of the instance
  16330. */
  16331. get sourceMesh(): Mesh;
  16332. /**
  16333. * Creates a new InstancedMesh object from the mesh model.
  16334. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16335. * @param name defines the name of the new instance
  16336. * @returns a new InstancedMesh
  16337. */
  16338. createInstance(name: string): InstancedMesh;
  16339. /**
  16340. * Is this node ready to be used/rendered
  16341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16342. * @return {boolean} is it ready
  16343. */
  16344. isReady(completeCheck?: boolean): boolean;
  16345. /**
  16346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16348. * @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.
  16349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16350. */
  16351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16352. /**
  16353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16355. * The `data` are either a numeric array either a Float32Array.
  16356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16357. * 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).
  16358. * Note that a new underlying VertexBuffer object is created each call.
  16359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16360. *
  16361. * Possible `kind` values :
  16362. * - VertexBuffer.PositionKind
  16363. * - VertexBuffer.UVKind
  16364. * - VertexBuffer.UV2Kind
  16365. * - VertexBuffer.UV3Kind
  16366. * - VertexBuffer.UV4Kind
  16367. * - VertexBuffer.UV5Kind
  16368. * - VertexBuffer.UV6Kind
  16369. * - VertexBuffer.ColorKind
  16370. * - VertexBuffer.MatricesIndicesKind
  16371. * - VertexBuffer.MatricesIndicesExtraKind
  16372. * - VertexBuffer.MatricesWeightsKind
  16373. * - VertexBuffer.MatricesWeightsExtraKind
  16374. *
  16375. * Returns the Mesh.
  16376. */
  16377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16378. /**
  16379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16380. * If the mesh has no geometry, it is simply returned as it is.
  16381. * The `data` are either a numeric array either a Float32Array.
  16382. * No new underlying VertexBuffer object is created.
  16383. * 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.
  16384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16385. *
  16386. * Possible `kind` values :
  16387. * - VertexBuffer.PositionKind
  16388. * - VertexBuffer.UVKind
  16389. * - VertexBuffer.UV2Kind
  16390. * - VertexBuffer.UV3Kind
  16391. * - VertexBuffer.UV4Kind
  16392. * - VertexBuffer.UV5Kind
  16393. * - VertexBuffer.UV6Kind
  16394. * - VertexBuffer.ColorKind
  16395. * - VertexBuffer.MatricesIndicesKind
  16396. * - VertexBuffer.MatricesIndicesExtraKind
  16397. * - VertexBuffer.MatricesWeightsKind
  16398. * - VertexBuffer.MatricesWeightsExtraKind
  16399. *
  16400. * Returns the Mesh.
  16401. */
  16402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16403. /**
  16404. * Sets the mesh indices.
  16405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16407. * This method creates a new index buffer each call.
  16408. * Returns the Mesh.
  16409. */
  16410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16411. /**
  16412. * Boolean : True if the mesh owns the requested kind of data.
  16413. */
  16414. isVerticesDataPresent(kind: string): boolean;
  16415. /**
  16416. * Returns an array of indices (IndicesArray).
  16417. */
  16418. getIndices(): Nullable<IndicesArray>;
  16419. get _positions(): Nullable<Vector3[]>;
  16420. /**
  16421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16422. * This means the mesh underlying bounding box and sphere are recomputed.
  16423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16424. * @returns the current mesh
  16425. */
  16426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16427. /** @hidden */
  16428. _preActivate(): InstancedMesh;
  16429. /** @hidden */
  16430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16431. /** @hidden */
  16432. _postActivate(): void;
  16433. getWorldMatrix(): Matrix;
  16434. get isAnInstance(): boolean;
  16435. /**
  16436. * Returns the current associated LOD AbstractMesh.
  16437. */
  16438. getLOD(camera: Camera): AbstractMesh;
  16439. /** @hidden */
  16440. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16441. /** @hidden */
  16442. _syncSubMeshes(): InstancedMesh;
  16443. /** @hidden */
  16444. _generatePointsArray(): boolean;
  16445. /** @hidden */
  16446. _updateBoundingInfo(): AbstractMesh;
  16447. /**
  16448. * Creates a new InstancedMesh from the current mesh.
  16449. * - name (string) : the cloned mesh name
  16450. * - newParent (optional Node) : the optional Node to parent the clone to.
  16451. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16452. *
  16453. * Returns the clone.
  16454. */
  16455. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16456. /**
  16457. * Disposes the InstancedMesh.
  16458. * Returns nothing.
  16459. */
  16460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16461. }
  16462. interface Mesh {
  16463. /**
  16464. * Register a custom buffer that will be instanced
  16465. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16466. * @param kind defines the buffer kind
  16467. * @param stride defines the stride in floats
  16468. */
  16469. registerInstancedBuffer(kind: string, stride: number): void;
  16470. /**
  16471. * true to use the edge renderer for all instances of this mesh
  16472. */
  16473. edgesShareWithInstances: boolean;
  16474. /** @hidden */
  16475. _userInstancedBuffersStorage: {
  16476. data: {
  16477. [key: string]: Float32Array;
  16478. };
  16479. sizes: {
  16480. [key: string]: number;
  16481. };
  16482. vertexBuffers: {
  16483. [key: string]: Nullable<VertexBuffer>;
  16484. };
  16485. strides: {
  16486. [key: string]: number;
  16487. };
  16488. };
  16489. }
  16490. interface AbstractMesh {
  16491. /**
  16492. * Object used to store instanced buffers defined by user
  16493. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16494. */
  16495. instancedBuffers: {
  16496. [key: string]: any;
  16497. };
  16498. }
  16499. }
  16500. declare module BABYLON {
  16501. /**
  16502. * Defines the options associated with the creation of a shader material.
  16503. */
  16504. export interface IShaderMaterialOptions {
  16505. /**
  16506. * Does the material work in alpha blend mode
  16507. */
  16508. needAlphaBlending: boolean;
  16509. /**
  16510. * Does the material work in alpha test mode
  16511. */
  16512. needAlphaTesting: boolean;
  16513. /**
  16514. * The list of attribute names used in the shader
  16515. */
  16516. attributes: string[];
  16517. /**
  16518. * The list of unifrom names used in the shader
  16519. */
  16520. uniforms: string[];
  16521. /**
  16522. * The list of UBO names used in the shader
  16523. */
  16524. uniformBuffers: string[];
  16525. /**
  16526. * The list of sampler names used in the shader
  16527. */
  16528. samplers: string[];
  16529. /**
  16530. * The list of defines used in the shader
  16531. */
  16532. defines: string[];
  16533. }
  16534. /**
  16535. * 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.
  16536. *
  16537. * This returned material effects how the mesh will look based on the code in the shaders.
  16538. *
  16539. * @see https://doc.babylonjs.com/how_to/shader_material
  16540. */
  16541. export class ShaderMaterial extends Material {
  16542. private _shaderPath;
  16543. private _options;
  16544. private _textures;
  16545. private _textureArrays;
  16546. private _floats;
  16547. private _ints;
  16548. private _floatsArrays;
  16549. private _colors3;
  16550. private _colors3Arrays;
  16551. private _colors4;
  16552. private _colors4Arrays;
  16553. private _vectors2;
  16554. private _vectors3;
  16555. private _vectors4;
  16556. private _matrices;
  16557. private _matrixArrays;
  16558. private _matrices3x3;
  16559. private _matrices2x2;
  16560. private _vectors2Arrays;
  16561. private _vectors3Arrays;
  16562. private _vectors4Arrays;
  16563. private _cachedWorldViewMatrix;
  16564. private _cachedWorldViewProjectionMatrix;
  16565. private _renderId;
  16566. private _multiview;
  16567. private _cachedDefines;
  16568. /** Define the Url to load snippets */
  16569. static SnippetUrl: string;
  16570. /** Snippet ID if the material was created from the snippet server */
  16571. snippetId: string;
  16572. /**
  16573. * Instantiate a new shader material.
  16574. * 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.
  16575. * This returned material effects how the mesh will look based on the code in the shaders.
  16576. * @see https://doc.babylonjs.com/how_to/shader_material
  16577. * @param name Define the name of the material in the scene
  16578. * @param scene Define the scene the material belongs to
  16579. * @param shaderPath Defines the route to the shader code in one of three ways:
  16580. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16581. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16582. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16583. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16584. * @param options Define the options used to create the shader
  16585. */
  16586. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16587. /**
  16588. * Gets the shader path used to define the shader code
  16589. * It can be modified to trigger a new compilation
  16590. */
  16591. get shaderPath(): any;
  16592. /**
  16593. * Sets the shader path used to define the shader code
  16594. * It can be modified to trigger a new compilation
  16595. */
  16596. set shaderPath(shaderPath: any);
  16597. /**
  16598. * Gets the options used to compile the shader.
  16599. * They can be modified to trigger a new compilation
  16600. */
  16601. get options(): IShaderMaterialOptions;
  16602. /**
  16603. * Gets the current class name of the material e.g. "ShaderMaterial"
  16604. * Mainly use in serialization.
  16605. * @returns the class name
  16606. */
  16607. getClassName(): string;
  16608. /**
  16609. * Specifies if the material will require alpha blending
  16610. * @returns a boolean specifying if alpha blending is needed
  16611. */
  16612. needAlphaBlending(): boolean;
  16613. /**
  16614. * Specifies if this material should be rendered in alpha test mode
  16615. * @returns a boolean specifying if an alpha test is needed.
  16616. */
  16617. needAlphaTesting(): boolean;
  16618. private _checkUniform;
  16619. /**
  16620. * Set a texture in the shader.
  16621. * @param name Define the name of the uniform samplers as defined in the shader
  16622. * @param texture Define the texture to bind to this sampler
  16623. * @return the material itself allowing "fluent" like uniform updates
  16624. */
  16625. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16626. /**
  16627. * Set a texture array in the shader.
  16628. * @param name Define the name of the uniform sampler array as defined in the shader
  16629. * @param textures Define the list of textures to bind to this sampler
  16630. * @return the material itself allowing "fluent" like uniform updates
  16631. */
  16632. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16633. /**
  16634. * Set a float in the shader.
  16635. * @param name Define the name of the uniform as defined in the shader
  16636. * @param value Define the value to give to the uniform
  16637. * @return the material itself allowing "fluent" like uniform updates
  16638. */
  16639. setFloat(name: string, value: number): ShaderMaterial;
  16640. /**
  16641. * Set a int in the shader.
  16642. * @param name Define the name of the uniform as defined in the shader
  16643. * @param value Define the value to give to the uniform
  16644. * @return the material itself allowing "fluent" like uniform updates
  16645. */
  16646. setInt(name: string, value: number): ShaderMaterial;
  16647. /**
  16648. * Set an array of floats in the shader.
  16649. * @param name Define the name of the uniform as defined in the shader
  16650. * @param value Define the value to give to the uniform
  16651. * @return the material itself allowing "fluent" like uniform updates
  16652. */
  16653. setFloats(name: string, value: number[]): ShaderMaterial;
  16654. /**
  16655. * Set a vec3 in the shader from a Color3.
  16656. * @param name Define the name of the uniform as defined in the shader
  16657. * @param value Define the value to give to the uniform
  16658. * @return the material itself allowing "fluent" like uniform updates
  16659. */
  16660. setColor3(name: string, value: Color3): ShaderMaterial;
  16661. /**
  16662. * Set a vec3 array in the shader from a Color3 array.
  16663. * @param name Define the name of the uniform as defined in the shader
  16664. * @param value Define the value to give to the uniform
  16665. * @return the material itself allowing "fluent" like uniform updates
  16666. */
  16667. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16668. /**
  16669. * Set a vec4 in the shader from a Color4.
  16670. * @param name Define the name of the uniform as defined in the shader
  16671. * @param value Define the value to give to the uniform
  16672. * @return the material itself allowing "fluent" like uniform updates
  16673. */
  16674. setColor4(name: string, value: Color4): ShaderMaterial;
  16675. /**
  16676. * Set a vec4 array in the shader from a Color4 array.
  16677. * @param name Define the name of the uniform as defined in the shader
  16678. * @param value Define the value to give to the uniform
  16679. * @return the material itself allowing "fluent" like uniform updates
  16680. */
  16681. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16682. /**
  16683. * Set a vec2 in the shader from a Vector2.
  16684. * @param name Define the name of the uniform as defined in the shader
  16685. * @param value Define the value to give to the uniform
  16686. * @return the material itself allowing "fluent" like uniform updates
  16687. */
  16688. setVector2(name: string, value: Vector2): ShaderMaterial;
  16689. /**
  16690. * Set a vec3 in the shader from a Vector3.
  16691. * @param name Define the name of the uniform as defined in the shader
  16692. * @param value Define the value to give to the uniform
  16693. * @return the material itself allowing "fluent" like uniform updates
  16694. */
  16695. setVector3(name: string, value: Vector3): ShaderMaterial;
  16696. /**
  16697. * Set a vec4 in the shader from a Vector4.
  16698. * @param name Define the name of the uniform as defined in the shader
  16699. * @param value Define the value to give to the uniform
  16700. * @return the material itself allowing "fluent" like uniform updates
  16701. */
  16702. setVector4(name: string, value: Vector4): ShaderMaterial;
  16703. /**
  16704. * Set a mat4 in the shader from a Matrix.
  16705. * @param name Define the name of the uniform as defined in the shader
  16706. * @param value Define the value to give to the uniform
  16707. * @return the material itself allowing "fluent" like uniform updates
  16708. */
  16709. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16710. /**
  16711. * Set a float32Array in the shader from a matrix array.
  16712. * @param name Define the name of the uniform as defined in the shader
  16713. * @param value Define the value to give to the uniform
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16717. /**
  16718. * Set a mat3 in the shader from a Float32Array.
  16719. * @param name Define the name of the uniform as defined in the shader
  16720. * @param value Define the value to give to the uniform
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16724. /**
  16725. * Set a mat2 in the shader from a Float32Array.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16731. /**
  16732. * Set a vec2 array in the shader from a number array.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setArray2(name: string, value: number[]): ShaderMaterial;
  16738. /**
  16739. * Set a vec3 array in the shader from a number array.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setArray3(name: string, value: number[]): ShaderMaterial;
  16745. /**
  16746. * Set a vec4 array in the shader from a number array.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setArray4(name: string, value: number[]): ShaderMaterial;
  16752. private _checkCache;
  16753. /**
  16754. * Specifies that the submesh is ready to be used
  16755. * @param mesh defines the mesh to check
  16756. * @param subMesh defines which submesh to check
  16757. * @param useInstances specifies that instances should be used
  16758. * @returns a boolean indicating that the submesh is ready or not
  16759. */
  16760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16761. /**
  16762. * Checks if the material is ready to render the requested mesh
  16763. * @param mesh Define the mesh to render
  16764. * @param useInstances Define whether or not the material is used with instances
  16765. * @returns true if ready, otherwise false
  16766. */
  16767. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16768. /**
  16769. * Binds the world matrix to the material
  16770. * @param world defines the world transformation matrix
  16771. * @param effectOverride - If provided, use this effect instead of internal effect
  16772. */
  16773. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16774. /**
  16775. * Binds the submesh to this material by preparing the effect and shader to draw
  16776. * @param world defines the world transformation matrix
  16777. * @param mesh defines the mesh containing the submesh
  16778. * @param subMesh defines the submesh to bind the material to
  16779. */
  16780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16781. /**
  16782. * Binds the material to the mesh
  16783. * @param world defines the world transformation matrix
  16784. * @param mesh defines the mesh to bind the material to
  16785. * @param effectOverride - If provided, use this effect instead of internal effect
  16786. */
  16787. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16788. protected _afterBind(mesh?: Mesh): void;
  16789. /**
  16790. * Gets the active textures from the material
  16791. * @returns an array of textures
  16792. */
  16793. getActiveTextures(): BaseTexture[];
  16794. /**
  16795. * Specifies if the material uses a texture
  16796. * @param texture defines the texture to check against the material
  16797. * @returns a boolean specifying if the material uses the texture
  16798. */
  16799. hasTexture(texture: BaseTexture): boolean;
  16800. /**
  16801. * Makes a duplicate of the material, and gives it a new name
  16802. * @param name defines the new name for the duplicated material
  16803. * @returns the cloned material
  16804. */
  16805. clone(name: string): ShaderMaterial;
  16806. /**
  16807. * Disposes the material
  16808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16810. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16811. */
  16812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16813. /**
  16814. * Serializes this material in a JSON representation
  16815. * @returns the serialized material object
  16816. */
  16817. serialize(): any;
  16818. /**
  16819. * Creates a shader material from parsed shader material data
  16820. * @param source defines the JSON represnetation of the material
  16821. * @param scene defines the hosting scene
  16822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16823. * @returns a new material
  16824. */
  16825. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16826. /**
  16827. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16828. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16829. * @param url defines the url to load from
  16830. * @param scene defines the hosting scene
  16831. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16832. * @returns a promise that will resolve to the new ShaderMaterial
  16833. */
  16834. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16835. /**
  16836. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16837. * @param snippetId defines the snippet to load
  16838. * @param scene defines the hosting scene
  16839. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16840. * @returns a promise that will resolve to the new ShaderMaterial
  16841. */
  16842. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16843. }
  16844. }
  16845. declare module BABYLON {
  16846. /** @hidden */
  16847. export var colorPixelShader: {
  16848. name: string;
  16849. shader: string;
  16850. };
  16851. }
  16852. declare module BABYLON {
  16853. /** @hidden */
  16854. export var colorVertexShader: {
  16855. name: string;
  16856. shader: string;
  16857. };
  16858. }
  16859. declare module BABYLON {
  16860. /**
  16861. * Line mesh
  16862. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16863. */
  16864. export class LinesMesh extends Mesh {
  16865. /**
  16866. * If vertex color should be applied to the mesh
  16867. */
  16868. readonly useVertexColor?: boolean | undefined;
  16869. /**
  16870. * If vertex alpha should be applied to the mesh
  16871. */
  16872. readonly useVertexAlpha?: boolean | undefined;
  16873. /**
  16874. * Color of the line (Default: White)
  16875. */
  16876. color: Color3;
  16877. /**
  16878. * Alpha of the line (Default: 1)
  16879. */
  16880. alpha: number;
  16881. /**
  16882. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16883. * This margin is expressed in world space coordinates, so its value may vary.
  16884. * Default value is 0.1
  16885. */
  16886. intersectionThreshold: number;
  16887. private _colorShader;
  16888. private color4;
  16889. /**
  16890. * Creates a new LinesMesh
  16891. * @param name defines the name
  16892. * @param scene defines the hosting scene
  16893. * @param parent defines the parent mesh if any
  16894. * @param source defines the optional source LinesMesh used to clone data from
  16895. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16896. * When false, achieved by calling a clone(), also passing False.
  16897. * This will make creation of children, recursive.
  16898. * @param useVertexColor defines if this LinesMesh supports vertex color
  16899. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16900. */
  16901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16902. /**
  16903. * If vertex color should be applied to the mesh
  16904. */
  16905. useVertexColor?: boolean | undefined,
  16906. /**
  16907. * If vertex alpha should be applied to the mesh
  16908. */
  16909. useVertexAlpha?: boolean | undefined);
  16910. private _addClipPlaneDefine;
  16911. private _removeClipPlaneDefine;
  16912. isReady(): boolean;
  16913. /**
  16914. * Returns the string "LineMesh"
  16915. */
  16916. getClassName(): string;
  16917. /**
  16918. * @hidden
  16919. */
  16920. get material(): Material;
  16921. /**
  16922. * @hidden
  16923. */
  16924. set material(value: Material);
  16925. /**
  16926. * @hidden
  16927. */
  16928. get checkCollisions(): boolean;
  16929. /** @hidden */
  16930. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16931. /** @hidden */
  16932. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16933. /**
  16934. * Disposes of the line mesh
  16935. * @param doNotRecurse If children should be disposed
  16936. */
  16937. dispose(doNotRecurse?: boolean): void;
  16938. /**
  16939. * Returns a new LineMesh object cloned from the current one.
  16940. */
  16941. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16942. /**
  16943. * Creates a new InstancedLinesMesh object from the mesh model.
  16944. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16945. * @param name defines the name of the new instance
  16946. * @returns a new InstancedLinesMesh
  16947. */
  16948. createInstance(name: string): InstancedLinesMesh;
  16949. }
  16950. /**
  16951. * Creates an instance based on a source LinesMesh
  16952. */
  16953. export class InstancedLinesMesh extends InstancedMesh {
  16954. /**
  16955. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16956. * This margin is expressed in world space coordinates, so its value may vary.
  16957. * Initilized with the intersectionThreshold value of the source LinesMesh
  16958. */
  16959. intersectionThreshold: number;
  16960. constructor(name: string, source: LinesMesh);
  16961. /**
  16962. * Returns the string "InstancedLinesMesh".
  16963. */
  16964. getClassName(): string;
  16965. }
  16966. }
  16967. declare module BABYLON {
  16968. /** @hidden */
  16969. export var linePixelShader: {
  16970. name: string;
  16971. shader: string;
  16972. };
  16973. }
  16974. declare module BABYLON {
  16975. /** @hidden */
  16976. export var lineVertexShader: {
  16977. name: string;
  16978. shader: string;
  16979. };
  16980. }
  16981. declare module BABYLON {
  16982. interface Scene {
  16983. /** @hidden */
  16984. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16985. }
  16986. interface AbstractMesh {
  16987. /**
  16988. * Gets the edgesRenderer associated with the mesh
  16989. */
  16990. edgesRenderer: Nullable<EdgesRenderer>;
  16991. }
  16992. interface LinesMesh {
  16993. /**
  16994. * Enables the edge rendering mode on the mesh.
  16995. * This mode makes the mesh edges visible
  16996. * @param epsilon defines the maximal distance between two angles to detect a face
  16997. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16998. * @returns the currentAbstractMesh
  16999. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17000. */
  17001. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17002. }
  17003. interface InstancedLinesMesh {
  17004. /**
  17005. * Enables the edge rendering mode on the mesh.
  17006. * This mode makes the mesh edges visible
  17007. * @param epsilon defines the maximal distance between two angles to detect a face
  17008. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17009. * @returns the current InstancedLinesMesh
  17010. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17011. */
  17012. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17013. }
  17014. /**
  17015. * Defines the minimum contract an Edges renderer should follow.
  17016. */
  17017. export interface IEdgesRenderer extends IDisposable {
  17018. /**
  17019. * Gets or sets a boolean indicating if the edgesRenderer is active
  17020. */
  17021. isEnabled: boolean;
  17022. /**
  17023. * Renders the edges of the attached mesh,
  17024. */
  17025. render(): void;
  17026. /**
  17027. * Checks wether or not the edges renderer is ready to render.
  17028. * @return true if ready, otherwise false.
  17029. */
  17030. isReady(): boolean;
  17031. /**
  17032. * List of instances to render in case the source mesh has instances
  17033. */
  17034. customInstances: SmartArray<Matrix>;
  17035. }
  17036. /**
  17037. * Defines the additional options of the edges renderer
  17038. */
  17039. export interface IEdgesRendererOptions {
  17040. /**
  17041. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17042. * If not defined, the default value is true
  17043. */
  17044. useAlternateEdgeFinder?: boolean;
  17045. /**
  17046. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17047. * If not defined, the default value is true.
  17048. * 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)
  17049. * This option is used only if useAlternateEdgeFinder = true
  17050. */
  17051. useFastVertexMerger?: boolean;
  17052. /**
  17053. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17054. * The default value is 1e-6
  17055. * This option is used only if useAlternateEdgeFinder = true
  17056. */
  17057. epsilonVertexMerge?: number;
  17058. /**
  17059. * 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
  17060. * 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.
  17061. * This option is used only if useAlternateEdgeFinder = true
  17062. */
  17063. applyTessellation?: boolean;
  17064. /**
  17065. * 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
  17066. * The default value is 1e-6
  17067. * This option is used only if useAlternateEdgeFinder = true
  17068. */
  17069. epsilonVertexAligned?: number;
  17070. }
  17071. /**
  17072. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17073. */
  17074. export class EdgesRenderer implements IEdgesRenderer {
  17075. /**
  17076. * Define the size of the edges with an orthographic camera
  17077. */
  17078. edgesWidthScalerForOrthographic: number;
  17079. /**
  17080. * Define the size of the edges with a perspective camera
  17081. */
  17082. edgesWidthScalerForPerspective: number;
  17083. protected _source: AbstractMesh;
  17084. protected _linesPositions: number[];
  17085. protected _linesNormals: number[];
  17086. protected _linesIndices: number[];
  17087. protected _epsilon: number;
  17088. protected _indicesCount: number;
  17089. protected _lineShader: ShaderMaterial;
  17090. protected _ib: DataBuffer;
  17091. protected _buffers: {
  17092. [key: string]: Nullable<VertexBuffer>;
  17093. };
  17094. protected _buffersForInstances: {
  17095. [key: string]: Nullable<VertexBuffer>;
  17096. };
  17097. protected _checkVerticesInsteadOfIndices: boolean;
  17098. protected _options: Nullable<IEdgesRendererOptions>;
  17099. private _meshRebuildObserver;
  17100. private _meshDisposeObserver;
  17101. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17102. isEnabled: boolean;
  17103. /**
  17104. * List of instances to render in case the source mesh has instances
  17105. */
  17106. customInstances: SmartArray<Matrix>;
  17107. private static GetShader;
  17108. /**
  17109. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17110. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17111. * @param source Mesh used to create edges
  17112. * @param epsilon sum of angles in adjacency to check for edge
  17113. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17114. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17115. * @param options The options to apply when generating the edges
  17116. */
  17117. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17118. protected _prepareRessources(): void;
  17119. /** @hidden */
  17120. _rebuild(): void;
  17121. /**
  17122. * Releases the required resources for the edges renderer
  17123. */
  17124. dispose(): void;
  17125. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17126. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17127. /**
  17128. * Checks if the pair of p0 and p1 is en edge
  17129. * @param faceIndex
  17130. * @param edge
  17131. * @param faceNormals
  17132. * @param p0
  17133. * @param p1
  17134. * @private
  17135. */
  17136. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17137. /**
  17138. * push line into the position, normal and index buffer
  17139. * @protected
  17140. */
  17141. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17142. /**
  17143. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17144. */
  17145. private _tessellateTriangle;
  17146. private _generateEdgesLinesAlternate;
  17147. /**
  17148. * Generates lines edges from adjacencjes
  17149. * @private
  17150. */
  17151. _generateEdgesLines(): void;
  17152. /**
  17153. * Checks wether or not the edges renderer is ready to render.
  17154. * @return true if ready, otherwise false.
  17155. */
  17156. isReady(): boolean;
  17157. /**
  17158. * Renders the edges of the attached mesh,
  17159. */
  17160. render(): void;
  17161. }
  17162. /**
  17163. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17164. */
  17165. export class LineEdgesRenderer extends EdgesRenderer {
  17166. /**
  17167. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17168. * @param source LineMesh used to generate edges
  17169. * @param epsilon not important (specified angle for edge detection)
  17170. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17171. */
  17172. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17173. /**
  17174. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17175. */
  17176. _generateEdgesLines(): void;
  17177. }
  17178. }
  17179. declare module BABYLON {
  17180. /**
  17181. * This represents the object necessary to create a rendering group.
  17182. * This is exclusively used and created by the rendering manager.
  17183. * To modify the behavior, you use the available helpers in your scene or meshes.
  17184. * @hidden
  17185. */
  17186. export class RenderingGroup {
  17187. index: number;
  17188. private static _zeroVector;
  17189. private _scene;
  17190. private _opaqueSubMeshes;
  17191. private _transparentSubMeshes;
  17192. private _alphaTestSubMeshes;
  17193. private _depthOnlySubMeshes;
  17194. private _particleSystems;
  17195. private _spriteManagers;
  17196. private _opaqueSortCompareFn;
  17197. private _alphaTestSortCompareFn;
  17198. private _transparentSortCompareFn;
  17199. private _renderOpaque;
  17200. private _renderAlphaTest;
  17201. private _renderTransparent;
  17202. /** @hidden */
  17203. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17204. onBeforeTransparentRendering: () => void;
  17205. /**
  17206. * Set the opaque sort comparison function.
  17207. * If null the sub meshes will be render in the order they were created
  17208. */
  17209. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17210. /**
  17211. * Set the alpha test sort comparison function.
  17212. * If null the sub meshes will be render in the order they were created
  17213. */
  17214. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17215. /**
  17216. * Set the transparent sort comparison function.
  17217. * If null the sub meshes will be render in the order they were created
  17218. */
  17219. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17220. /**
  17221. * Creates a new rendering group.
  17222. * @param index The rendering group index
  17223. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17224. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17225. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17226. */
  17227. 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>);
  17228. /**
  17229. * Render all the sub meshes contained in the group.
  17230. * @param customRenderFunction Used to override the default render behaviour of the group.
  17231. * @returns true if rendered some submeshes.
  17232. */
  17233. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17234. /**
  17235. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17236. * @param subMeshes The submeshes to render
  17237. */
  17238. private renderOpaqueSorted;
  17239. /**
  17240. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17241. * @param subMeshes The submeshes to render
  17242. */
  17243. private renderAlphaTestSorted;
  17244. /**
  17245. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17246. * @param subMeshes The submeshes to render
  17247. */
  17248. private renderTransparentSorted;
  17249. /**
  17250. * Renders the submeshes in a specified order.
  17251. * @param subMeshes The submeshes to sort before render
  17252. * @param sortCompareFn The comparison function use to sort
  17253. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17254. * @param transparent Specifies to activate blending if true
  17255. */
  17256. private static renderSorted;
  17257. /**
  17258. * Renders the submeshes in the order they were dispatched (no sort applied).
  17259. * @param subMeshes The submeshes to render
  17260. */
  17261. private static renderUnsorted;
  17262. /**
  17263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17264. * are rendered back to front if in the same alpha index.
  17265. *
  17266. * @param a The first submesh
  17267. * @param b The second submesh
  17268. * @returns The result of the comparison
  17269. */
  17270. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17271. /**
  17272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17273. * are rendered back to front.
  17274. *
  17275. * @param a The first submesh
  17276. * @param b The second submesh
  17277. * @returns The result of the comparison
  17278. */
  17279. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17280. /**
  17281. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17282. * are rendered front to back (prevent overdraw).
  17283. *
  17284. * @param a The first submesh
  17285. * @param b The second submesh
  17286. * @returns The result of the comparison
  17287. */
  17288. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17289. /**
  17290. * Resets the different lists of submeshes to prepare a new frame.
  17291. */
  17292. prepare(): void;
  17293. dispose(): void;
  17294. /**
  17295. * Inserts the submesh in its correct queue depending on its material.
  17296. * @param subMesh The submesh to dispatch
  17297. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17298. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17299. */
  17300. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17301. dispatchSprites(spriteManager: ISpriteManager): void;
  17302. dispatchParticles(particleSystem: IParticleSystem): void;
  17303. private _renderParticles;
  17304. private _renderSprites;
  17305. }
  17306. }
  17307. declare module BABYLON {
  17308. /**
  17309. * Interface describing the different options available in the rendering manager
  17310. * regarding Auto Clear between groups.
  17311. */
  17312. export interface IRenderingManagerAutoClearSetup {
  17313. /**
  17314. * Defines whether or not autoclear is enable.
  17315. */
  17316. autoClear: boolean;
  17317. /**
  17318. * Defines whether or not to autoclear the depth buffer.
  17319. */
  17320. depth: boolean;
  17321. /**
  17322. * Defines whether or not to autoclear the stencil buffer.
  17323. */
  17324. stencil: boolean;
  17325. }
  17326. /**
  17327. * This class is used by the onRenderingGroupObservable
  17328. */
  17329. export class RenderingGroupInfo {
  17330. /**
  17331. * The Scene that being rendered
  17332. */
  17333. scene: Scene;
  17334. /**
  17335. * The camera currently used for the rendering pass
  17336. */
  17337. camera: Nullable<Camera>;
  17338. /**
  17339. * The ID of the renderingGroup being processed
  17340. */
  17341. renderingGroupId: number;
  17342. }
  17343. /**
  17344. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17345. * It is enable to manage the different groups as well as the different necessary sort functions.
  17346. * This should not be used directly aside of the few static configurations
  17347. */
  17348. export class RenderingManager {
  17349. /**
  17350. * The max id used for rendering groups (not included)
  17351. */
  17352. static MAX_RENDERINGGROUPS: number;
  17353. /**
  17354. * The min id used for rendering groups (included)
  17355. */
  17356. static MIN_RENDERINGGROUPS: number;
  17357. /**
  17358. * Used to globally prevent autoclearing scenes.
  17359. */
  17360. static AUTOCLEAR: boolean;
  17361. /**
  17362. * @hidden
  17363. */
  17364. _useSceneAutoClearSetup: boolean;
  17365. private _scene;
  17366. private _renderingGroups;
  17367. private _depthStencilBufferAlreadyCleaned;
  17368. private _autoClearDepthStencil;
  17369. private _customOpaqueSortCompareFn;
  17370. private _customAlphaTestSortCompareFn;
  17371. private _customTransparentSortCompareFn;
  17372. private _renderingGroupInfo;
  17373. /**
  17374. * Instantiates a new rendering group for a particular scene
  17375. * @param scene Defines the scene the groups belongs to
  17376. */
  17377. constructor(scene: Scene);
  17378. private _clearDepthStencilBuffer;
  17379. /**
  17380. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17381. * @hidden
  17382. */
  17383. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17384. /**
  17385. * Resets the different information of the group to prepare a new frame
  17386. * @hidden
  17387. */
  17388. reset(): void;
  17389. /**
  17390. * Dispose and release the group and its associated resources.
  17391. * @hidden
  17392. */
  17393. dispose(): void;
  17394. /**
  17395. * Clear the info related to rendering groups preventing retention points during dispose.
  17396. */
  17397. freeRenderingGroups(): void;
  17398. private _prepareRenderingGroup;
  17399. /**
  17400. * Add a sprite manager to the rendering manager in order to render it this frame.
  17401. * @param spriteManager Define the sprite manager to render
  17402. */
  17403. dispatchSprites(spriteManager: ISpriteManager): void;
  17404. /**
  17405. * Add a particle system to the rendering manager in order to render it this frame.
  17406. * @param particleSystem Define the particle system to render
  17407. */
  17408. dispatchParticles(particleSystem: IParticleSystem): void;
  17409. /**
  17410. * Add a submesh to the manager in order to render it this frame
  17411. * @param subMesh The submesh to dispatch
  17412. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17413. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17414. */
  17415. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17416. /**
  17417. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17418. * This allowed control for front to back rendering or reversly depending of the special needs.
  17419. *
  17420. * @param renderingGroupId The rendering group id corresponding to its index
  17421. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17422. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17423. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17424. */
  17425. 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;
  17426. /**
  17427. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17428. *
  17429. * @param renderingGroupId The rendering group id corresponding to its index
  17430. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17431. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17432. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17433. */
  17434. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17435. /**
  17436. * Gets the current auto clear configuration for one rendering group of the rendering
  17437. * manager.
  17438. * @param index the rendering group index to get the information for
  17439. * @returns The auto clear setup for the requested rendering group
  17440. */
  17441. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17442. }
  17443. }
  17444. declare module BABYLON {
  17445. /**
  17446. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17447. */
  17448. export interface ICustomShaderOptions {
  17449. /**
  17450. * Gets or sets the custom shader name to use
  17451. */
  17452. shaderName: string;
  17453. /**
  17454. * The list of attribute names used in the shader
  17455. */
  17456. attributes?: string[];
  17457. /**
  17458. * The list of unifrom names used in the shader
  17459. */
  17460. uniforms?: string[];
  17461. /**
  17462. * The list of sampler names used in the shader
  17463. */
  17464. samplers?: string[];
  17465. /**
  17466. * The list of defines used in the shader
  17467. */
  17468. defines?: string[];
  17469. }
  17470. /**
  17471. * Interface to implement to create a shadow generator compatible with BJS.
  17472. */
  17473. export interface IShadowGenerator {
  17474. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17475. id: string;
  17476. /**
  17477. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17478. * @returns The render target texture if present otherwise, null
  17479. */
  17480. getShadowMap(): Nullable<RenderTargetTexture>;
  17481. /**
  17482. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17483. * @param subMesh The submesh we want to render in the shadow map
  17484. * @param useInstances Defines wether will draw in the map using instances
  17485. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17486. * @returns true if ready otherwise, false
  17487. */
  17488. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17489. /**
  17490. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17491. * @param defines Defines of the material we want to update
  17492. * @param lightIndex Index of the light in the enabled light list of the material
  17493. */
  17494. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17495. /**
  17496. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17497. * defined in the generator but impacting the effect).
  17498. * It implies the unifroms available on the materials are the standard BJS ones.
  17499. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17500. * @param effect The effect we are binfing the information for
  17501. */
  17502. bindShadowLight(lightIndex: string, effect: Effect): void;
  17503. /**
  17504. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17505. * (eq to shadow prjection matrix * light transform matrix)
  17506. * @returns The transform matrix used to create the shadow map
  17507. */
  17508. getTransformMatrix(): Matrix;
  17509. /**
  17510. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17511. * Cube and 2D textures for instance.
  17512. */
  17513. recreateShadowMap(): void;
  17514. /**
  17515. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17516. * @param onCompiled Callback triggered at the and of the effects compilation
  17517. * @param options Sets of optional options forcing the compilation with different modes
  17518. */
  17519. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17520. useInstances: boolean;
  17521. }>): void;
  17522. /**
  17523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17524. * @param options Sets of optional options forcing the compilation with different modes
  17525. * @returns A promise that resolves when the compilation completes
  17526. */
  17527. forceCompilationAsync(options?: Partial<{
  17528. useInstances: boolean;
  17529. }>): Promise<void>;
  17530. /**
  17531. * Serializes the shadow generator setup to a json object.
  17532. * @returns The serialized JSON object
  17533. */
  17534. serialize(): any;
  17535. /**
  17536. * Disposes the Shadow map and related Textures and effects.
  17537. */
  17538. dispose(): void;
  17539. }
  17540. /**
  17541. * Default implementation IShadowGenerator.
  17542. * This is the main object responsible of generating shadows in the framework.
  17543. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17544. */
  17545. export class ShadowGenerator implements IShadowGenerator {
  17546. /**
  17547. * Name of the shadow generator class
  17548. */
  17549. static CLASSNAME: string;
  17550. /**
  17551. * Shadow generator mode None: no filtering applied.
  17552. */
  17553. static readonly FILTER_NONE: number;
  17554. /**
  17555. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17556. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17557. */
  17558. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17559. /**
  17560. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17561. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17562. */
  17563. static readonly FILTER_POISSONSAMPLING: number;
  17564. /**
  17565. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17566. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17567. */
  17568. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17569. /**
  17570. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17571. * edge artifacts on steep falloff.
  17572. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17573. */
  17574. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17575. /**
  17576. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17577. * edge artifacts on steep falloff.
  17578. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17579. */
  17580. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17581. /**
  17582. * Shadow generator mode PCF: Percentage Closer Filtering
  17583. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17584. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17585. */
  17586. static readonly FILTER_PCF: number;
  17587. /**
  17588. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17589. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17590. * Contact Hardening
  17591. */
  17592. static readonly FILTER_PCSS: number;
  17593. /**
  17594. * Reserved for PCF and PCSS
  17595. * Highest Quality.
  17596. *
  17597. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17598. *
  17599. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17600. */
  17601. static readonly QUALITY_HIGH: number;
  17602. /**
  17603. * Reserved for PCF and PCSS
  17604. * Good tradeoff for quality/perf cross devices
  17605. *
  17606. * Execute PCF on a 3*3 kernel.
  17607. *
  17608. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17609. */
  17610. static readonly QUALITY_MEDIUM: number;
  17611. /**
  17612. * Reserved for PCF and PCSS
  17613. * The lowest quality but the fastest.
  17614. *
  17615. * Execute PCF on a 1*1 kernel.
  17616. *
  17617. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17618. */
  17619. static readonly QUALITY_LOW: number;
  17620. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17621. id: string;
  17622. /** Gets or sets the custom shader name to use */
  17623. customShaderOptions: ICustomShaderOptions;
  17624. /**
  17625. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17626. */
  17627. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17628. /**
  17629. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17630. */
  17631. onAfterShadowMapRenderObservable: Observable<Effect>;
  17632. /**
  17633. * Observable triggered before a mesh is rendered in the shadow map.
  17634. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17635. */
  17636. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17637. /**
  17638. * Observable triggered after a mesh is rendered in the shadow map.
  17639. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17640. */
  17641. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17642. protected _bias: number;
  17643. /**
  17644. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17645. */
  17646. get bias(): number;
  17647. /**
  17648. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17649. */
  17650. set bias(bias: number);
  17651. protected _normalBias: number;
  17652. /**
  17653. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17654. */
  17655. get normalBias(): number;
  17656. /**
  17657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17658. */
  17659. set normalBias(normalBias: number);
  17660. protected _blurBoxOffset: number;
  17661. /**
  17662. * Gets the blur box offset: offset applied during the blur pass.
  17663. * Only useful if useKernelBlur = false
  17664. */
  17665. get blurBoxOffset(): number;
  17666. /**
  17667. * Sets the blur box offset: offset applied during the blur pass.
  17668. * Only useful if useKernelBlur = false
  17669. */
  17670. set blurBoxOffset(value: number);
  17671. protected _blurScale: number;
  17672. /**
  17673. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17674. * 2 means half of the size.
  17675. */
  17676. get blurScale(): number;
  17677. /**
  17678. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17679. * 2 means half of the size.
  17680. */
  17681. set blurScale(value: number);
  17682. protected _blurKernel: number;
  17683. /**
  17684. * Gets the blur kernel: kernel size of the blur pass.
  17685. * Only useful if useKernelBlur = true
  17686. */
  17687. get blurKernel(): number;
  17688. /**
  17689. * Sets the blur kernel: kernel size of the blur pass.
  17690. * Only useful if useKernelBlur = true
  17691. */
  17692. set blurKernel(value: number);
  17693. protected _useKernelBlur: boolean;
  17694. /**
  17695. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17696. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17697. */
  17698. get useKernelBlur(): boolean;
  17699. /**
  17700. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17701. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17702. */
  17703. set useKernelBlur(value: boolean);
  17704. protected _depthScale: number;
  17705. /**
  17706. * Gets the depth scale used in ESM mode.
  17707. */
  17708. get depthScale(): number;
  17709. /**
  17710. * Sets the depth scale used in ESM mode.
  17711. * This can override the scale stored on the light.
  17712. */
  17713. set depthScale(value: number);
  17714. protected _validateFilter(filter: number): number;
  17715. protected _filter: number;
  17716. /**
  17717. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17718. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17719. */
  17720. get filter(): number;
  17721. /**
  17722. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17723. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17724. */
  17725. set filter(value: number);
  17726. /**
  17727. * Gets if the current filter is set to Poisson Sampling.
  17728. */
  17729. get usePoissonSampling(): boolean;
  17730. /**
  17731. * Sets the current filter to Poisson Sampling.
  17732. */
  17733. set usePoissonSampling(value: boolean);
  17734. /**
  17735. * Gets if the current filter is set to ESM.
  17736. */
  17737. get useExponentialShadowMap(): boolean;
  17738. /**
  17739. * Sets the current filter is to ESM.
  17740. */
  17741. set useExponentialShadowMap(value: boolean);
  17742. /**
  17743. * Gets if the current filter is set to filtered ESM.
  17744. */
  17745. get useBlurExponentialShadowMap(): boolean;
  17746. /**
  17747. * Gets if the current filter is set to filtered ESM.
  17748. */
  17749. set useBlurExponentialShadowMap(value: boolean);
  17750. /**
  17751. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17752. * exponential to prevent steep falloff artifacts).
  17753. */
  17754. get useCloseExponentialShadowMap(): boolean;
  17755. /**
  17756. * Sets the current filter to "close ESM" (using the inverse of the
  17757. * exponential to prevent steep falloff artifacts).
  17758. */
  17759. set useCloseExponentialShadowMap(value: boolean);
  17760. /**
  17761. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17762. * exponential to prevent steep falloff artifacts).
  17763. */
  17764. get useBlurCloseExponentialShadowMap(): boolean;
  17765. /**
  17766. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17767. * exponential to prevent steep falloff artifacts).
  17768. */
  17769. set useBlurCloseExponentialShadowMap(value: boolean);
  17770. /**
  17771. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17772. */
  17773. get usePercentageCloserFiltering(): boolean;
  17774. /**
  17775. * Sets the current filter to "PCF" (percentage closer filtering).
  17776. */
  17777. set usePercentageCloserFiltering(value: boolean);
  17778. protected _filteringQuality: number;
  17779. /**
  17780. * Gets the PCF or PCSS Quality.
  17781. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17782. */
  17783. get filteringQuality(): number;
  17784. /**
  17785. * Sets the PCF or PCSS Quality.
  17786. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17787. */
  17788. set filteringQuality(filteringQuality: number);
  17789. /**
  17790. * Gets if the current filter is set to "PCSS" (contact hardening).
  17791. */
  17792. get useContactHardeningShadow(): boolean;
  17793. /**
  17794. * Sets the current filter to "PCSS" (contact hardening).
  17795. */
  17796. set useContactHardeningShadow(value: boolean);
  17797. protected _contactHardeningLightSizeUVRatio: number;
  17798. /**
  17799. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17800. * Using a ratio helps keeping shape stability independently of the map size.
  17801. *
  17802. * It does not account for the light projection as it was having too much
  17803. * instability during the light setup or during light position changes.
  17804. *
  17805. * Only valid if useContactHardeningShadow is true.
  17806. */
  17807. get contactHardeningLightSizeUVRatio(): number;
  17808. /**
  17809. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17810. * Using a ratio helps keeping shape stability independently of the map size.
  17811. *
  17812. * It does not account for the light projection as it was having too much
  17813. * instability during the light setup or during light position changes.
  17814. *
  17815. * Only valid if useContactHardeningShadow is true.
  17816. */
  17817. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17818. protected _darkness: number;
  17819. /** Gets or sets the actual darkness of a shadow */
  17820. get darkness(): number;
  17821. set darkness(value: number);
  17822. /**
  17823. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17824. * 0 means strongest and 1 would means no shadow.
  17825. * @returns the darkness.
  17826. */
  17827. getDarkness(): number;
  17828. /**
  17829. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17830. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17831. * @returns the shadow generator allowing fluent coding.
  17832. */
  17833. setDarkness(darkness: number): ShadowGenerator;
  17834. protected _transparencyShadow: boolean;
  17835. /** Gets or sets the ability to have transparent shadow */
  17836. get transparencyShadow(): boolean;
  17837. set transparencyShadow(value: boolean);
  17838. /**
  17839. * Sets the ability to have transparent shadow (boolean).
  17840. * @param transparent True if transparent else False
  17841. * @returns the shadow generator allowing fluent coding
  17842. */
  17843. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17844. /**
  17845. * Enables or disables shadows with varying strength based on the transparency
  17846. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17847. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17848. * mesh.visibility * alphaTexture.a
  17849. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17850. */
  17851. enableSoftTransparentShadow: boolean;
  17852. protected _shadowMap: Nullable<RenderTargetTexture>;
  17853. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17854. /**
  17855. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17856. * @returns The render target texture if present otherwise, null
  17857. */
  17858. getShadowMap(): Nullable<RenderTargetTexture>;
  17859. /**
  17860. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17861. * @returns The render target texture if the shadow map is present otherwise, null
  17862. */
  17863. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17864. /**
  17865. * Gets the class name of that object
  17866. * @returns "ShadowGenerator"
  17867. */
  17868. getClassName(): string;
  17869. /**
  17870. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17871. * @param mesh Mesh to add
  17872. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17873. * @returns the Shadow Generator itself
  17874. */
  17875. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17876. /**
  17877. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17878. * @param mesh Mesh to remove
  17879. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17880. * @returns the Shadow Generator itself
  17881. */
  17882. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17883. /**
  17884. * Controls the extent to which the shadows fade out at the edge of the frustum
  17885. */
  17886. frustumEdgeFalloff: number;
  17887. protected _light: IShadowLight;
  17888. /**
  17889. * Returns the associated light object.
  17890. * @returns the light generating the shadow
  17891. */
  17892. getLight(): IShadowLight;
  17893. /**
  17894. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17895. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17896. * It might on the other hand introduce peter panning.
  17897. */
  17898. forceBackFacesOnly: boolean;
  17899. protected _scene: Scene;
  17900. protected _lightDirection: Vector3;
  17901. protected _effect: Effect;
  17902. protected _viewMatrix: Matrix;
  17903. protected _projectionMatrix: Matrix;
  17904. protected _transformMatrix: Matrix;
  17905. protected _cachedPosition: Vector3;
  17906. protected _cachedDirection: Vector3;
  17907. protected _cachedDefines: string;
  17908. protected _currentRenderID: number;
  17909. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17910. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17911. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17912. protected _blurPostProcesses: PostProcess[];
  17913. protected _mapSize: number;
  17914. protected _currentFaceIndex: number;
  17915. protected _currentFaceIndexCache: number;
  17916. protected _textureType: number;
  17917. protected _defaultTextureMatrix: Matrix;
  17918. protected _storedUniqueId: Nullable<number>;
  17919. /** @hidden */
  17920. static _SceneComponentInitialization: (scene: Scene) => void;
  17921. /**
  17922. * Creates a ShadowGenerator object.
  17923. * A ShadowGenerator is the required tool to use the shadows.
  17924. * Each light casting shadows needs to use its own ShadowGenerator.
  17925. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17926. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17927. * @param light The light object generating the shadows.
  17928. * @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.
  17929. */
  17930. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17931. protected _initializeGenerator(): void;
  17932. protected _createTargetRenderTexture(): void;
  17933. protected _initializeShadowMap(): void;
  17934. protected _initializeBlurRTTAndPostProcesses(): void;
  17935. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17936. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17937. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17938. protected _applyFilterValues(): void;
  17939. /**
  17940. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17941. * @param onCompiled Callback triggered at the and of the effects compilation
  17942. * @param options Sets of optional options forcing the compilation with different modes
  17943. */
  17944. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17945. useInstances: boolean;
  17946. }>): void;
  17947. /**
  17948. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17949. * @param options Sets of optional options forcing the compilation with different modes
  17950. * @returns A promise that resolves when the compilation completes
  17951. */
  17952. forceCompilationAsync(options?: Partial<{
  17953. useInstances: boolean;
  17954. }>): Promise<void>;
  17955. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17956. private _prepareShadowDefines;
  17957. /**
  17958. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17959. * @param subMesh The submesh we want to render in the shadow map
  17960. * @param useInstances Defines wether will draw in the map using instances
  17961. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17962. * @returns true if ready otherwise, false
  17963. */
  17964. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17965. /**
  17966. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17967. * @param defines Defines of the material we want to update
  17968. * @param lightIndex Index of the light in the enabled light list of the material
  17969. */
  17970. prepareDefines(defines: any, lightIndex: number): void;
  17971. /**
  17972. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17973. * defined in the generator but impacting the effect).
  17974. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17975. * @param effect The effect we are binfing the information for
  17976. */
  17977. bindShadowLight(lightIndex: string, effect: Effect): void;
  17978. /**
  17979. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17980. * (eq to shadow prjection matrix * light transform matrix)
  17981. * @returns The transform matrix used to create the shadow map
  17982. */
  17983. getTransformMatrix(): Matrix;
  17984. /**
  17985. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17986. * Cube and 2D textures for instance.
  17987. */
  17988. recreateShadowMap(): void;
  17989. protected _disposeBlurPostProcesses(): void;
  17990. protected _disposeRTTandPostProcesses(): void;
  17991. /**
  17992. * Disposes the ShadowGenerator.
  17993. * Returns nothing.
  17994. */
  17995. dispose(): void;
  17996. /**
  17997. * Serializes the shadow generator setup to a json object.
  17998. * @returns The serialized JSON object
  17999. */
  18000. serialize(): any;
  18001. /**
  18002. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18003. * @param parsedShadowGenerator The JSON object to parse
  18004. * @param scene The scene to create the shadow map for
  18005. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18006. * @returns The parsed shadow generator
  18007. */
  18008. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18009. }
  18010. }
  18011. declare module BABYLON {
  18012. /**
  18013. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18014. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18015. * 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.
  18016. */
  18017. export abstract class Light extends Node {
  18018. /**
  18019. * Falloff Default: light is falling off following the material specification:
  18020. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18021. */
  18022. static readonly FALLOFF_DEFAULT: number;
  18023. /**
  18024. * Falloff Physical: light is falling off following the inverse squared distance law.
  18025. */
  18026. static readonly FALLOFF_PHYSICAL: number;
  18027. /**
  18028. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18029. * to enhance interoperability with other engines.
  18030. */
  18031. static readonly FALLOFF_GLTF: number;
  18032. /**
  18033. * Falloff Standard: light is falling off like in the standard material
  18034. * to enhance interoperability with other materials.
  18035. */
  18036. static readonly FALLOFF_STANDARD: number;
  18037. /**
  18038. * If every light affecting the material is in this lightmapMode,
  18039. * material.lightmapTexture adds or multiplies
  18040. * (depends on material.useLightmapAsShadowmap)
  18041. * after every other light calculations.
  18042. */
  18043. static readonly LIGHTMAP_DEFAULT: number;
  18044. /**
  18045. * material.lightmapTexture as only diffuse lighting from this light
  18046. * adds only specular lighting from this light
  18047. * adds dynamic shadows
  18048. */
  18049. static readonly LIGHTMAP_SPECULAR: number;
  18050. /**
  18051. * material.lightmapTexture as only lighting
  18052. * no light calculation from this light
  18053. * only adds dynamic shadows from this light
  18054. */
  18055. static readonly LIGHTMAP_SHADOWSONLY: number;
  18056. /**
  18057. * Each light type uses the default quantity according to its type:
  18058. * point/spot lights use luminous intensity
  18059. * directional lights use illuminance
  18060. */
  18061. static readonly INTENSITYMODE_AUTOMATIC: number;
  18062. /**
  18063. * lumen (lm)
  18064. */
  18065. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18066. /**
  18067. * candela (lm/sr)
  18068. */
  18069. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18070. /**
  18071. * lux (lm/m^2)
  18072. */
  18073. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18074. /**
  18075. * nit (cd/m^2)
  18076. */
  18077. static readonly INTENSITYMODE_LUMINANCE: number;
  18078. /**
  18079. * Light type const id of the point light.
  18080. */
  18081. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18082. /**
  18083. * Light type const id of the directional light.
  18084. */
  18085. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18086. /**
  18087. * Light type const id of the spot light.
  18088. */
  18089. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18090. /**
  18091. * Light type const id of the hemispheric light.
  18092. */
  18093. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18094. /**
  18095. * Diffuse gives the basic color to an object.
  18096. */
  18097. diffuse: Color3;
  18098. /**
  18099. * Specular produces a highlight color on an object.
  18100. * Note: This is note affecting PBR materials.
  18101. */
  18102. specular: Color3;
  18103. /**
  18104. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18105. * falling off base on range or angle.
  18106. * This can be set to any values in Light.FALLOFF_x.
  18107. *
  18108. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18109. * other types of materials.
  18110. */
  18111. falloffType: number;
  18112. /**
  18113. * Strength of the light.
  18114. * Note: By default it is define in the framework own unit.
  18115. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18116. */
  18117. intensity: number;
  18118. private _range;
  18119. protected _inverseSquaredRange: number;
  18120. /**
  18121. * Defines how far from the source the light is impacting in scene units.
  18122. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18123. */
  18124. get range(): number;
  18125. /**
  18126. * Defines how far from the source the light is impacting in scene units.
  18127. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18128. */
  18129. set range(value: number);
  18130. /**
  18131. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18132. * of light.
  18133. */
  18134. private _photometricScale;
  18135. private _intensityMode;
  18136. /**
  18137. * Gets the photometric scale used to interpret the intensity.
  18138. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18139. */
  18140. get intensityMode(): number;
  18141. /**
  18142. * Sets the photometric scale used to interpret the intensity.
  18143. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18144. */
  18145. set intensityMode(value: number);
  18146. private _radius;
  18147. /**
  18148. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18149. */
  18150. get radius(): number;
  18151. /**
  18152. * sets the light radius used by PBR Materials to simulate soft area lights.
  18153. */
  18154. set radius(value: number);
  18155. private _renderPriority;
  18156. /**
  18157. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18158. * exceeding the number allowed of the materials.
  18159. */
  18160. renderPriority: number;
  18161. private _shadowEnabled;
  18162. /**
  18163. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18164. * the current shadow generator.
  18165. */
  18166. get shadowEnabled(): boolean;
  18167. /**
  18168. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18169. * the current shadow generator.
  18170. */
  18171. set shadowEnabled(value: boolean);
  18172. private _includedOnlyMeshes;
  18173. /**
  18174. * Gets the only meshes impacted by this light.
  18175. */
  18176. get includedOnlyMeshes(): AbstractMesh[];
  18177. /**
  18178. * Sets the only meshes impacted by this light.
  18179. */
  18180. set includedOnlyMeshes(value: AbstractMesh[]);
  18181. private _excludedMeshes;
  18182. /**
  18183. * Gets the meshes not impacted by this light.
  18184. */
  18185. get excludedMeshes(): AbstractMesh[];
  18186. /**
  18187. * Sets the meshes not impacted by this light.
  18188. */
  18189. set excludedMeshes(value: AbstractMesh[]);
  18190. private _excludeWithLayerMask;
  18191. /**
  18192. * Gets the layer id use to find what meshes are not impacted by the light.
  18193. * Inactive if 0
  18194. */
  18195. get excludeWithLayerMask(): number;
  18196. /**
  18197. * Sets the layer id use to find what meshes are not impacted by the light.
  18198. * Inactive if 0
  18199. */
  18200. set excludeWithLayerMask(value: number);
  18201. private _includeOnlyWithLayerMask;
  18202. /**
  18203. * Gets the layer id use to find what meshes are impacted by the light.
  18204. * Inactive if 0
  18205. */
  18206. get includeOnlyWithLayerMask(): number;
  18207. /**
  18208. * Sets the layer id use to find what meshes are impacted by the light.
  18209. * Inactive if 0
  18210. */
  18211. set includeOnlyWithLayerMask(value: number);
  18212. private _lightmapMode;
  18213. /**
  18214. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18215. */
  18216. get lightmapMode(): number;
  18217. /**
  18218. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18219. */
  18220. set lightmapMode(value: number);
  18221. /**
  18222. * Shadow generator associted to the light.
  18223. * @hidden Internal use only.
  18224. */
  18225. _shadowGenerator: Nullable<IShadowGenerator>;
  18226. /**
  18227. * @hidden Internal use only.
  18228. */
  18229. _excludedMeshesIds: string[];
  18230. /**
  18231. * @hidden Internal use only.
  18232. */
  18233. _includedOnlyMeshesIds: string[];
  18234. /**
  18235. * The current light unifom buffer.
  18236. * @hidden Internal use only.
  18237. */
  18238. _uniformBuffer: UniformBuffer;
  18239. /** @hidden */
  18240. _renderId: number;
  18241. /**
  18242. * Creates a Light object in the scene.
  18243. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18244. * @param name The firendly name of the light
  18245. * @param scene The scene the light belongs too
  18246. */
  18247. constructor(name: string, scene: Scene);
  18248. protected abstract _buildUniformLayout(): void;
  18249. /**
  18250. * Sets the passed Effect "effect" with the Light information.
  18251. * @param effect The effect to update
  18252. * @param lightIndex The index of the light in the effect to update
  18253. * @returns The light
  18254. */
  18255. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18256. /**
  18257. * Sets the passed Effect "effect" with the Light textures.
  18258. * @param effect The effect to update
  18259. * @param lightIndex The index of the light in the effect to update
  18260. * @returns The light
  18261. */
  18262. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18263. /**
  18264. * Binds the lights information from the scene to the effect for the given mesh.
  18265. * @param lightIndex Light index
  18266. * @param scene The scene where the light belongs to
  18267. * @param effect The effect we are binding the data to
  18268. * @param useSpecular Defines if specular is supported
  18269. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18270. */
  18271. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18272. /**
  18273. * Sets the passed Effect "effect" with the Light information.
  18274. * @param effect The effect to update
  18275. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18276. * @returns The light
  18277. */
  18278. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18279. /**
  18280. * Returns the string "Light".
  18281. * @returns the class name
  18282. */
  18283. getClassName(): string;
  18284. /** @hidden */
  18285. readonly _isLight: boolean;
  18286. /**
  18287. * Converts the light information to a readable string for debug purpose.
  18288. * @param fullDetails Supports for multiple levels of logging within scene loading
  18289. * @returns the human readable light info
  18290. */
  18291. toString(fullDetails?: boolean): string;
  18292. /** @hidden */
  18293. protected _syncParentEnabledState(): void;
  18294. /**
  18295. * Set the enabled state of this node.
  18296. * @param value - the new enabled state
  18297. */
  18298. setEnabled(value: boolean): void;
  18299. /**
  18300. * Returns the Light associated shadow generator if any.
  18301. * @return the associated shadow generator.
  18302. */
  18303. getShadowGenerator(): Nullable<IShadowGenerator>;
  18304. /**
  18305. * Returns a Vector3, the absolute light position in the World.
  18306. * @returns the world space position of the light
  18307. */
  18308. getAbsolutePosition(): Vector3;
  18309. /**
  18310. * Specifies if the light will affect the passed mesh.
  18311. * @param mesh The mesh to test against the light
  18312. * @return true the mesh is affected otherwise, false.
  18313. */
  18314. canAffectMesh(mesh: AbstractMesh): boolean;
  18315. /**
  18316. * Sort function to order lights for rendering.
  18317. * @param a First Light object to compare to second.
  18318. * @param b Second Light object to compare first.
  18319. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18320. */
  18321. static CompareLightsPriority(a: Light, b: Light): number;
  18322. /**
  18323. * Releases resources associated with this node.
  18324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18326. */
  18327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18328. /**
  18329. * Returns the light type ID (integer).
  18330. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18331. */
  18332. getTypeID(): number;
  18333. /**
  18334. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18335. * @returns the scaled intensity in intensity mode unit
  18336. */
  18337. getScaledIntensity(): number;
  18338. /**
  18339. * Returns a new Light object, named "name", from the current one.
  18340. * @param name The name of the cloned light
  18341. * @param newParent The parent of this light, if it has one
  18342. * @returns the new created light
  18343. */
  18344. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18345. /**
  18346. * Serializes the current light into a Serialization object.
  18347. * @returns the serialized object.
  18348. */
  18349. serialize(): any;
  18350. /**
  18351. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18352. * This new light is named "name" and added to the passed scene.
  18353. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18354. * @param name The friendly name of the light
  18355. * @param scene The scene the new light will belong to
  18356. * @returns the constructor function
  18357. */
  18358. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18359. /**
  18360. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18361. * @param parsedLight The JSON representation of the light
  18362. * @param scene The scene to create the parsed light in
  18363. * @returns the created light after parsing
  18364. */
  18365. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18366. private _hookArrayForExcluded;
  18367. private _hookArrayForIncludedOnly;
  18368. private _resyncMeshes;
  18369. /**
  18370. * Forces the meshes to update their light related information in their rendering used effects
  18371. * @hidden Internal Use Only
  18372. */
  18373. _markMeshesAsLightDirty(): void;
  18374. /**
  18375. * Recomputes the cached photometric scale if needed.
  18376. */
  18377. private _computePhotometricScale;
  18378. /**
  18379. * Returns the Photometric Scale according to the light type and intensity mode.
  18380. */
  18381. private _getPhotometricScale;
  18382. /**
  18383. * Reorder the light in the scene according to their defined priority.
  18384. * @hidden Internal Use Only
  18385. */
  18386. _reorderLightsInScene(): void;
  18387. /**
  18388. * Prepares the list of defines specific to the light type.
  18389. * @param defines the list of defines
  18390. * @param lightIndex defines the index of the light for the effect
  18391. */
  18392. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18393. }
  18394. }
  18395. declare module BABYLON {
  18396. /**
  18397. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18398. * This is the base of the follow, arc rotate cameras and Free camera
  18399. * @see https://doc.babylonjs.com/features/cameras
  18400. */
  18401. export class TargetCamera extends Camera {
  18402. private static _RigCamTransformMatrix;
  18403. private static _TargetTransformMatrix;
  18404. private static _TargetFocalPoint;
  18405. private _tmpUpVector;
  18406. private _tmpTargetVector;
  18407. /**
  18408. * Define the current direction the camera is moving to
  18409. */
  18410. cameraDirection: Vector3;
  18411. /**
  18412. * Define the current rotation the camera is rotating to
  18413. */
  18414. cameraRotation: Vector2;
  18415. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18416. ignoreParentScaling: boolean;
  18417. /**
  18418. * When set, the up vector of the camera will be updated by the rotation of the camera
  18419. */
  18420. updateUpVectorFromRotation: boolean;
  18421. private _tmpQuaternion;
  18422. /**
  18423. * Define the current rotation of the camera
  18424. */
  18425. rotation: Vector3;
  18426. /**
  18427. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18428. */
  18429. rotationQuaternion: Quaternion;
  18430. /**
  18431. * Define the current speed of the camera
  18432. */
  18433. speed: number;
  18434. /**
  18435. * Add constraint to the camera to prevent it to move freely in all directions and
  18436. * around all axis.
  18437. */
  18438. noRotationConstraint: boolean;
  18439. /**
  18440. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18441. * panning
  18442. */
  18443. invertRotation: boolean;
  18444. /**
  18445. * Speed multiplier for inverse camera panning
  18446. */
  18447. inverseRotationSpeed: number;
  18448. /**
  18449. * Define the current target of the camera as an object or a position.
  18450. */
  18451. lockedTarget: any;
  18452. /** @hidden */
  18453. _currentTarget: Vector3;
  18454. /** @hidden */
  18455. _initialFocalDistance: number;
  18456. /** @hidden */
  18457. _viewMatrix: Matrix;
  18458. /** @hidden */
  18459. _camMatrix: Matrix;
  18460. /** @hidden */
  18461. _cameraTransformMatrix: Matrix;
  18462. /** @hidden */
  18463. _cameraRotationMatrix: Matrix;
  18464. /** @hidden */
  18465. _referencePoint: Vector3;
  18466. /** @hidden */
  18467. _transformedReferencePoint: Vector3;
  18468. /** @hidden */
  18469. _reset: () => void;
  18470. private _defaultUp;
  18471. /**
  18472. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18473. * This is the base of the follow, arc rotate cameras and Free camera
  18474. * @see https://doc.babylonjs.com/features/cameras
  18475. * @param name Defines the name of the camera in the scene
  18476. * @param position Defines the start position of the camera in the scene
  18477. * @param scene Defines the scene the camera belongs to
  18478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18479. */
  18480. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18481. /**
  18482. * Gets the position in front of the camera at a given distance.
  18483. * @param distance The distance from the camera we want the position to be
  18484. * @returns the position
  18485. */
  18486. getFrontPosition(distance: number): Vector3;
  18487. /** @hidden */
  18488. _getLockedTargetPosition(): Nullable<Vector3>;
  18489. private _storedPosition;
  18490. private _storedRotation;
  18491. private _storedRotationQuaternion;
  18492. /**
  18493. * Store current camera state of the camera (fov, position, rotation, etc..)
  18494. * @returns the camera
  18495. */
  18496. storeState(): Camera;
  18497. /**
  18498. * Restored camera state. You must call storeState() first
  18499. * @returns whether it was successful or not
  18500. * @hidden
  18501. */
  18502. _restoreStateValues(): boolean;
  18503. /** @hidden */
  18504. _initCache(): void;
  18505. /** @hidden */
  18506. _updateCache(ignoreParentClass?: boolean): void;
  18507. /** @hidden */
  18508. _isSynchronizedViewMatrix(): boolean;
  18509. /** @hidden */
  18510. _computeLocalCameraSpeed(): number;
  18511. /**
  18512. * Defines the target the camera should look at.
  18513. * @param target Defines the new target as a Vector or a mesh
  18514. */
  18515. setTarget(target: Vector3): void;
  18516. /**
  18517. * Defines the target point of the camera.
  18518. * The camera looks towards it form the radius distance.
  18519. */
  18520. get target(): Vector3;
  18521. set target(value: Vector3);
  18522. /**
  18523. * Return the current target position of the camera. This value is expressed in local space.
  18524. * @returns the target position
  18525. */
  18526. getTarget(): Vector3;
  18527. /** @hidden */
  18528. _decideIfNeedsToMove(): boolean;
  18529. /** @hidden */
  18530. _updatePosition(): void;
  18531. /** @hidden */
  18532. _checkInputs(): void;
  18533. protected _updateCameraRotationMatrix(): void;
  18534. /**
  18535. * 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)
  18536. * @returns the current camera
  18537. */
  18538. private _rotateUpVectorWithCameraRotationMatrix;
  18539. private _cachedRotationZ;
  18540. private _cachedQuaternionRotationZ;
  18541. /** @hidden */
  18542. _getViewMatrix(): Matrix;
  18543. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18544. /**
  18545. * @hidden
  18546. */
  18547. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18548. /**
  18549. * @hidden
  18550. */
  18551. _updateRigCameras(): void;
  18552. private _getRigCamPositionAndTarget;
  18553. /**
  18554. * Gets the current object class name.
  18555. * @return the class name
  18556. */
  18557. getClassName(): string;
  18558. }
  18559. }
  18560. declare module BABYLON {
  18561. /**
  18562. * Gather the list of keyboard event types as constants.
  18563. */
  18564. export class KeyboardEventTypes {
  18565. /**
  18566. * The keydown event is fired when a key becomes active (pressed).
  18567. */
  18568. static readonly KEYDOWN: number;
  18569. /**
  18570. * The keyup event is fired when a key has been released.
  18571. */
  18572. static readonly KEYUP: number;
  18573. }
  18574. /**
  18575. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18576. */
  18577. export class KeyboardInfo {
  18578. /**
  18579. * Defines the type of event (KeyboardEventTypes)
  18580. */
  18581. type: number;
  18582. /**
  18583. * Defines the related dom event
  18584. */
  18585. event: KeyboardEvent;
  18586. /**
  18587. * Instantiates a new keyboard info.
  18588. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18589. * @param type Defines the type of event (KeyboardEventTypes)
  18590. * @param event Defines the related dom event
  18591. */
  18592. constructor(
  18593. /**
  18594. * Defines the type of event (KeyboardEventTypes)
  18595. */
  18596. type: number,
  18597. /**
  18598. * Defines the related dom event
  18599. */
  18600. event: KeyboardEvent);
  18601. }
  18602. /**
  18603. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18604. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18605. */
  18606. export class KeyboardInfoPre extends KeyboardInfo {
  18607. /**
  18608. * Defines the type of event (KeyboardEventTypes)
  18609. */
  18610. type: number;
  18611. /**
  18612. * Defines the related dom event
  18613. */
  18614. event: KeyboardEvent;
  18615. /**
  18616. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18617. */
  18618. skipOnPointerObservable: boolean;
  18619. /**
  18620. * Instantiates a new keyboard pre info.
  18621. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18622. * @param type Defines the type of event (KeyboardEventTypes)
  18623. * @param event Defines the related dom event
  18624. */
  18625. constructor(
  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. }
  18636. declare module BABYLON {
  18637. /**
  18638. * Manage the keyboard inputs to control the movement of a free camera.
  18639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18640. */
  18641. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18642. /**
  18643. * Defines the camera the input is attached to.
  18644. */
  18645. camera: FreeCamera;
  18646. /**
  18647. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18648. */
  18649. keysUp: number[];
  18650. /**
  18651. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18652. */
  18653. keysUpward: number[];
  18654. /**
  18655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18656. */
  18657. keysDown: number[];
  18658. /**
  18659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18660. */
  18661. keysDownward: number[];
  18662. /**
  18663. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18664. */
  18665. keysLeft: number[];
  18666. /**
  18667. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18668. */
  18669. keysRight: number[];
  18670. private _keys;
  18671. private _onCanvasBlurObserver;
  18672. private _onKeyboardObserver;
  18673. private _engine;
  18674. private _scene;
  18675. /**
  18676. * Attach the input controls to a specific dom element to get the input from.
  18677. * @param element Defines the element the controls should be listened from
  18678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18679. */
  18680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Update the current camera state depending on the inputs that have been used this frame.
  18688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18689. */
  18690. checkInputs(): void;
  18691. /**
  18692. * Gets the class name of the current intput.
  18693. * @returns the class name
  18694. */
  18695. getClassName(): string;
  18696. /** @hidden */
  18697. _onLostFocus(): void;
  18698. /**
  18699. * Get the friendly name associated with the input class.
  18700. * @returns the input friendly name
  18701. */
  18702. getSimpleName(): string;
  18703. }
  18704. }
  18705. declare module BABYLON {
  18706. /**
  18707. * Gather the list of pointer event types as constants.
  18708. */
  18709. export class PointerEventTypes {
  18710. /**
  18711. * 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.
  18712. */
  18713. static readonly POINTERDOWN: number;
  18714. /**
  18715. * The pointerup event is fired when a pointer is no longer active.
  18716. */
  18717. static readonly POINTERUP: number;
  18718. /**
  18719. * The pointermove event is fired when a pointer changes coordinates.
  18720. */
  18721. static readonly POINTERMOVE: number;
  18722. /**
  18723. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18724. */
  18725. static readonly POINTERWHEEL: number;
  18726. /**
  18727. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18728. */
  18729. static readonly POINTERPICK: number;
  18730. /**
  18731. * The pointertap event is fired when a the object has been touched and released without drag.
  18732. */
  18733. static readonly POINTERTAP: number;
  18734. /**
  18735. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18736. */
  18737. static readonly POINTERDOUBLETAP: number;
  18738. }
  18739. /**
  18740. * Base class of pointer info types.
  18741. */
  18742. export class PointerInfoBase {
  18743. /**
  18744. * Defines the type of event (PointerEventTypes)
  18745. */
  18746. type: number;
  18747. /**
  18748. * Defines the related dom event
  18749. */
  18750. event: PointerEvent | MouseWheelEvent;
  18751. /**
  18752. * Instantiates the base class of pointers info.
  18753. * @param type Defines the type of event (PointerEventTypes)
  18754. * @param event Defines the related dom event
  18755. */
  18756. constructor(
  18757. /**
  18758. * Defines the type of event (PointerEventTypes)
  18759. */
  18760. type: number,
  18761. /**
  18762. * Defines the related dom event
  18763. */
  18764. event: PointerEvent | MouseWheelEvent);
  18765. }
  18766. /**
  18767. * This class is used to store pointer related info for the onPrePointerObservable event.
  18768. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18769. */
  18770. export class PointerInfoPre extends PointerInfoBase {
  18771. /**
  18772. * Ray from a pointer if availible (eg. 6dof controller)
  18773. */
  18774. ray: Nullable<Ray>;
  18775. /**
  18776. * Defines the local position of the pointer on the canvas.
  18777. */
  18778. localPosition: Vector2;
  18779. /**
  18780. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18781. */
  18782. skipOnPointerObservable: boolean;
  18783. /**
  18784. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18785. * @param type Defines the type of event (PointerEventTypes)
  18786. * @param event Defines the related dom event
  18787. * @param localX Defines the local x coordinates of the pointer when the event occured
  18788. * @param localY Defines the local y coordinates of the pointer when the event occured
  18789. */
  18790. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18791. }
  18792. /**
  18793. * This type contains all the data related to a pointer event in Babylon.js.
  18794. * 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.
  18795. */
  18796. export class PointerInfo extends PointerInfoBase {
  18797. /**
  18798. * Defines the picking info associated to the info (if any)\
  18799. */
  18800. pickInfo: Nullable<PickingInfo>;
  18801. /**
  18802. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18803. * @param type Defines the type of event (PointerEventTypes)
  18804. * @param event Defines the related dom event
  18805. * @param pickInfo Defines the picking info associated to the info (if any)\
  18806. */
  18807. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18808. /**
  18809. * Defines the picking info associated to the info (if any)\
  18810. */
  18811. pickInfo: Nullable<PickingInfo>);
  18812. }
  18813. /**
  18814. * Data relating to a touch event on the screen.
  18815. */
  18816. export interface PointerTouch {
  18817. /**
  18818. * X coordinate of touch.
  18819. */
  18820. x: number;
  18821. /**
  18822. * Y coordinate of touch.
  18823. */
  18824. y: number;
  18825. /**
  18826. * Id of touch. Unique for each finger.
  18827. */
  18828. pointerId: number;
  18829. /**
  18830. * Event type passed from DOM.
  18831. */
  18832. type: any;
  18833. }
  18834. }
  18835. declare module BABYLON {
  18836. /**
  18837. * Manage the mouse inputs to control the movement of a free camera.
  18838. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18839. */
  18840. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18841. /**
  18842. * Define if touch is enabled in the mouse input
  18843. */
  18844. touchEnabled: boolean;
  18845. /**
  18846. * Defines the camera the input is attached to.
  18847. */
  18848. camera: FreeCamera;
  18849. /**
  18850. * Defines the buttons associated with the input to handle camera move.
  18851. */
  18852. buttons: number[];
  18853. /**
  18854. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18855. */
  18856. angularSensibility: number;
  18857. private _pointerInput;
  18858. private _onMouseMove;
  18859. private _observer;
  18860. private previousPosition;
  18861. /**
  18862. * Observable for when a pointer move event occurs containing the move offset
  18863. */
  18864. onPointerMovedObservable: Observable<{
  18865. offsetX: number;
  18866. offsetY: number;
  18867. }>;
  18868. /**
  18869. * @hidden
  18870. * If the camera should be rotated automatically based on pointer movement
  18871. */
  18872. _allowCameraRotation: boolean;
  18873. /**
  18874. * Manage the mouse inputs to control the movement of a free camera.
  18875. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18876. * @param touchEnabled Defines if touch is enabled or not
  18877. */
  18878. constructor(
  18879. /**
  18880. * Define if touch is enabled in the mouse input
  18881. */
  18882. touchEnabled?: boolean);
  18883. /**
  18884. * Attach the input controls to a specific dom element to get the input from.
  18885. * @param element Defines the element the controls should be listened from
  18886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18887. */
  18888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18889. /**
  18890. * Called on JS contextmenu event.
  18891. * Override this method to provide functionality.
  18892. */
  18893. protected onContextMenu(evt: PointerEvent): void;
  18894. /**
  18895. * Detach the current controls from the specified dom element.
  18896. * @param element Defines the element to stop listening the inputs from
  18897. */
  18898. detachControl(element: Nullable<HTMLElement>): void;
  18899. /**
  18900. * Gets the class name of the current intput.
  18901. * @returns the class name
  18902. */
  18903. getClassName(): string;
  18904. /**
  18905. * Get the friendly name associated with the input class.
  18906. * @returns the input friendly name
  18907. */
  18908. getSimpleName(): string;
  18909. }
  18910. }
  18911. declare module BABYLON {
  18912. /**
  18913. * Manage the touch inputs to control the movement of a free camera.
  18914. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18915. */
  18916. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18917. /**
  18918. * Define if mouse events can be treated as touch events
  18919. */
  18920. allowMouse: boolean;
  18921. /**
  18922. * Defines the camera the input is attached to.
  18923. */
  18924. camera: FreeCamera;
  18925. /**
  18926. * Defines the touch sensibility for rotation.
  18927. * The higher the faster.
  18928. */
  18929. touchAngularSensibility: number;
  18930. /**
  18931. * Defines the touch sensibility for move.
  18932. * The higher the faster.
  18933. */
  18934. touchMoveSensibility: number;
  18935. private _offsetX;
  18936. private _offsetY;
  18937. private _pointerPressed;
  18938. private _pointerInput;
  18939. private _observer;
  18940. private _onLostFocus;
  18941. /**
  18942. * Manage the touch inputs to control the movement of a free camera.
  18943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18944. * @param allowMouse Defines if mouse events can be treated as touch events
  18945. */
  18946. constructor(
  18947. /**
  18948. * Define if mouse events can be treated as touch events
  18949. */
  18950. allowMouse?: boolean);
  18951. /**
  18952. * Attach the input controls to a specific dom element to get the input from.
  18953. * @param element Defines the element the controls should be listened from
  18954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18955. */
  18956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18957. /**
  18958. * Detach the current controls from the specified dom element.
  18959. * @param element Defines the element to stop listening the inputs from
  18960. */
  18961. detachControl(element: Nullable<HTMLElement>): void;
  18962. /**
  18963. * Update the current camera state depending on the inputs that have been used this frame.
  18964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18965. */
  18966. checkInputs(): void;
  18967. /**
  18968. * Gets the class name of the current intput.
  18969. * @returns the class name
  18970. */
  18971. getClassName(): string;
  18972. /**
  18973. * Get the friendly name associated with the input class.
  18974. * @returns the input friendly name
  18975. */
  18976. getSimpleName(): string;
  18977. }
  18978. }
  18979. declare module BABYLON {
  18980. /**
  18981. * Default Inputs manager for the FreeCamera.
  18982. * It groups all the default supported inputs for ease of use.
  18983. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18984. */
  18985. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18986. /**
  18987. * @hidden
  18988. */
  18989. _mouseInput: Nullable<FreeCameraMouseInput>;
  18990. /**
  18991. * Instantiates a new FreeCameraInputsManager.
  18992. * @param camera Defines the camera the inputs belong to
  18993. */
  18994. constructor(camera: FreeCamera);
  18995. /**
  18996. * Add keyboard input support to the input manager.
  18997. * @returns the current input manager
  18998. */
  18999. addKeyboard(): FreeCameraInputsManager;
  19000. /**
  19001. * Add mouse input support to the input manager.
  19002. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19003. * @returns the current input manager
  19004. */
  19005. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19006. /**
  19007. * Removes the mouse input support from the manager
  19008. * @returns the current input manager
  19009. */
  19010. removeMouse(): FreeCameraInputsManager;
  19011. /**
  19012. * Add touch input support to the input manager.
  19013. * @returns the current input manager
  19014. */
  19015. addTouch(): FreeCameraInputsManager;
  19016. /**
  19017. * Remove all attached input methods from a camera
  19018. */
  19019. clear(): void;
  19020. }
  19021. }
  19022. declare module BABYLON {
  19023. /**
  19024. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19025. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19026. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19027. */
  19028. export class FreeCamera extends TargetCamera {
  19029. /**
  19030. * Define the collision ellipsoid of the camera.
  19031. * This is helpful to simulate a camera body like the player body around the camera
  19032. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19033. */
  19034. ellipsoid: Vector3;
  19035. /**
  19036. * Define an offset for the position of the ellipsoid around the camera.
  19037. * This can be helpful to determine the center of the body near the gravity center of the body
  19038. * instead of its head.
  19039. */
  19040. ellipsoidOffset: Vector3;
  19041. /**
  19042. * Enable or disable collisions of the camera with the rest of the scene objects.
  19043. */
  19044. checkCollisions: boolean;
  19045. /**
  19046. * Enable or disable gravity on the camera.
  19047. */
  19048. applyGravity: boolean;
  19049. /**
  19050. * Define the input manager associated to the camera.
  19051. */
  19052. inputs: FreeCameraInputsManager;
  19053. /**
  19054. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19055. * Higher values reduce sensitivity.
  19056. */
  19057. get angularSensibility(): number;
  19058. /**
  19059. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19060. * Higher values reduce sensitivity.
  19061. */
  19062. set angularSensibility(value: number);
  19063. /**
  19064. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19065. */
  19066. get keysUp(): number[];
  19067. set keysUp(value: number[]);
  19068. /**
  19069. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19070. */
  19071. get keysUpward(): number[];
  19072. set keysUpward(value: number[]);
  19073. /**
  19074. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19075. */
  19076. get keysDown(): number[];
  19077. set keysDown(value: number[]);
  19078. /**
  19079. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19080. */
  19081. get keysDownward(): number[];
  19082. set keysDownward(value: number[]);
  19083. /**
  19084. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19085. */
  19086. get keysLeft(): number[];
  19087. set keysLeft(value: number[]);
  19088. /**
  19089. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19090. */
  19091. get keysRight(): number[];
  19092. set keysRight(value: number[]);
  19093. /**
  19094. * Event raised when the camera collide with a mesh in the scene.
  19095. */
  19096. onCollide: (collidedMesh: AbstractMesh) => void;
  19097. private _collider;
  19098. private _needMoveForGravity;
  19099. private _oldPosition;
  19100. private _diffPosition;
  19101. private _newPosition;
  19102. /** @hidden */
  19103. _localDirection: Vector3;
  19104. /** @hidden */
  19105. _transformedDirection: Vector3;
  19106. /**
  19107. * Instantiates a Free Camera.
  19108. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19109. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19110. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19111. * @param name Define the name of the camera in the scene
  19112. * @param position Define the start position of the camera in the scene
  19113. * @param scene Define the scene the camera belongs to
  19114. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19115. */
  19116. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19117. /**
  19118. * Attached controls to the current camera.
  19119. * @param element Defines the element the controls should be listened from
  19120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19121. */
  19122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19123. /**
  19124. * Detach the current controls from the camera.
  19125. * The camera will stop reacting to inputs.
  19126. * @param element Defines the element to stop listening the inputs from
  19127. */
  19128. detachControl(element: HTMLElement): void;
  19129. private _collisionMask;
  19130. /**
  19131. * Define a collision mask to limit the list of object the camera can collide with
  19132. */
  19133. get collisionMask(): number;
  19134. set collisionMask(mask: number);
  19135. /** @hidden */
  19136. _collideWithWorld(displacement: Vector3): void;
  19137. private _onCollisionPositionChange;
  19138. /** @hidden */
  19139. _checkInputs(): void;
  19140. /** @hidden */
  19141. _decideIfNeedsToMove(): boolean;
  19142. /** @hidden */
  19143. _updatePosition(): void;
  19144. /**
  19145. * Destroy the camera and release the current resources hold by it.
  19146. */
  19147. dispose(): void;
  19148. /**
  19149. * Gets the current object class name.
  19150. * @return the class name
  19151. */
  19152. getClassName(): string;
  19153. }
  19154. }
  19155. declare module BABYLON {
  19156. /**
  19157. * Represents a gamepad control stick position
  19158. */
  19159. export class StickValues {
  19160. /**
  19161. * The x component of the control stick
  19162. */
  19163. x: number;
  19164. /**
  19165. * The y component of the control stick
  19166. */
  19167. y: number;
  19168. /**
  19169. * Initializes the gamepad x and y control stick values
  19170. * @param x The x component of the gamepad control stick value
  19171. * @param y The y component of the gamepad control stick value
  19172. */
  19173. constructor(
  19174. /**
  19175. * The x component of the control stick
  19176. */
  19177. x: number,
  19178. /**
  19179. * The y component of the control stick
  19180. */
  19181. y: number);
  19182. }
  19183. /**
  19184. * An interface which manages callbacks for gamepad button changes
  19185. */
  19186. export interface GamepadButtonChanges {
  19187. /**
  19188. * Called when a gamepad has been changed
  19189. */
  19190. changed: boolean;
  19191. /**
  19192. * Called when a gamepad press event has been triggered
  19193. */
  19194. pressChanged: boolean;
  19195. /**
  19196. * Called when a touch event has been triggered
  19197. */
  19198. touchChanged: boolean;
  19199. /**
  19200. * Called when a value has changed
  19201. */
  19202. valueChanged: boolean;
  19203. }
  19204. /**
  19205. * Represents a gamepad
  19206. */
  19207. export class Gamepad {
  19208. /**
  19209. * The id of the gamepad
  19210. */
  19211. id: string;
  19212. /**
  19213. * The index of the gamepad
  19214. */
  19215. index: number;
  19216. /**
  19217. * The browser gamepad
  19218. */
  19219. browserGamepad: any;
  19220. /**
  19221. * Specifies what type of gamepad this represents
  19222. */
  19223. type: number;
  19224. private _leftStick;
  19225. private _rightStick;
  19226. /** @hidden */
  19227. _isConnected: boolean;
  19228. private _leftStickAxisX;
  19229. private _leftStickAxisY;
  19230. private _rightStickAxisX;
  19231. private _rightStickAxisY;
  19232. /**
  19233. * Triggered when the left control stick has been changed
  19234. */
  19235. private _onleftstickchanged;
  19236. /**
  19237. * Triggered when the right control stick has been changed
  19238. */
  19239. private _onrightstickchanged;
  19240. /**
  19241. * Represents a gamepad controller
  19242. */
  19243. static GAMEPAD: number;
  19244. /**
  19245. * Represents a generic controller
  19246. */
  19247. static GENERIC: number;
  19248. /**
  19249. * Represents an XBox controller
  19250. */
  19251. static XBOX: number;
  19252. /**
  19253. * Represents a pose-enabled controller
  19254. */
  19255. static POSE_ENABLED: number;
  19256. /**
  19257. * Represents an Dual Shock controller
  19258. */
  19259. static DUALSHOCK: number;
  19260. /**
  19261. * Specifies whether the left control stick should be Y-inverted
  19262. */
  19263. protected _invertLeftStickY: boolean;
  19264. /**
  19265. * Specifies if the gamepad has been connected
  19266. */
  19267. get isConnected(): boolean;
  19268. /**
  19269. * Initializes the gamepad
  19270. * @param id The id of the gamepad
  19271. * @param index The index of the gamepad
  19272. * @param browserGamepad The browser gamepad
  19273. * @param leftStickX The x component of the left joystick
  19274. * @param leftStickY The y component of the left joystick
  19275. * @param rightStickX The x component of the right joystick
  19276. * @param rightStickY The y component of the right joystick
  19277. */
  19278. constructor(
  19279. /**
  19280. * The id of the gamepad
  19281. */
  19282. id: string,
  19283. /**
  19284. * The index of the gamepad
  19285. */
  19286. index: number,
  19287. /**
  19288. * The browser gamepad
  19289. */
  19290. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19291. /**
  19292. * Callback triggered when the left joystick has changed
  19293. * @param callback
  19294. */
  19295. onleftstickchanged(callback: (values: StickValues) => void): void;
  19296. /**
  19297. * Callback triggered when the right joystick has changed
  19298. * @param callback
  19299. */
  19300. onrightstickchanged(callback: (values: StickValues) => void): void;
  19301. /**
  19302. * Gets the left joystick
  19303. */
  19304. get leftStick(): StickValues;
  19305. /**
  19306. * Sets the left joystick values
  19307. */
  19308. set leftStick(newValues: StickValues);
  19309. /**
  19310. * Gets the right joystick
  19311. */
  19312. get rightStick(): StickValues;
  19313. /**
  19314. * Sets the right joystick value
  19315. */
  19316. set rightStick(newValues: StickValues);
  19317. /**
  19318. * Updates the gamepad joystick positions
  19319. */
  19320. update(): void;
  19321. /**
  19322. * Disposes the gamepad
  19323. */
  19324. dispose(): void;
  19325. }
  19326. /**
  19327. * Represents a generic gamepad
  19328. */
  19329. export class GenericPad extends Gamepad {
  19330. private _buttons;
  19331. private _onbuttondown;
  19332. private _onbuttonup;
  19333. /**
  19334. * Observable triggered when a button has been pressed
  19335. */
  19336. onButtonDownObservable: Observable<number>;
  19337. /**
  19338. * Observable triggered when a button has been released
  19339. */
  19340. onButtonUpObservable: Observable<number>;
  19341. /**
  19342. * Callback triggered when a button has been pressed
  19343. * @param callback Called when a button has been pressed
  19344. */
  19345. onbuttondown(callback: (buttonPressed: number) => void): void;
  19346. /**
  19347. * Callback triggered when a button has been released
  19348. * @param callback Called when a button has been released
  19349. */
  19350. onbuttonup(callback: (buttonReleased: number) => void): void;
  19351. /**
  19352. * Initializes the generic gamepad
  19353. * @param id The id of the generic gamepad
  19354. * @param index The index of the generic gamepad
  19355. * @param browserGamepad The browser gamepad
  19356. */
  19357. constructor(id: string, index: number, browserGamepad: any);
  19358. private _setButtonValue;
  19359. /**
  19360. * Updates the generic gamepad
  19361. */
  19362. update(): void;
  19363. /**
  19364. * Disposes the generic gamepad
  19365. */
  19366. dispose(): void;
  19367. }
  19368. }
  19369. declare module BABYLON {
  19370. /**
  19371. * Defines the types of pose enabled controllers that are supported
  19372. */
  19373. export enum PoseEnabledControllerType {
  19374. /**
  19375. * HTC Vive
  19376. */
  19377. VIVE = 0,
  19378. /**
  19379. * Oculus Rift
  19380. */
  19381. OCULUS = 1,
  19382. /**
  19383. * Windows mixed reality
  19384. */
  19385. WINDOWS = 2,
  19386. /**
  19387. * Samsung gear VR
  19388. */
  19389. GEAR_VR = 3,
  19390. /**
  19391. * Google Daydream
  19392. */
  19393. DAYDREAM = 4,
  19394. /**
  19395. * Generic
  19396. */
  19397. GENERIC = 5
  19398. }
  19399. /**
  19400. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19401. */
  19402. export interface MutableGamepadButton {
  19403. /**
  19404. * Value of the button/trigger
  19405. */
  19406. value: number;
  19407. /**
  19408. * If the button/trigger is currently touched
  19409. */
  19410. touched: boolean;
  19411. /**
  19412. * If the button/trigger is currently pressed
  19413. */
  19414. pressed: boolean;
  19415. }
  19416. /**
  19417. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19418. * @hidden
  19419. */
  19420. export interface ExtendedGamepadButton extends GamepadButton {
  19421. /**
  19422. * If the button/trigger is currently pressed
  19423. */
  19424. readonly pressed: boolean;
  19425. /**
  19426. * If the button/trigger is currently touched
  19427. */
  19428. readonly touched: boolean;
  19429. /**
  19430. * Value of the button/trigger
  19431. */
  19432. readonly value: number;
  19433. }
  19434. /** @hidden */
  19435. export interface _GamePadFactory {
  19436. /**
  19437. * Returns whether or not the current gamepad can be created for this type of controller.
  19438. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19439. * @returns true if it can be created, otherwise false
  19440. */
  19441. canCreate(gamepadInfo: any): boolean;
  19442. /**
  19443. * Creates a new instance of the Gamepad.
  19444. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19445. * @returns the new gamepad instance
  19446. */
  19447. create(gamepadInfo: any): Gamepad;
  19448. }
  19449. /**
  19450. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19451. */
  19452. export class PoseEnabledControllerHelper {
  19453. /** @hidden */
  19454. static _ControllerFactories: _GamePadFactory[];
  19455. /** @hidden */
  19456. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19457. /**
  19458. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19459. * @param vrGamepad the gamepad to initialized
  19460. * @returns a vr controller of the type the gamepad identified as
  19461. */
  19462. static InitiateController(vrGamepad: any): Gamepad;
  19463. }
  19464. /**
  19465. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19466. */
  19467. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19468. /**
  19469. * If the controller is used in a webXR session
  19470. */
  19471. isXR: boolean;
  19472. private _deviceRoomPosition;
  19473. private _deviceRoomRotationQuaternion;
  19474. /**
  19475. * The device position in babylon space
  19476. */
  19477. devicePosition: Vector3;
  19478. /**
  19479. * The device rotation in babylon space
  19480. */
  19481. deviceRotationQuaternion: Quaternion;
  19482. /**
  19483. * The scale factor of the device in babylon space
  19484. */
  19485. deviceScaleFactor: number;
  19486. /**
  19487. * (Likely devicePosition should be used instead) The device position in its room space
  19488. */
  19489. position: Vector3;
  19490. /**
  19491. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19492. */
  19493. rotationQuaternion: Quaternion;
  19494. /**
  19495. * The type of controller (Eg. Windows mixed reality)
  19496. */
  19497. controllerType: PoseEnabledControllerType;
  19498. protected _calculatedPosition: Vector3;
  19499. private _calculatedRotation;
  19500. /**
  19501. * The raw pose from the device
  19502. */
  19503. rawPose: DevicePose;
  19504. private _trackPosition;
  19505. private _maxRotationDistFromHeadset;
  19506. private _draggedRoomRotation;
  19507. /**
  19508. * @hidden
  19509. */
  19510. _disableTrackPosition(fixedPosition: Vector3): void;
  19511. /**
  19512. * Internal, the mesh attached to the controller
  19513. * @hidden
  19514. */
  19515. _mesh: Nullable<AbstractMesh>;
  19516. private _poseControlledCamera;
  19517. private _leftHandSystemQuaternion;
  19518. /**
  19519. * Internal, matrix used to convert room space to babylon space
  19520. * @hidden
  19521. */
  19522. _deviceToWorld: Matrix;
  19523. /**
  19524. * Node to be used when casting a ray from the controller
  19525. * @hidden
  19526. */
  19527. _pointingPoseNode: Nullable<TransformNode>;
  19528. /**
  19529. * Name of the child mesh that can be used to cast a ray from the controller
  19530. */
  19531. static readonly POINTING_POSE: string;
  19532. /**
  19533. * Creates a new PoseEnabledController from a gamepad
  19534. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19535. */
  19536. constructor(browserGamepad: any);
  19537. private _workingMatrix;
  19538. /**
  19539. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19540. */
  19541. update(): void;
  19542. /**
  19543. * Updates only the pose device and mesh without doing any button event checking
  19544. */
  19545. protected _updatePoseAndMesh(): void;
  19546. /**
  19547. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19548. * @param poseData raw pose fromthe device
  19549. */
  19550. updateFromDevice(poseData: DevicePose): void;
  19551. /**
  19552. * @hidden
  19553. */
  19554. _meshAttachedObservable: Observable<AbstractMesh>;
  19555. /**
  19556. * Attaches a mesh to the controller
  19557. * @param mesh the mesh to be attached
  19558. */
  19559. attachToMesh(mesh: AbstractMesh): void;
  19560. /**
  19561. * Attaches the controllers mesh to a camera
  19562. * @param camera the camera the mesh should be attached to
  19563. */
  19564. attachToPoseControlledCamera(camera: TargetCamera): void;
  19565. /**
  19566. * Disposes of the controller
  19567. */
  19568. dispose(): void;
  19569. /**
  19570. * The mesh that is attached to the controller
  19571. */
  19572. get mesh(): Nullable<AbstractMesh>;
  19573. /**
  19574. * Gets the ray of the controller in the direction the controller is pointing
  19575. * @param length the length the resulting ray should be
  19576. * @returns a ray in the direction the controller is pointing
  19577. */
  19578. getForwardRay(length?: number): Ray;
  19579. }
  19580. }
  19581. declare module BABYLON {
  19582. /**
  19583. * Defines the WebVRController object that represents controllers tracked in 3D space
  19584. */
  19585. export abstract class WebVRController extends PoseEnabledController {
  19586. /**
  19587. * Internal, the default controller model for the controller
  19588. */
  19589. protected _defaultModel: Nullable<AbstractMesh>;
  19590. /**
  19591. * Fired when the trigger state has changed
  19592. */
  19593. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19594. /**
  19595. * Fired when the main button state has changed
  19596. */
  19597. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19598. /**
  19599. * Fired when the secondary button state has changed
  19600. */
  19601. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19602. /**
  19603. * Fired when the pad state has changed
  19604. */
  19605. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19606. /**
  19607. * Fired when controllers stick values have changed
  19608. */
  19609. onPadValuesChangedObservable: Observable<StickValues>;
  19610. /**
  19611. * Array of button availible on the controller
  19612. */
  19613. protected _buttons: Array<MutableGamepadButton>;
  19614. private _onButtonStateChange;
  19615. /**
  19616. * Fired when a controller button's state has changed
  19617. * @param callback the callback containing the button that was modified
  19618. */
  19619. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19620. /**
  19621. * X and Y axis corresponding to the controllers joystick
  19622. */
  19623. pad: StickValues;
  19624. /**
  19625. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19626. */
  19627. hand: string;
  19628. /**
  19629. * The default controller model for the controller
  19630. */
  19631. get defaultModel(): Nullable<AbstractMesh>;
  19632. /**
  19633. * Creates a new WebVRController from a gamepad
  19634. * @param vrGamepad the gamepad that the WebVRController should be created from
  19635. */
  19636. constructor(vrGamepad: any);
  19637. /**
  19638. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19639. */
  19640. update(): void;
  19641. /**
  19642. * Function to be called when a button is modified
  19643. */
  19644. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19645. /**
  19646. * Loads a mesh and attaches it to the controller
  19647. * @param scene the scene the mesh should be added to
  19648. * @param meshLoaded callback for when the mesh has been loaded
  19649. */
  19650. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19651. private _setButtonValue;
  19652. private _changes;
  19653. private _checkChanges;
  19654. /**
  19655. * Disposes of th webVRCOntroller
  19656. */
  19657. dispose(): void;
  19658. }
  19659. }
  19660. declare module BABYLON {
  19661. /**
  19662. * The HemisphericLight simulates the ambient environment light,
  19663. * so the passed direction is the light reflection direction, not the incoming direction.
  19664. */
  19665. export class HemisphericLight extends Light {
  19666. /**
  19667. * The groundColor is the light in the opposite direction to the one specified during creation.
  19668. * 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.
  19669. */
  19670. groundColor: Color3;
  19671. /**
  19672. * The light reflection direction, not the incoming direction.
  19673. */
  19674. direction: Vector3;
  19675. /**
  19676. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19677. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19678. * The HemisphericLight can't cast shadows.
  19679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19680. * @param name The friendly name of the light
  19681. * @param direction The direction of the light reflection
  19682. * @param scene The scene the light belongs to
  19683. */
  19684. constructor(name: string, direction: Vector3, scene: Scene);
  19685. protected _buildUniformLayout(): void;
  19686. /**
  19687. * Returns the string "HemisphericLight".
  19688. * @return The class name
  19689. */
  19690. getClassName(): string;
  19691. /**
  19692. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19693. * Returns the updated direction.
  19694. * @param target The target the direction should point to
  19695. * @return The computed direction
  19696. */
  19697. setDirectionToTarget(target: Vector3): Vector3;
  19698. /**
  19699. * Returns the shadow generator associated to the light.
  19700. * @returns Always null for hemispheric lights because it does not support shadows.
  19701. */
  19702. getShadowGenerator(): Nullable<IShadowGenerator>;
  19703. /**
  19704. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19705. * @param effect The effect to update
  19706. * @param lightIndex The index of the light in the effect to update
  19707. * @returns The hemispheric light
  19708. */
  19709. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19710. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19711. /**
  19712. * Computes the world matrix of the node
  19713. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19714. * @param useWasUpdatedFlag defines a reserved property
  19715. * @returns the world matrix
  19716. */
  19717. computeWorldMatrix(): Matrix;
  19718. /**
  19719. * Returns the integer 3.
  19720. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19721. */
  19722. getTypeID(): number;
  19723. /**
  19724. * Prepares the list of defines specific to the light type.
  19725. * @param defines the list of defines
  19726. * @param lightIndex defines the index of the light for the effect
  19727. */
  19728. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19729. }
  19730. }
  19731. declare module BABYLON {
  19732. /** @hidden */
  19733. export var vrMultiviewToSingleviewPixelShader: {
  19734. name: string;
  19735. shader: string;
  19736. };
  19737. }
  19738. declare module BABYLON {
  19739. /**
  19740. * Renders to multiple views with a single draw call
  19741. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19742. */
  19743. export class MultiviewRenderTarget extends RenderTargetTexture {
  19744. /**
  19745. * Creates a multiview render target
  19746. * @param scene scene used with the render target
  19747. * @param size the size of the render target (used for each view)
  19748. */
  19749. constructor(scene: Scene, size?: number | {
  19750. width: number;
  19751. height: number;
  19752. } | {
  19753. ratio: number;
  19754. });
  19755. /**
  19756. * @hidden
  19757. * @param faceIndex the face index, if its a cube texture
  19758. */
  19759. _bindFrameBuffer(faceIndex?: number): void;
  19760. /**
  19761. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19762. * @returns the view count
  19763. */
  19764. getViewCount(): number;
  19765. }
  19766. }
  19767. declare module BABYLON {
  19768. interface Engine {
  19769. /**
  19770. * Creates a new multiview render target
  19771. * @param width defines the width of the texture
  19772. * @param height defines the height of the texture
  19773. * @returns the created multiview texture
  19774. */
  19775. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19776. /**
  19777. * Binds a multiview framebuffer to be drawn to
  19778. * @param multiviewTexture texture to bind
  19779. */
  19780. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19781. }
  19782. interface Camera {
  19783. /**
  19784. * @hidden
  19785. * 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)
  19786. */
  19787. _useMultiviewToSingleView: boolean;
  19788. /**
  19789. * @hidden
  19790. * 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)
  19791. */
  19792. _multiviewTexture: Nullable<RenderTargetTexture>;
  19793. /**
  19794. * @hidden
  19795. * ensures the multiview texture of the camera exists and has the specified width/height
  19796. * @param width height to set on the multiview texture
  19797. * @param height width to set on the multiview texture
  19798. */
  19799. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19800. }
  19801. interface Scene {
  19802. /** @hidden */
  19803. _transformMatrixR: Matrix;
  19804. /** @hidden */
  19805. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19806. /** @hidden */
  19807. _createMultiviewUbo(): void;
  19808. /** @hidden */
  19809. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19810. /** @hidden */
  19811. _renderMultiviewToSingleView(camera: Camera): void;
  19812. }
  19813. }
  19814. declare module BABYLON {
  19815. /**
  19816. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19817. * This will not be used for webXR as it supports displaying texture arrays directly
  19818. */
  19819. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19820. /**
  19821. * Gets a string identifying the name of the class
  19822. * @returns "VRMultiviewToSingleviewPostProcess" string
  19823. */
  19824. getClassName(): string;
  19825. /**
  19826. * Initializes a VRMultiviewToSingleview
  19827. * @param name name of the post process
  19828. * @param camera camera to be applied to
  19829. * @param scaleFactor scaling factor to the size of the output texture
  19830. */
  19831. constructor(name: string, camera: Camera, scaleFactor: number);
  19832. }
  19833. }
  19834. declare module BABYLON {
  19835. /**
  19836. * Interface used to define additional presentation attributes
  19837. */
  19838. export interface IVRPresentationAttributes {
  19839. /**
  19840. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19841. */
  19842. highRefreshRate: boolean;
  19843. /**
  19844. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19845. */
  19846. foveationLevel: number;
  19847. }
  19848. interface Engine {
  19849. /** @hidden */
  19850. _vrDisplay: any;
  19851. /** @hidden */
  19852. _vrSupported: boolean;
  19853. /** @hidden */
  19854. _oldSize: Size;
  19855. /** @hidden */
  19856. _oldHardwareScaleFactor: number;
  19857. /** @hidden */
  19858. _vrExclusivePointerMode: boolean;
  19859. /** @hidden */
  19860. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19861. /** @hidden */
  19862. _onVRDisplayPointerRestricted: () => void;
  19863. /** @hidden */
  19864. _onVRDisplayPointerUnrestricted: () => void;
  19865. /** @hidden */
  19866. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19867. /** @hidden */
  19868. _onVrDisplayDisconnect: Nullable<() => void>;
  19869. /** @hidden */
  19870. _onVrDisplayPresentChange: Nullable<() => void>;
  19871. /**
  19872. * Observable signaled when VR display mode changes
  19873. */
  19874. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19875. /**
  19876. * Observable signaled when VR request present is complete
  19877. */
  19878. onVRRequestPresentComplete: Observable<boolean>;
  19879. /**
  19880. * Observable signaled when VR request present starts
  19881. */
  19882. onVRRequestPresentStart: Observable<Engine>;
  19883. /**
  19884. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19885. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19886. */
  19887. isInVRExclusivePointerMode: boolean;
  19888. /**
  19889. * Gets a boolean indicating if a webVR device was detected
  19890. * @returns true if a webVR device was detected
  19891. */
  19892. isVRDevicePresent(): boolean;
  19893. /**
  19894. * Gets the current webVR device
  19895. * @returns the current webVR device (or null)
  19896. */
  19897. getVRDevice(): any;
  19898. /**
  19899. * Initializes a webVR display and starts listening to display change events
  19900. * The onVRDisplayChangedObservable will be notified upon these changes
  19901. * @returns A promise containing a VRDisplay and if vr is supported
  19902. */
  19903. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19904. /** @hidden */
  19905. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19906. /**
  19907. * Gets or sets the presentation attributes used to configure VR rendering
  19908. */
  19909. vrPresentationAttributes?: IVRPresentationAttributes;
  19910. /**
  19911. * Call this function to switch to webVR mode
  19912. * Will do nothing if webVR is not supported or if there is no webVR device
  19913. * @param options the webvr options provided to the camera. mainly used for multiview
  19914. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19915. */
  19916. enableVR(options: WebVROptions): void;
  19917. /** @hidden */
  19918. _onVRFullScreenTriggered(): void;
  19919. }
  19920. }
  19921. declare module BABYLON {
  19922. /**
  19923. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19924. * IMPORTANT!! The data is right-hand data.
  19925. * @export
  19926. * @interface DevicePose
  19927. */
  19928. export interface DevicePose {
  19929. /**
  19930. * The position of the device, values in array are [x,y,z].
  19931. */
  19932. readonly position: Nullable<Float32Array>;
  19933. /**
  19934. * The linearVelocity of the device, values in array are [x,y,z].
  19935. */
  19936. readonly linearVelocity: Nullable<Float32Array>;
  19937. /**
  19938. * The linearAcceleration of the device, values in array are [x,y,z].
  19939. */
  19940. readonly linearAcceleration: Nullable<Float32Array>;
  19941. /**
  19942. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19943. */
  19944. readonly orientation: Nullable<Float32Array>;
  19945. /**
  19946. * The angularVelocity of the device, values in array are [x,y,z].
  19947. */
  19948. readonly angularVelocity: Nullable<Float32Array>;
  19949. /**
  19950. * The angularAcceleration of the device, values in array are [x,y,z].
  19951. */
  19952. readonly angularAcceleration: Nullable<Float32Array>;
  19953. }
  19954. /**
  19955. * Interface representing a pose controlled object in Babylon.
  19956. * A pose controlled object has both regular pose values as well as pose values
  19957. * from an external device such as a VR head mounted display
  19958. */
  19959. export interface PoseControlled {
  19960. /**
  19961. * The position of the object in babylon space.
  19962. */
  19963. position: Vector3;
  19964. /**
  19965. * The rotation quaternion of the object in babylon space.
  19966. */
  19967. rotationQuaternion: Quaternion;
  19968. /**
  19969. * The position of the device in babylon space.
  19970. */
  19971. devicePosition?: Vector3;
  19972. /**
  19973. * The rotation quaternion of the device in babylon space.
  19974. */
  19975. deviceRotationQuaternion: Quaternion;
  19976. /**
  19977. * The raw pose coming from the device.
  19978. */
  19979. rawPose: Nullable<DevicePose>;
  19980. /**
  19981. * The scale of the device to be used when translating from device space to babylon space.
  19982. */
  19983. deviceScaleFactor: number;
  19984. /**
  19985. * Updates the poseControlled values based on the input device pose.
  19986. * @param poseData the pose data to update the object with
  19987. */
  19988. updateFromDevice(poseData: DevicePose): void;
  19989. }
  19990. /**
  19991. * Set of options to customize the webVRCamera
  19992. */
  19993. export interface WebVROptions {
  19994. /**
  19995. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19996. */
  19997. trackPosition?: boolean;
  19998. /**
  19999. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20000. */
  20001. positionScale?: number;
  20002. /**
  20003. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20004. */
  20005. displayName?: string;
  20006. /**
  20007. * Should the native controller meshes be initialized. (default: true)
  20008. */
  20009. controllerMeshes?: boolean;
  20010. /**
  20011. * Creating a default HemiLight only on controllers. (default: true)
  20012. */
  20013. defaultLightingOnControllers?: boolean;
  20014. /**
  20015. * If you don't want to use the default VR button of the helper. (default: false)
  20016. */
  20017. useCustomVRButton?: boolean;
  20018. /**
  20019. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20020. */
  20021. customVRButton?: HTMLButtonElement;
  20022. /**
  20023. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20024. */
  20025. rayLength?: number;
  20026. /**
  20027. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20028. */
  20029. defaultHeight?: number;
  20030. /**
  20031. * If multiview should be used if availible (default: false)
  20032. */
  20033. useMultiview?: boolean;
  20034. }
  20035. /**
  20036. * This represents a WebVR camera.
  20037. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20038. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20039. */
  20040. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20041. private webVROptions;
  20042. /**
  20043. * @hidden
  20044. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20045. */
  20046. _vrDevice: any;
  20047. /**
  20048. * The rawPose of the vrDevice.
  20049. */
  20050. rawPose: Nullable<DevicePose>;
  20051. private _onVREnabled;
  20052. private _specsVersion;
  20053. private _attached;
  20054. private _frameData;
  20055. protected _descendants: Array<Node>;
  20056. private _deviceRoomPosition;
  20057. /** @hidden */
  20058. _deviceRoomRotationQuaternion: Quaternion;
  20059. private _standingMatrix;
  20060. /**
  20061. * Represents device position in babylon space.
  20062. */
  20063. devicePosition: Vector3;
  20064. /**
  20065. * Represents device rotation in babylon space.
  20066. */
  20067. deviceRotationQuaternion: Quaternion;
  20068. /**
  20069. * The scale of the device to be used when translating from device space to babylon space.
  20070. */
  20071. deviceScaleFactor: number;
  20072. private _deviceToWorld;
  20073. private _worldToDevice;
  20074. /**
  20075. * References to the webVR controllers for the vrDevice.
  20076. */
  20077. controllers: Array<WebVRController>;
  20078. /**
  20079. * Emits an event when a controller is attached.
  20080. */
  20081. onControllersAttachedObservable: Observable<WebVRController[]>;
  20082. /**
  20083. * Emits an event when a controller's mesh has been loaded;
  20084. */
  20085. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20086. /**
  20087. * Emits an event when the HMD's pose has been updated.
  20088. */
  20089. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20090. private _poseSet;
  20091. /**
  20092. * If the rig cameras be used as parent instead of this camera.
  20093. */
  20094. rigParenting: boolean;
  20095. private _lightOnControllers;
  20096. private _defaultHeight?;
  20097. /**
  20098. * Instantiates a WebVRFreeCamera.
  20099. * @param name The name of the WebVRFreeCamera
  20100. * @param position The starting anchor position for the camera
  20101. * @param scene The scene the camera belongs to
  20102. * @param webVROptions a set of customizable options for the webVRCamera
  20103. */
  20104. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20105. /**
  20106. * Gets the device distance from the ground in meters.
  20107. * @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.
  20108. */
  20109. deviceDistanceToRoomGround(): number;
  20110. /**
  20111. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20112. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20113. */
  20114. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20115. /**
  20116. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20117. * @returns A promise with a boolean set to if the standing matrix is supported.
  20118. */
  20119. useStandingMatrixAsync(): Promise<boolean>;
  20120. /**
  20121. * Disposes the camera
  20122. */
  20123. dispose(): void;
  20124. /**
  20125. * Gets a vrController by name.
  20126. * @param name The name of the controller to retreive
  20127. * @returns the controller matching the name specified or null if not found
  20128. */
  20129. getControllerByName(name: string): Nullable<WebVRController>;
  20130. private _leftController;
  20131. /**
  20132. * The controller corresponding to the users left hand.
  20133. */
  20134. get leftController(): Nullable<WebVRController>;
  20135. private _rightController;
  20136. /**
  20137. * The controller corresponding to the users right hand.
  20138. */
  20139. get rightController(): Nullable<WebVRController>;
  20140. /**
  20141. * Casts a ray forward from the vrCamera's gaze.
  20142. * @param length Length of the ray (default: 100)
  20143. * @returns the ray corresponding to the gaze
  20144. */
  20145. getForwardRay(length?: number): Ray;
  20146. /**
  20147. * @hidden
  20148. * Updates the camera based on device's frame data
  20149. */
  20150. _checkInputs(): void;
  20151. /**
  20152. * Updates the poseControlled values based on the input device pose.
  20153. * @param poseData Pose coming from the device
  20154. */
  20155. updateFromDevice(poseData: DevicePose): void;
  20156. private _htmlElementAttached;
  20157. private _detachIfAttached;
  20158. /**
  20159. * WebVR's attach control will start broadcasting frames to the device.
  20160. * Note that in certain browsers (chrome for example) this function must be called
  20161. * within a user-interaction callback. Example:
  20162. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20163. *
  20164. * @param element html element to attach the vrDevice to
  20165. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20166. */
  20167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20168. /**
  20169. * Detaches the camera from the html element and disables VR
  20170. *
  20171. * @param element html element to detach from
  20172. */
  20173. detachControl(element: HTMLElement): void;
  20174. /**
  20175. * @returns the name of this class
  20176. */
  20177. getClassName(): string;
  20178. /**
  20179. * Calls resetPose on the vrDisplay
  20180. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20181. */
  20182. resetToCurrentRotation(): void;
  20183. /**
  20184. * @hidden
  20185. * Updates the rig cameras (left and right eye)
  20186. */
  20187. _updateRigCameras(): void;
  20188. private _workingVector;
  20189. private _oneVector;
  20190. private _workingMatrix;
  20191. private updateCacheCalled;
  20192. private _correctPositionIfNotTrackPosition;
  20193. /**
  20194. * @hidden
  20195. * Updates the cached values of the camera
  20196. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20197. */
  20198. _updateCache(ignoreParentClass?: boolean): void;
  20199. /**
  20200. * @hidden
  20201. * Get current device position in babylon world
  20202. */
  20203. _computeDevicePosition(): void;
  20204. /**
  20205. * Updates the current device position and rotation in the babylon world
  20206. */
  20207. update(): void;
  20208. /**
  20209. * @hidden
  20210. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20211. * @returns an identity matrix
  20212. */
  20213. _getViewMatrix(): Matrix;
  20214. private _tmpMatrix;
  20215. /**
  20216. * This function is called by the two RIG cameras.
  20217. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20218. * @hidden
  20219. */
  20220. _getWebVRViewMatrix(): Matrix;
  20221. /** @hidden */
  20222. _getWebVRProjectionMatrix(): Matrix;
  20223. private _onGamepadConnectedObserver;
  20224. private _onGamepadDisconnectedObserver;
  20225. private _updateCacheWhenTrackingDisabledObserver;
  20226. /**
  20227. * Initializes the controllers and their meshes
  20228. */
  20229. initControllers(): void;
  20230. }
  20231. }
  20232. declare module BABYLON {
  20233. /**
  20234. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20235. *
  20236. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20237. *
  20238. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20239. */
  20240. export class MaterialHelper {
  20241. /**
  20242. * Bind the current view position to an effect.
  20243. * @param effect The effect to be bound
  20244. * @param scene The scene the eyes position is used from
  20245. * @param variableName name of the shader variable that will hold the eye position
  20246. */
  20247. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20248. /**
  20249. * Helps preparing the defines values about the UVs in used in the effect.
  20250. * UVs are shared as much as we can accross channels in the shaders.
  20251. * @param texture The texture we are preparing the UVs for
  20252. * @param defines The defines to update
  20253. * @param key The channel key "diffuse", "specular"... used in the shader
  20254. */
  20255. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20256. /**
  20257. * Binds a texture matrix value to its corrsponding uniform
  20258. * @param texture The texture to bind the matrix for
  20259. * @param uniformBuffer The uniform buffer receivin the data
  20260. * @param key The channel key "diffuse", "specular"... used in the shader
  20261. */
  20262. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20263. /**
  20264. * Gets the current status of the fog (should it be enabled?)
  20265. * @param mesh defines the mesh to evaluate for fog support
  20266. * @param scene defines the hosting scene
  20267. * @returns true if fog must be enabled
  20268. */
  20269. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20270. /**
  20271. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20272. * @param mesh defines the current mesh
  20273. * @param scene defines the current scene
  20274. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20275. * @param pointsCloud defines if point cloud rendering has to be turned on
  20276. * @param fogEnabled defines if fog has to be turned on
  20277. * @param alphaTest defines if alpha testing has to be turned on
  20278. * @param defines defines the current list of defines
  20279. */
  20280. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20281. /**
  20282. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20283. * @param scene defines the current scene
  20284. * @param engine defines the current engine
  20285. * @param defines specifies the list of active defines
  20286. * @param useInstances defines if instances have to be turned on
  20287. * @param useClipPlane defines if clip plane have to be turned on
  20288. * @param useInstances defines if instances have to be turned on
  20289. * @param useThinInstances defines if thin instances have to be turned on
  20290. */
  20291. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20292. /**
  20293. * Prepares the defines for bones
  20294. * @param mesh The mesh containing the geometry data we will draw
  20295. * @param defines The defines to update
  20296. */
  20297. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20298. /**
  20299. * Prepares the defines for morph targets
  20300. * @param mesh The mesh containing the geometry data we will draw
  20301. * @param defines The defines to update
  20302. */
  20303. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20304. /**
  20305. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20306. * @param mesh The mesh containing the geometry data we will draw
  20307. * @param defines The defines to update
  20308. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20309. * @param useBones Precise whether bones should be used or not (override mesh info)
  20310. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20311. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20312. * @returns false if defines are considered not dirty and have not been checked
  20313. */
  20314. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20315. /**
  20316. * Prepares the defines related to multiview
  20317. * @param scene The scene we are intending to draw
  20318. * @param defines The defines to update
  20319. */
  20320. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20321. /**
  20322. * Prepares the defines related to the prepass
  20323. * @param scene The scene we are intending to draw
  20324. * @param defines The defines to update
  20325. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20326. */
  20327. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20328. /**
  20329. * Prepares the defines related to the light information passed in parameter
  20330. * @param scene The scene we are intending to draw
  20331. * @param mesh The mesh the effect is compiling for
  20332. * @param light The light the effect is compiling for
  20333. * @param lightIndex The index of the light
  20334. * @param defines The defines to update
  20335. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20336. * @param state Defines the current state regarding what is needed (normals, etc...)
  20337. */
  20338. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20339. needNormals: boolean;
  20340. needRebuild: boolean;
  20341. shadowEnabled: boolean;
  20342. specularEnabled: boolean;
  20343. lightmapMode: boolean;
  20344. }): void;
  20345. /**
  20346. * Prepares the defines related to the light information passed in parameter
  20347. * @param scene The scene we are intending to draw
  20348. * @param mesh The mesh the effect is compiling for
  20349. * @param defines The defines to update
  20350. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20351. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20352. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20353. * @returns true if normals will be required for the rest of the effect
  20354. */
  20355. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20356. /**
  20357. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20358. * @param lightIndex defines the light index
  20359. * @param uniformsList The uniform list
  20360. * @param samplersList The sampler list
  20361. * @param projectedLightTexture defines if projected texture must be used
  20362. * @param uniformBuffersList defines an optional list of uniform buffers
  20363. */
  20364. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20365. /**
  20366. * Prepares the uniforms and samplers list to be used in the effect
  20367. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20368. * @param samplersList The sampler list
  20369. * @param defines The defines helping in the list generation
  20370. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20371. */
  20372. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20373. /**
  20374. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20375. * @param defines The defines to update while falling back
  20376. * @param fallbacks The authorized effect fallbacks
  20377. * @param maxSimultaneousLights The maximum number of lights allowed
  20378. * @param rank the current rank of the Effect
  20379. * @returns The newly affected rank
  20380. */
  20381. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20382. private static _TmpMorphInfluencers;
  20383. /**
  20384. * Prepares the list of attributes required for morph targets according to the effect defines.
  20385. * @param attribs The current list of supported attribs
  20386. * @param mesh The mesh to prepare the morph targets attributes for
  20387. * @param influencers The number of influencers
  20388. */
  20389. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20390. /**
  20391. * Prepares the list of attributes required for morph targets according to the effect defines.
  20392. * @param attribs The current list of supported attribs
  20393. * @param mesh The mesh to prepare the morph targets attributes for
  20394. * @param defines The current Defines of the effect
  20395. */
  20396. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20397. /**
  20398. * Prepares the list of attributes required for bones according to the effect defines.
  20399. * @param attribs The current list of supported attribs
  20400. * @param mesh The mesh to prepare the bones attributes for
  20401. * @param defines The current Defines of the effect
  20402. * @param fallbacks The current efffect fallback strategy
  20403. */
  20404. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20405. /**
  20406. * Check and prepare the list of attributes required for instances according to the effect defines.
  20407. * @param attribs The current list of supported attribs
  20408. * @param defines The current MaterialDefines of the effect
  20409. */
  20410. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20411. /**
  20412. * Add the list of attributes required for instances to the attribs array.
  20413. * @param attribs The current list of supported attribs
  20414. */
  20415. static PushAttributesForInstances(attribs: string[]): void;
  20416. /**
  20417. * Binds the light information to the effect.
  20418. * @param light The light containing the generator
  20419. * @param effect The effect we are binding the data to
  20420. * @param lightIndex The light index in the effect used to render
  20421. */
  20422. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20423. /**
  20424. * Binds the lights information from the scene to the effect for the given mesh.
  20425. * @param light Light to bind
  20426. * @param lightIndex Light index
  20427. * @param scene The scene where the light belongs to
  20428. * @param effect The effect we are binding the data to
  20429. * @param useSpecular Defines if specular is supported
  20430. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20431. */
  20432. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20433. /**
  20434. * Binds the lights information from the scene to the effect for the given mesh.
  20435. * @param scene The scene the lights belongs to
  20436. * @param mesh The mesh we are binding the information to render
  20437. * @param effect The effect we are binding the data to
  20438. * @param defines The generated defines for the effect
  20439. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20440. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20441. */
  20442. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20443. private static _tempFogColor;
  20444. /**
  20445. * Binds the fog information from the scene to the effect for the given mesh.
  20446. * @param scene The scene the lights belongs to
  20447. * @param mesh The mesh we are binding the information to render
  20448. * @param effect The effect we are binding the data to
  20449. * @param linearSpace Defines if the fog effect is applied in linear space
  20450. */
  20451. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20452. /**
  20453. * Binds the bones information from the mesh to the effect.
  20454. * @param mesh The mesh we are binding the information to render
  20455. * @param effect The effect we are binding the data to
  20456. */
  20457. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20458. /**
  20459. * Binds the morph targets information from the mesh to the effect.
  20460. * @param abstractMesh The mesh we are binding the information to render
  20461. * @param effect The effect we are binding the data to
  20462. */
  20463. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20464. /**
  20465. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20466. * @param defines The generated defines used in the effect
  20467. * @param effect The effect we are binding the data to
  20468. * @param scene The scene we are willing to render with logarithmic scale for
  20469. */
  20470. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20471. /**
  20472. * Binds the clip plane information from the scene to the effect.
  20473. * @param scene The scene the clip plane information are extracted from
  20474. * @param effect The effect we are binding the data to
  20475. */
  20476. static BindClipPlane(effect: Effect, scene: Scene): void;
  20477. }
  20478. }
  20479. declare module BABYLON {
  20480. /**
  20481. * Block used to expose an input value
  20482. */
  20483. export class InputBlock extends NodeMaterialBlock {
  20484. private _mode;
  20485. private _associatedVariableName;
  20486. private _storedValue;
  20487. private _valueCallback;
  20488. private _type;
  20489. private _animationType;
  20490. /** Gets or set a value used to limit the range of float values */
  20491. min: number;
  20492. /** Gets or set a value used to limit the range of float values */
  20493. max: number;
  20494. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20495. isBoolean: boolean;
  20496. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20497. matrixMode: number;
  20498. /** @hidden */
  20499. _systemValue: Nullable<NodeMaterialSystemValues>;
  20500. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20501. isConstant: boolean;
  20502. /** Gets or sets the group to use to display this block in the Inspector */
  20503. groupInInspector: string;
  20504. /** Gets an observable raised when the value is changed */
  20505. onValueChangedObservable: Observable<InputBlock>;
  20506. /**
  20507. * Gets or sets the connection point type (default is float)
  20508. */
  20509. get type(): NodeMaterialBlockConnectionPointTypes;
  20510. /**
  20511. * Creates a new InputBlock
  20512. * @param name defines the block name
  20513. * @param target defines the target of that block (Vertex by default)
  20514. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20515. */
  20516. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20517. /**
  20518. * Validates if a name is a reserve word.
  20519. * @param newName the new name to be given to the node.
  20520. * @returns false if the name is a reserve word, else true.
  20521. */
  20522. validateBlockName(newName: string): boolean;
  20523. /**
  20524. * Gets the output component
  20525. */
  20526. get output(): NodeMaterialConnectionPoint;
  20527. /**
  20528. * Set the source of this connection point to a vertex attribute
  20529. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20530. * @returns the current connection point
  20531. */
  20532. setAsAttribute(attributeName?: string): InputBlock;
  20533. /**
  20534. * Set the source of this connection point to a system value
  20535. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20536. * @returns the current connection point
  20537. */
  20538. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20539. /**
  20540. * Gets or sets the value of that point.
  20541. * Please note that this value will be ignored if valueCallback is defined
  20542. */
  20543. get value(): any;
  20544. set value(value: any);
  20545. /**
  20546. * Gets or sets a callback used to get the value of that point.
  20547. * Please note that setting this value will force the connection point to ignore the value property
  20548. */
  20549. get valueCallback(): () => any;
  20550. set valueCallback(value: () => any);
  20551. /**
  20552. * Gets or sets the associated variable name in the shader
  20553. */
  20554. get associatedVariableName(): string;
  20555. set associatedVariableName(value: string);
  20556. /** Gets or sets the type of animation applied to the input */
  20557. get animationType(): AnimatedInputBlockTypes;
  20558. set animationType(value: AnimatedInputBlockTypes);
  20559. /**
  20560. * Gets a boolean indicating that this connection point not defined yet
  20561. */
  20562. get isUndefined(): boolean;
  20563. /**
  20564. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20565. * In this case the connection point name must be the name of the uniform to use.
  20566. * Can only be set on inputs
  20567. */
  20568. get isUniform(): boolean;
  20569. set isUniform(value: boolean);
  20570. /**
  20571. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20572. * In this case the connection point name must be the name of the attribute to use
  20573. * Can only be set on inputs
  20574. */
  20575. get isAttribute(): boolean;
  20576. set isAttribute(value: boolean);
  20577. /**
  20578. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20579. * Can only be set on exit points
  20580. */
  20581. get isVarying(): boolean;
  20582. set isVarying(value: boolean);
  20583. /**
  20584. * Gets a boolean indicating that the current connection point is a system value
  20585. */
  20586. get isSystemValue(): boolean;
  20587. /**
  20588. * Gets or sets the current well known value or null if not defined as a system value
  20589. */
  20590. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20591. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20592. /**
  20593. * Gets the current class name
  20594. * @returns the class name
  20595. */
  20596. getClassName(): string;
  20597. /**
  20598. * Animate the input if animationType !== None
  20599. * @param scene defines the rendering scene
  20600. */
  20601. animate(scene: Scene): void;
  20602. private _emitDefine;
  20603. initialize(state: NodeMaterialBuildState): void;
  20604. /**
  20605. * Set the input block to its default value (based on its type)
  20606. */
  20607. setDefaultValue(): void;
  20608. private _emitConstant;
  20609. /** @hidden */
  20610. get _noContextSwitch(): boolean;
  20611. private _emit;
  20612. /** @hidden */
  20613. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20614. /** @hidden */
  20615. _transmit(effect: Effect, scene: Scene): void;
  20616. protected _buildBlock(state: NodeMaterialBuildState): void;
  20617. protected _dumpPropertiesCode(): string;
  20618. dispose(): void;
  20619. serialize(): any;
  20620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20621. }
  20622. }
  20623. declare module BABYLON {
  20624. /**
  20625. * Enum used to define the compatibility state between two connection points
  20626. */
  20627. export enum NodeMaterialConnectionPointCompatibilityStates {
  20628. /** Points are compatibles */
  20629. Compatible = 0,
  20630. /** Points are incompatible because of their types */
  20631. TypeIncompatible = 1,
  20632. /** Points are incompatible because of their targets (vertex vs fragment) */
  20633. TargetIncompatible = 2
  20634. }
  20635. /**
  20636. * Defines the direction of a connection point
  20637. */
  20638. export enum NodeMaterialConnectionPointDirection {
  20639. /** Input */
  20640. Input = 0,
  20641. /** Output */
  20642. Output = 1
  20643. }
  20644. /**
  20645. * Defines a connection point for a block
  20646. */
  20647. export class NodeMaterialConnectionPoint {
  20648. /** @hidden */
  20649. _ownerBlock: NodeMaterialBlock;
  20650. /** @hidden */
  20651. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20652. private _endpoints;
  20653. private _associatedVariableName;
  20654. private _direction;
  20655. /** @hidden */
  20656. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20657. /** @hidden */
  20658. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20659. private _type;
  20660. /** @hidden */
  20661. _enforceAssociatedVariableName: boolean;
  20662. /** Gets the direction of the point */
  20663. get direction(): NodeMaterialConnectionPointDirection;
  20664. /** Indicates that this connection point needs dual validation before being connected to another point */
  20665. needDualDirectionValidation: boolean;
  20666. /**
  20667. * Gets or sets the additional types supported by this connection point
  20668. */
  20669. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20670. /**
  20671. * Gets or sets the additional types excluded by this connection point
  20672. */
  20673. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20674. /**
  20675. * Observable triggered when this point is connected
  20676. */
  20677. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20678. /**
  20679. * Gets or sets the associated variable name in the shader
  20680. */
  20681. get associatedVariableName(): string;
  20682. set associatedVariableName(value: string);
  20683. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20684. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20685. /**
  20686. * Gets or sets the connection point type (default is float)
  20687. */
  20688. get type(): NodeMaterialBlockConnectionPointTypes;
  20689. set type(value: NodeMaterialBlockConnectionPointTypes);
  20690. /**
  20691. * Gets or sets the connection point name
  20692. */
  20693. name: string;
  20694. /**
  20695. * Gets or sets the connection point name
  20696. */
  20697. displayName: string;
  20698. /**
  20699. * Gets or sets a boolean indicating that this connection point can be omitted
  20700. */
  20701. isOptional: boolean;
  20702. /**
  20703. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20704. */
  20705. isExposedOnFrame: boolean;
  20706. /**
  20707. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20708. */
  20709. define: string;
  20710. /** @hidden */
  20711. _prioritizeVertex: boolean;
  20712. private _target;
  20713. /** Gets or sets the target of that connection point */
  20714. get target(): NodeMaterialBlockTargets;
  20715. set target(value: NodeMaterialBlockTargets);
  20716. /**
  20717. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20718. */
  20719. get isConnected(): boolean;
  20720. /**
  20721. * Gets a boolean indicating that the current point is connected to an input block
  20722. */
  20723. get isConnectedToInputBlock(): boolean;
  20724. /**
  20725. * Gets a the connected input block (if any)
  20726. */
  20727. get connectInputBlock(): Nullable<InputBlock>;
  20728. /** Get the other side of the connection (if any) */
  20729. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20730. /** Get the block that owns this connection point */
  20731. get ownerBlock(): NodeMaterialBlock;
  20732. /** Get the block connected on the other side of this connection (if any) */
  20733. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20734. /** Get the block connected on the endpoints of this connection (if any) */
  20735. get connectedBlocks(): Array<NodeMaterialBlock>;
  20736. /** Gets the list of connected endpoints */
  20737. get endpoints(): NodeMaterialConnectionPoint[];
  20738. /** Gets a boolean indicating if that output point is connected to at least one input */
  20739. get hasEndpoints(): boolean;
  20740. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20741. get isConnectedInVertexShader(): boolean;
  20742. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20743. get isConnectedInFragmentShader(): boolean;
  20744. /**
  20745. * Creates a block suitable to be used as an input for this input point.
  20746. * If null is returned, a block based on the point type will be created.
  20747. * @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
  20748. */
  20749. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20750. /**
  20751. * Creates a new connection point
  20752. * @param name defines the connection point name
  20753. * @param ownerBlock defines the block hosting this connection point
  20754. * @param direction defines the direction of the connection point
  20755. */
  20756. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20757. /**
  20758. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20759. * @returns the class name
  20760. */
  20761. getClassName(): string;
  20762. /**
  20763. * Gets a boolean indicating if the current point can be connected to another point
  20764. * @param connectionPoint defines the other connection point
  20765. * @returns a boolean
  20766. */
  20767. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20768. /**
  20769. * Gets a number indicating if the current point can be connected to another point
  20770. * @param connectionPoint defines the other connection point
  20771. * @returns a number defining the compatibility state
  20772. */
  20773. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20774. /**
  20775. * Connect this point to another connection point
  20776. * @param connectionPoint defines the other connection point
  20777. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20778. * @returns the current connection point
  20779. */
  20780. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20781. /**
  20782. * Disconnect this point from one of his endpoint
  20783. * @param endpoint defines the other connection point
  20784. * @returns the current connection point
  20785. */
  20786. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20787. /**
  20788. * Serializes this point in a JSON representation
  20789. * @param isInput defines if the connection point is an input (default is true)
  20790. * @returns the serialized point object
  20791. */
  20792. serialize(isInput?: boolean): any;
  20793. /**
  20794. * Release resources
  20795. */
  20796. dispose(): void;
  20797. }
  20798. }
  20799. declare module BABYLON {
  20800. /**
  20801. * Enum used to define the material modes
  20802. */
  20803. export enum NodeMaterialModes {
  20804. /** Regular material */
  20805. Material = 0,
  20806. /** For post process */
  20807. PostProcess = 1,
  20808. /** For particle system */
  20809. Particle = 2,
  20810. /** For procedural texture */
  20811. ProceduralTexture = 3
  20812. }
  20813. }
  20814. declare module BABYLON {
  20815. /**
  20816. * Block used to read a texture from a sampler
  20817. */
  20818. export class TextureBlock extends NodeMaterialBlock {
  20819. private _defineName;
  20820. private _linearDefineName;
  20821. private _gammaDefineName;
  20822. private _tempTextureRead;
  20823. private _samplerName;
  20824. private _transformedUVName;
  20825. private _textureTransformName;
  20826. private _textureInfoName;
  20827. private _mainUVName;
  20828. private _mainUVDefineName;
  20829. private _fragmentOnly;
  20830. /**
  20831. * Gets or sets the texture associated with the node
  20832. */
  20833. texture: Nullable<Texture>;
  20834. /**
  20835. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20836. */
  20837. convertToGammaSpace: boolean;
  20838. /**
  20839. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20840. */
  20841. convertToLinearSpace: boolean;
  20842. /**
  20843. * Create a new TextureBlock
  20844. * @param name defines the block name
  20845. */
  20846. constructor(name: string, fragmentOnly?: boolean);
  20847. /**
  20848. * Gets the current class name
  20849. * @returns the class name
  20850. */
  20851. getClassName(): string;
  20852. /**
  20853. * Gets the uv input component
  20854. */
  20855. get uv(): NodeMaterialConnectionPoint;
  20856. /**
  20857. * Gets the rgba output component
  20858. */
  20859. get rgba(): NodeMaterialConnectionPoint;
  20860. /**
  20861. * Gets the rgb output component
  20862. */
  20863. get rgb(): NodeMaterialConnectionPoint;
  20864. /**
  20865. * Gets the r output component
  20866. */
  20867. get r(): NodeMaterialConnectionPoint;
  20868. /**
  20869. * Gets the g output component
  20870. */
  20871. get g(): NodeMaterialConnectionPoint;
  20872. /**
  20873. * Gets the b output component
  20874. */
  20875. get b(): NodeMaterialConnectionPoint;
  20876. /**
  20877. * Gets the a output component
  20878. */
  20879. get a(): NodeMaterialConnectionPoint;
  20880. get target(): NodeMaterialBlockTargets;
  20881. autoConfigure(material: NodeMaterial): void;
  20882. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20884. isReady(): boolean;
  20885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20886. private get _isMixed();
  20887. private _injectVertexCode;
  20888. private _writeTextureRead;
  20889. private _writeOutput;
  20890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20891. protected _dumpPropertiesCode(): string;
  20892. serialize(): any;
  20893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20894. }
  20895. }
  20896. declare module BABYLON {
  20897. /** @hidden */
  20898. export var reflectionFunction: {
  20899. name: string;
  20900. shader: string;
  20901. };
  20902. }
  20903. declare module BABYLON {
  20904. /**
  20905. * Base block used to read a reflection texture from a sampler
  20906. */
  20907. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20908. /** @hidden */
  20909. _define3DName: string;
  20910. /** @hidden */
  20911. _defineCubicName: string;
  20912. /** @hidden */
  20913. _defineExplicitName: string;
  20914. /** @hidden */
  20915. _defineProjectionName: string;
  20916. /** @hidden */
  20917. _defineLocalCubicName: string;
  20918. /** @hidden */
  20919. _defineSphericalName: string;
  20920. /** @hidden */
  20921. _definePlanarName: string;
  20922. /** @hidden */
  20923. _defineEquirectangularName: string;
  20924. /** @hidden */
  20925. _defineMirroredEquirectangularFixedName: string;
  20926. /** @hidden */
  20927. _defineEquirectangularFixedName: string;
  20928. /** @hidden */
  20929. _defineSkyboxName: string;
  20930. /** @hidden */
  20931. _defineOppositeZ: string;
  20932. /** @hidden */
  20933. _cubeSamplerName: string;
  20934. /** @hidden */
  20935. _2DSamplerName: string;
  20936. protected _positionUVWName: string;
  20937. protected _directionWName: string;
  20938. protected _reflectionVectorName: string;
  20939. /** @hidden */
  20940. _reflectionCoordsName: string;
  20941. /** @hidden */
  20942. _reflectionMatrixName: string;
  20943. protected _reflectionColorName: string;
  20944. /**
  20945. * Gets or sets the texture associated with the node
  20946. */
  20947. texture: Nullable<BaseTexture>;
  20948. /**
  20949. * Create a new ReflectionTextureBaseBlock
  20950. * @param name defines the block name
  20951. */
  20952. constructor(name: string);
  20953. /**
  20954. * Gets the current class name
  20955. * @returns the class name
  20956. */
  20957. getClassName(): string;
  20958. /**
  20959. * Gets the world position input component
  20960. */
  20961. abstract get position(): NodeMaterialConnectionPoint;
  20962. /**
  20963. * Gets the world position input component
  20964. */
  20965. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20966. /**
  20967. * Gets the world normal input component
  20968. */
  20969. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20970. /**
  20971. * Gets the world input component
  20972. */
  20973. abstract get world(): NodeMaterialConnectionPoint;
  20974. /**
  20975. * Gets the camera (or eye) position component
  20976. */
  20977. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20978. /**
  20979. * Gets the view input component
  20980. */
  20981. abstract get view(): NodeMaterialConnectionPoint;
  20982. protected _getTexture(): Nullable<BaseTexture>;
  20983. autoConfigure(material: NodeMaterial): void;
  20984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20985. isReady(): boolean;
  20986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20987. /**
  20988. * Gets the code to inject in the vertex shader
  20989. * @param state current state of the node material building
  20990. * @returns the shader code
  20991. */
  20992. handleVertexSide(state: NodeMaterialBuildState): string;
  20993. /**
  20994. * Handles the inits for the fragment code path
  20995. * @param state node material build state
  20996. */
  20997. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20998. /**
  20999. * Generates the reflection coords code for the fragment code path
  21000. * @param worldNormalVarName name of the world normal variable
  21001. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21002. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21003. * @returns the shader code
  21004. */
  21005. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21006. /**
  21007. * Generates the reflection color code for the fragment code path
  21008. * @param lodVarName name of the lod variable
  21009. * @param swizzleLookupTexture swizzle to use for the final color variable
  21010. * @returns the shader code
  21011. */
  21012. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21013. /**
  21014. * Generates the code corresponding to the connected output points
  21015. * @param state node material build state
  21016. * @param varName name of the variable to output
  21017. * @returns the shader code
  21018. */
  21019. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21020. protected _buildBlock(state: NodeMaterialBuildState): this;
  21021. protected _dumpPropertiesCode(): string;
  21022. serialize(): any;
  21023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21024. }
  21025. }
  21026. declare module BABYLON {
  21027. /**
  21028. * Defines a connection point to be used for points with a custom object type
  21029. */
  21030. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21031. private _blockType;
  21032. private _blockName;
  21033. private _nameForCheking?;
  21034. /**
  21035. * Creates a new connection point
  21036. * @param name defines the connection point name
  21037. * @param ownerBlock defines the block hosting this connection point
  21038. * @param direction defines the direction of the connection point
  21039. */
  21040. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21041. /**
  21042. * Gets a number indicating if the current point can be connected to another point
  21043. * @param connectionPoint defines the other connection point
  21044. * @returns a number defining the compatibility state
  21045. */
  21046. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21047. /**
  21048. * Creates a block suitable to be used as an input for this input point.
  21049. * If null is returned, a block based on the point type will be created.
  21050. * @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
  21051. */
  21052. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21053. }
  21054. }
  21055. declare module BABYLON {
  21056. /**
  21057. * Enum defining the type of properties that can be edited in the property pages in the NME
  21058. */
  21059. export enum PropertyTypeForEdition {
  21060. /** property is a boolean */
  21061. Boolean = 0,
  21062. /** property is a float */
  21063. Float = 1,
  21064. /** property is a Vector2 */
  21065. Vector2 = 2,
  21066. /** property is a list of values */
  21067. List = 3
  21068. }
  21069. /**
  21070. * Interface that defines an option in a variable of type list
  21071. */
  21072. export interface IEditablePropertyListOption {
  21073. /** label of the option */
  21074. "label": string;
  21075. /** value of the option */
  21076. "value": number;
  21077. }
  21078. /**
  21079. * Interface that defines the options available for an editable property
  21080. */
  21081. export interface IEditablePropertyOption {
  21082. /** min value */
  21083. "min"?: number;
  21084. /** max value */
  21085. "max"?: number;
  21086. /** notifiers: indicates which actions to take when the property is changed */
  21087. "notifiers"?: {
  21088. /** the material should be rebuilt */
  21089. "rebuild"?: boolean;
  21090. /** the preview should be updated */
  21091. "update"?: boolean;
  21092. };
  21093. /** list of the options for a variable of type list */
  21094. "options"?: IEditablePropertyListOption[];
  21095. }
  21096. /**
  21097. * Interface that describes an editable property
  21098. */
  21099. export interface IPropertyDescriptionForEdition {
  21100. /** name of the property */
  21101. "propertyName": string;
  21102. /** display name of the property */
  21103. "displayName": string;
  21104. /** type of the property */
  21105. "type": PropertyTypeForEdition;
  21106. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21107. "groupName": string;
  21108. /** options for the property */
  21109. "options": IEditablePropertyOption;
  21110. }
  21111. /**
  21112. * Decorator that flags a property in a node material block as being editable
  21113. */
  21114. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21115. }
  21116. declare module BABYLON {
  21117. /**
  21118. * Block used to implement the refraction part of the sub surface module of the PBR material
  21119. */
  21120. export class RefractionBlock extends NodeMaterialBlock {
  21121. /** @hidden */
  21122. _define3DName: string;
  21123. /** @hidden */
  21124. _refractionMatrixName: string;
  21125. /** @hidden */
  21126. _defineLODRefractionAlpha: string;
  21127. /** @hidden */
  21128. _defineLinearSpecularRefraction: string;
  21129. /** @hidden */
  21130. _defineOppositeZ: string;
  21131. /** @hidden */
  21132. _cubeSamplerName: string;
  21133. /** @hidden */
  21134. _2DSamplerName: string;
  21135. /** @hidden */
  21136. _vRefractionMicrosurfaceInfosName: string;
  21137. /** @hidden */
  21138. _vRefractionInfosName: string;
  21139. private _scene;
  21140. /**
  21141. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21142. * Materials half opaque for instance using refraction could benefit from this control.
  21143. */
  21144. linkRefractionWithTransparency: boolean;
  21145. /**
  21146. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21147. */
  21148. invertRefractionY: boolean;
  21149. /**
  21150. * Gets or sets the texture associated with the node
  21151. */
  21152. texture: Nullable<BaseTexture>;
  21153. /**
  21154. * Create a new RefractionBlock
  21155. * @param name defines the block name
  21156. */
  21157. constructor(name: string);
  21158. /**
  21159. * Gets the current class name
  21160. * @returns the class name
  21161. */
  21162. getClassName(): string;
  21163. /**
  21164. * Gets the intensity input component
  21165. */
  21166. get intensity(): NodeMaterialConnectionPoint;
  21167. /**
  21168. * Gets the index of refraction input component
  21169. */
  21170. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21171. /**
  21172. * Gets the tint at distance input component
  21173. */
  21174. get tintAtDistance(): NodeMaterialConnectionPoint;
  21175. /**
  21176. * Gets the view input component
  21177. */
  21178. get view(): NodeMaterialConnectionPoint;
  21179. /**
  21180. * Gets the refraction object output component
  21181. */
  21182. get refraction(): NodeMaterialConnectionPoint;
  21183. /**
  21184. * Returns true if the block has a texture
  21185. */
  21186. get hasTexture(): boolean;
  21187. protected _getTexture(): Nullable<BaseTexture>;
  21188. autoConfigure(material: NodeMaterial): void;
  21189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21190. isReady(): boolean;
  21191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21192. /**
  21193. * Gets the main code of the block (fragment side)
  21194. * @param state current state of the node material building
  21195. * @returns the shader code
  21196. */
  21197. getCode(state: NodeMaterialBuildState): string;
  21198. protected _buildBlock(state: NodeMaterialBuildState): this;
  21199. protected _dumpPropertiesCode(): string;
  21200. serialize(): any;
  21201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21202. }
  21203. }
  21204. declare module BABYLON {
  21205. /**
  21206. * Base block used as input for post process
  21207. */
  21208. export class CurrentScreenBlock extends NodeMaterialBlock {
  21209. private _samplerName;
  21210. private _linearDefineName;
  21211. private _gammaDefineName;
  21212. private _mainUVName;
  21213. private _tempTextureRead;
  21214. /**
  21215. * Gets or sets the texture associated with the node
  21216. */
  21217. texture: Nullable<BaseTexture>;
  21218. /**
  21219. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21220. */
  21221. convertToGammaSpace: boolean;
  21222. /**
  21223. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21224. */
  21225. convertToLinearSpace: boolean;
  21226. /**
  21227. * Create a new CurrentScreenBlock
  21228. * @param name defines the block name
  21229. */
  21230. constructor(name: string);
  21231. /**
  21232. * Gets the current class name
  21233. * @returns the class name
  21234. */
  21235. getClassName(): string;
  21236. /**
  21237. * Gets the uv input component
  21238. */
  21239. get uv(): NodeMaterialConnectionPoint;
  21240. /**
  21241. * Gets the rgba output component
  21242. */
  21243. get rgba(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the rgb output component
  21246. */
  21247. get rgb(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the r output component
  21250. */
  21251. get r(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the g output component
  21254. */
  21255. get g(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the b output component
  21258. */
  21259. get b(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the a output component
  21262. */
  21263. get a(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Initialize the block and prepare the context for build
  21266. * @param state defines the state that will be used for the build
  21267. */
  21268. initialize(state: NodeMaterialBuildState): void;
  21269. get target(): NodeMaterialBlockTargets;
  21270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21271. isReady(): boolean;
  21272. private _injectVertexCode;
  21273. private _writeTextureRead;
  21274. private _writeOutput;
  21275. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21276. serialize(): any;
  21277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21278. }
  21279. }
  21280. declare module BABYLON {
  21281. /**
  21282. * Base block used for the particle texture
  21283. */
  21284. export class ParticleTextureBlock extends NodeMaterialBlock {
  21285. private _samplerName;
  21286. private _linearDefineName;
  21287. private _gammaDefineName;
  21288. private _tempTextureRead;
  21289. /**
  21290. * Gets or sets the texture associated with the node
  21291. */
  21292. texture: Nullable<BaseTexture>;
  21293. /**
  21294. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21295. */
  21296. convertToGammaSpace: boolean;
  21297. /**
  21298. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21299. */
  21300. convertToLinearSpace: boolean;
  21301. /**
  21302. * Create a new ParticleTextureBlock
  21303. * @param name defines the block name
  21304. */
  21305. constructor(name: string);
  21306. /**
  21307. * Gets the current class name
  21308. * @returns the class name
  21309. */
  21310. getClassName(): string;
  21311. /**
  21312. * Gets the uv input component
  21313. */
  21314. get uv(): NodeMaterialConnectionPoint;
  21315. /**
  21316. * Gets the rgba output component
  21317. */
  21318. get rgba(): NodeMaterialConnectionPoint;
  21319. /**
  21320. * Gets the rgb output component
  21321. */
  21322. get rgb(): NodeMaterialConnectionPoint;
  21323. /**
  21324. * Gets the r output component
  21325. */
  21326. get r(): NodeMaterialConnectionPoint;
  21327. /**
  21328. * Gets the g output component
  21329. */
  21330. get g(): NodeMaterialConnectionPoint;
  21331. /**
  21332. * Gets the b output component
  21333. */
  21334. get b(): NodeMaterialConnectionPoint;
  21335. /**
  21336. * Gets the a output component
  21337. */
  21338. get a(): NodeMaterialConnectionPoint;
  21339. /**
  21340. * Initialize the block and prepare the context for build
  21341. * @param state defines the state that will be used for the build
  21342. */
  21343. initialize(state: NodeMaterialBuildState): void;
  21344. autoConfigure(material: NodeMaterial): void;
  21345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21346. isReady(): boolean;
  21347. private _writeOutput;
  21348. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21349. serialize(): any;
  21350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21351. }
  21352. }
  21353. declare module BABYLON {
  21354. /**
  21355. * Class used to store shared data between 2 NodeMaterialBuildState
  21356. */
  21357. export class NodeMaterialBuildStateSharedData {
  21358. /**
  21359. * Gets the list of emitted varyings
  21360. */
  21361. temps: string[];
  21362. /**
  21363. * Gets the list of emitted varyings
  21364. */
  21365. varyings: string[];
  21366. /**
  21367. * Gets the varying declaration string
  21368. */
  21369. varyingDeclaration: string;
  21370. /**
  21371. * Input blocks
  21372. */
  21373. inputBlocks: InputBlock[];
  21374. /**
  21375. * Input blocks
  21376. */
  21377. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21378. /**
  21379. * Bindable blocks (Blocks that need to set data to the effect)
  21380. */
  21381. bindableBlocks: NodeMaterialBlock[];
  21382. /**
  21383. * List of blocks that can provide a compilation fallback
  21384. */
  21385. blocksWithFallbacks: NodeMaterialBlock[];
  21386. /**
  21387. * List of blocks that can provide a define update
  21388. */
  21389. blocksWithDefines: NodeMaterialBlock[];
  21390. /**
  21391. * List of blocks that can provide a repeatable content
  21392. */
  21393. repeatableContentBlocks: NodeMaterialBlock[];
  21394. /**
  21395. * List of blocks that can provide a dynamic list of uniforms
  21396. */
  21397. dynamicUniformBlocks: NodeMaterialBlock[];
  21398. /**
  21399. * List of blocks that can block the isReady function for the material
  21400. */
  21401. blockingBlocks: NodeMaterialBlock[];
  21402. /**
  21403. * Gets the list of animated inputs
  21404. */
  21405. animatedInputs: InputBlock[];
  21406. /**
  21407. * Build Id used to avoid multiple recompilations
  21408. */
  21409. buildId: number;
  21410. /** List of emitted variables */
  21411. variableNames: {
  21412. [key: string]: number;
  21413. };
  21414. /** List of emitted defines */
  21415. defineNames: {
  21416. [key: string]: number;
  21417. };
  21418. /** Should emit comments? */
  21419. emitComments: boolean;
  21420. /** Emit build activity */
  21421. verbose: boolean;
  21422. /** Gets or sets the hosting scene */
  21423. scene: Scene;
  21424. /**
  21425. * Gets the compilation hints emitted at compilation time
  21426. */
  21427. hints: {
  21428. needWorldViewMatrix: boolean;
  21429. needWorldViewProjectionMatrix: boolean;
  21430. needAlphaBlending: boolean;
  21431. needAlphaTesting: boolean;
  21432. };
  21433. /**
  21434. * List of compilation checks
  21435. */
  21436. checks: {
  21437. emitVertex: boolean;
  21438. emitFragment: boolean;
  21439. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21440. };
  21441. /**
  21442. * Is vertex program allowed to be empty?
  21443. */
  21444. allowEmptyVertexProgram: boolean;
  21445. /** Creates a new shared data */
  21446. constructor();
  21447. /**
  21448. * Emits console errors and exceptions if there is a failing check
  21449. */
  21450. emitErrors(): void;
  21451. }
  21452. }
  21453. declare module BABYLON {
  21454. /**
  21455. * Class used to store node based material build state
  21456. */
  21457. export class NodeMaterialBuildState {
  21458. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21459. supportUniformBuffers: boolean;
  21460. /**
  21461. * Gets the list of emitted attributes
  21462. */
  21463. attributes: string[];
  21464. /**
  21465. * Gets the list of emitted uniforms
  21466. */
  21467. uniforms: string[];
  21468. /**
  21469. * Gets the list of emitted constants
  21470. */
  21471. constants: string[];
  21472. /**
  21473. * Gets the list of emitted samplers
  21474. */
  21475. samplers: string[];
  21476. /**
  21477. * Gets the list of emitted functions
  21478. */
  21479. functions: {
  21480. [key: string]: string;
  21481. };
  21482. /**
  21483. * Gets the list of emitted extensions
  21484. */
  21485. extensions: {
  21486. [key: string]: string;
  21487. };
  21488. /**
  21489. * Gets the target of the compilation state
  21490. */
  21491. target: NodeMaterialBlockTargets;
  21492. /**
  21493. * Gets the list of emitted counters
  21494. */
  21495. counters: {
  21496. [key: string]: number;
  21497. };
  21498. /**
  21499. * Shared data between multiple NodeMaterialBuildState instances
  21500. */
  21501. sharedData: NodeMaterialBuildStateSharedData;
  21502. /** @hidden */
  21503. _vertexState: NodeMaterialBuildState;
  21504. /** @hidden */
  21505. _attributeDeclaration: string;
  21506. /** @hidden */
  21507. _uniformDeclaration: string;
  21508. /** @hidden */
  21509. _constantDeclaration: string;
  21510. /** @hidden */
  21511. _samplerDeclaration: string;
  21512. /** @hidden */
  21513. _varyingTransfer: string;
  21514. /** @hidden */
  21515. _injectAtEnd: string;
  21516. private _repeatableContentAnchorIndex;
  21517. /** @hidden */
  21518. _builtCompilationString: string;
  21519. /**
  21520. * Gets the emitted compilation strings
  21521. */
  21522. compilationString: string;
  21523. /**
  21524. * Finalize the compilation strings
  21525. * @param state defines the current compilation state
  21526. */
  21527. finalize(state: NodeMaterialBuildState): void;
  21528. /** @hidden */
  21529. get _repeatableContentAnchor(): string;
  21530. /** @hidden */
  21531. _getFreeVariableName(prefix: string): string;
  21532. /** @hidden */
  21533. _getFreeDefineName(prefix: string): string;
  21534. /** @hidden */
  21535. _excludeVariableName(name: string): void;
  21536. /** @hidden */
  21537. _emit2DSampler(name: string): void;
  21538. /** @hidden */
  21539. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21540. /** @hidden */
  21541. _emitExtension(name: string, extension: string, define?: string): void;
  21542. /** @hidden */
  21543. _emitFunction(name: string, code: string, comments: string): void;
  21544. /** @hidden */
  21545. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21546. replaceStrings?: {
  21547. search: RegExp;
  21548. replace: string;
  21549. }[];
  21550. repeatKey?: string;
  21551. }): string;
  21552. /** @hidden */
  21553. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21554. repeatKey?: string;
  21555. removeAttributes?: boolean;
  21556. removeUniforms?: boolean;
  21557. removeVaryings?: boolean;
  21558. removeIfDef?: boolean;
  21559. replaceStrings?: {
  21560. search: RegExp;
  21561. replace: string;
  21562. }[];
  21563. }, storeKey?: string): void;
  21564. /** @hidden */
  21565. _registerTempVariable(name: string): boolean;
  21566. /** @hidden */
  21567. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21568. /** @hidden */
  21569. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21570. /** @hidden */
  21571. _emitFloat(value: number): string;
  21572. }
  21573. }
  21574. declare module BABYLON {
  21575. /**
  21576. * Helper class used to generate session unique ID
  21577. */
  21578. export class UniqueIdGenerator {
  21579. private static _UniqueIdCounter;
  21580. /**
  21581. * Gets an unique (relatively to the current scene) Id
  21582. */
  21583. static get UniqueId(): number;
  21584. }
  21585. }
  21586. declare module BABYLON {
  21587. /**
  21588. * Defines a block that can be used inside a node based material
  21589. */
  21590. export class NodeMaterialBlock {
  21591. private _buildId;
  21592. private _buildTarget;
  21593. private _target;
  21594. private _isFinalMerger;
  21595. private _isInput;
  21596. private _name;
  21597. protected _isUnique: boolean;
  21598. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21599. inputsAreExclusive: boolean;
  21600. /** @hidden */
  21601. _codeVariableName: string;
  21602. /** @hidden */
  21603. _inputs: NodeMaterialConnectionPoint[];
  21604. /** @hidden */
  21605. _outputs: NodeMaterialConnectionPoint[];
  21606. /** @hidden */
  21607. _preparationId: number;
  21608. /**
  21609. * Gets the name of the block
  21610. */
  21611. get name(): string;
  21612. /**
  21613. * Sets the name of the block. Will check if the name is valid.
  21614. */
  21615. set name(newName: string);
  21616. /**
  21617. * Gets or sets the unique id of the node
  21618. */
  21619. uniqueId: number;
  21620. /**
  21621. * Gets or sets the comments associated with this block
  21622. */
  21623. comments: string;
  21624. /**
  21625. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21626. */
  21627. get isUnique(): boolean;
  21628. /**
  21629. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21630. */
  21631. get isFinalMerger(): boolean;
  21632. /**
  21633. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21634. */
  21635. get isInput(): boolean;
  21636. /**
  21637. * Gets or sets the build Id
  21638. */
  21639. get buildId(): number;
  21640. set buildId(value: number);
  21641. /**
  21642. * Gets or sets the target of the block
  21643. */
  21644. get target(): NodeMaterialBlockTargets;
  21645. set target(value: NodeMaterialBlockTargets);
  21646. /**
  21647. * Gets the list of input points
  21648. */
  21649. get inputs(): NodeMaterialConnectionPoint[];
  21650. /** Gets the list of output points */
  21651. get outputs(): NodeMaterialConnectionPoint[];
  21652. /**
  21653. * Find an input by its name
  21654. * @param name defines the name of the input to look for
  21655. * @returns the input or null if not found
  21656. */
  21657. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21658. /**
  21659. * Find an output by its name
  21660. * @param name defines the name of the outputto look for
  21661. * @returns the output or null if not found
  21662. */
  21663. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21664. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21665. visibleInInspector: boolean;
  21666. /**
  21667. * Creates a new NodeMaterialBlock
  21668. * @param name defines the block name
  21669. * @param target defines the target of that block (Vertex by default)
  21670. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21671. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21672. */
  21673. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21674. /**
  21675. * Initialize the block and prepare the context for build
  21676. * @param state defines the state that will be used for the build
  21677. */
  21678. initialize(state: NodeMaterialBuildState): void;
  21679. /**
  21680. * Bind data to effect. Will only be called for blocks with isBindable === true
  21681. * @param effect defines the effect to bind data to
  21682. * @param nodeMaterial defines the hosting NodeMaterial
  21683. * @param mesh defines the mesh that will be rendered
  21684. * @param subMesh defines the submesh that will be rendered
  21685. */
  21686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21687. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21688. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21689. protected _writeFloat(value: number): string;
  21690. /**
  21691. * Gets the current class name e.g. "NodeMaterialBlock"
  21692. * @returns the class name
  21693. */
  21694. getClassName(): string;
  21695. /**
  21696. * Register a new input. Must be called inside a block constructor
  21697. * @param name defines the connection point name
  21698. * @param type defines the connection point type
  21699. * @param isOptional defines a boolean indicating that this input can be omitted
  21700. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21701. * @param point an already created connection point. If not provided, create a new one
  21702. * @returns the current block
  21703. */
  21704. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21705. /**
  21706. * Register a new output. Must be called inside a block constructor
  21707. * @param name defines the connection point name
  21708. * @param type defines the connection point type
  21709. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21710. * @param point an already created connection point. If not provided, create a new one
  21711. * @returns the current block
  21712. */
  21713. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21714. /**
  21715. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21716. * @param forOutput defines an optional connection point to check compatibility with
  21717. * @returns the first available input or null
  21718. */
  21719. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21720. /**
  21721. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21722. * @param forBlock defines an optional block to check compatibility with
  21723. * @returns the first available input or null
  21724. */
  21725. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21726. /**
  21727. * Gets the sibling of the given output
  21728. * @param current defines the current output
  21729. * @returns the next output in the list or null
  21730. */
  21731. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21732. /**
  21733. * Connect current block with another block
  21734. * @param other defines the block to connect with
  21735. * @param options define the various options to help pick the right connections
  21736. * @returns the current block
  21737. */
  21738. connectTo(other: NodeMaterialBlock, options?: {
  21739. input?: string;
  21740. output?: string;
  21741. outputSwizzle?: string;
  21742. }): this | undefined;
  21743. protected _buildBlock(state: NodeMaterialBuildState): void;
  21744. /**
  21745. * Add uniforms, samplers and uniform buffers at compilation time
  21746. * @param state defines the state to update
  21747. * @param nodeMaterial defines the node material requesting the update
  21748. * @param defines defines the material defines to update
  21749. * @param uniformBuffers defines the list of uniform buffer names
  21750. */
  21751. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21752. /**
  21753. * Add potential fallbacks if shader compilation fails
  21754. * @param mesh defines the mesh to be rendered
  21755. * @param fallbacks defines the current prioritized list of fallbacks
  21756. */
  21757. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21758. /**
  21759. * Initialize defines for shader compilation
  21760. * @param mesh defines the mesh to be rendered
  21761. * @param nodeMaterial defines the node material requesting the update
  21762. * @param defines defines the material defines to update
  21763. * @param useInstances specifies that instances should be used
  21764. */
  21765. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21766. /**
  21767. * Update defines for shader compilation
  21768. * @param mesh defines the mesh to be rendered
  21769. * @param nodeMaterial defines the node material requesting the update
  21770. * @param defines defines the material defines to update
  21771. * @param useInstances specifies that instances should be used
  21772. * @param subMesh defines which submesh to render
  21773. */
  21774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21775. /**
  21776. * Lets the block try to connect some inputs automatically
  21777. * @param material defines the hosting NodeMaterial
  21778. */
  21779. autoConfigure(material: NodeMaterial): void;
  21780. /**
  21781. * Function called when a block is declared as repeatable content generator
  21782. * @param vertexShaderState defines the current compilation state for the vertex shader
  21783. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21784. * @param mesh defines the mesh to be rendered
  21785. * @param defines defines the material defines to update
  21786. */
  21787. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21788. /**
  21789. * Checks if the block is ready
  21790. * @param mesh defines the mesh to be rendered
  21791. * @param nodeMaterial defines the node material requesting the update
  21792. * @param defines defines the material defines to update
  21793. * @param useInstances specifies that instances should be used
  21794. * @returns true if the block is ready
  21795. */
  21796. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21797. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21798. private _processBuild;
  21799. /**
  21800. * Validates the new name for the block node.
  21801. * @param newName the new name to be given to the node.
  21802. * @returns false if the name is a reserve word, else true.
  21803. */
  21804. validateBlockName(newName: string): boolean;
  21805. /**
  21806. * Compile the current node and generate the shader code
  21807. * @param state defines the current compilation state (uniforms, samplers, current string)
  21808. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21809. * @returns true if already built
  21810. */
  21811. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21812. protected _inputRename(name: string): string;
  21813. protected _outputRename(name: string): string;
  21814. protected _dumpPropertiesCode(): string;
  21815. /** @hidden */
  21816. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21817. /** @hidden */
  21818. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21819. /**
  21820. * Clone the current block to a new identical block
  21821. * @param scene defines the hosting scene
  21822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21823. * @returns a copy of the current block
  21824. */
  21825. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21826. /**
  21827. * Serializes this block in a JSON representation
  21828. * @returns the serialized block object
  21829. */
  21830. serialize(): any;
  21831. /** @hidden */
  21832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21833. private _deserializePortDisplayNamesAndExposedOnFrame;
  21834. /**
  21835. * Release resources
  21836. */
  21837. dispose(): void;
  21838. }
  21839. }
  21840. declare module BABYLON {
  21841. /**
  21842. * Base class of materials working in push mode in babylon JS
  21843. * @hidden
  21844. */
  21845. export class PushMaterial extends Material {
  21846. protected _activeEffect: Effect;
  21847. protected _normalMatrix: Matrix;
  21848. constructor(name: string, scene: Scene);
  21849. getEffect(): Effect;
  21850. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21851. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21852. /**
  21853. * Binds the given world matrix to the active effect
  21854. *
  21855. * @param world the matrix to bind
  21856. */
  21857. bindOnlyWorldMatrix(world: Matrix): void;
  21858. /**
  21859. * Binds the given normal matrix to the active effect
  21860. *
  21861. * @param normalMatrix the matrix to bind
  21862. */
  21863. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21864. bind(world: Matrix, mesh?: Mesh): void;
  21865. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21866. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21867. }
  21868. }
  21869. declare module BABYLON {
  21870. /**
  21871. * Root class for all node material optimizers
  21872. */
  21873. export class NodeMaterialOptimizer {
  21874. /**
  21875. * Function used to optimize a NodeMaterial graph
  21876. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21877. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21878. */
  21879. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21880. }
  21881. }
  21882. declare module BABYLON {
  21883. /**
  21884. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21885. */
  21886. export class TransformBlock extends NodeMaterialBlock {
  21887. /**
  21888. * Defines the value to use to complement W value to transform it to a Vector4
  21889. */
  21890. complementW: number;
  21891. /**
  21892. * Defines the value to use to complement z value to transform it to a Vector4
  21893. */
  21894. complementZ: number;
  21895. /**
  21896. * Creates a new TransformBlock
  21897. * @param name defines the block name
  21898. */
  21899. constructor(name: string);
  21900. /**
  21901. * Gets the current class name
  21902. * @returns the class name
  21903. */
  21904. getClassName(): string;
  21905. /**
  21906. * Gets the vector input
  21907. */
  21908. get vector(): NodeMaterialConnectionPoint;
  21909. /**
  21910. * Gets the output component
  21911. */
  21912. get output(): NodeMaterialConnectionPoint;
  21913. /**
  21914. * Gets the xyz output component
  21915. */
  21916. get xyz(): NodeMaterialConnectionPoint;
  21917. /**
  21918. * Gets the matrix transform input
  21919. */
  21920. get transform(): NodeMaterialConnectionPoint;
  21921. protected _buildBlock(state: NodeMaterialBuildState): this;
  21922. /**
  21923. * Update defines for shader compilation
  21924. * @param mesh defines the mesh to be rendered
  21925. * @param nodeMaterial defines the node material requesting the update
  21926. * @param defines defines the material defines to update
  21927. * @param useInstances specifies that instances should be used
  21928. * @param subMesh defines which submesh to render
  21929. */
  21930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21931. serialize(): any;
  21932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21933. protected _dumpPropertiesCode(): string;
  21934. }
  21935. }
  21936. declare module BABYLON {
  21937. /**
  21938. * Block used to output the vertex position
  21939. */
  21940. export class VertexOutputBlock extends NodeMaterialBlock {
  21941. /**
  21942. * Creates a new VertexOutputBlock
  21943. * @param name defines the block name
  21944. */
  21945. constructor(name: string);
  21946. /**
  21947. * Gets the current class name
  21948. * @returns the class name
  21949. */
  21950. getClassName(): string;
  21951. /**
  21952. * Gets the vector input component
  21953. */
  21954. get vector(): NodeMaterialConnectionPoint;
  21955. protected _buildBlock(state: NodeMaterialBuildState): this;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /**
  21960. * Block used to output the final color
  21961. */
  21962. export class FragmentOutputBlock extends NodeMaterialBlock {
  21963. /**
  21964. * Create a new FragmentOutputBlock
  21965. * @param name defines the block name
  21966. */
  21967. constructor(name: string);
  21968. /**
  21969. * Gets the current class name
  21970. * @returns the class name
  21971. */
  21972. getClassName(): string;
  21973. /**
  21974. * Gets the rgba input component
  21975. */
  21976. get rgba(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Gets the rgb input component
  21979. */
  21980. get rgb(): NodeMaterialConnectionPoint;
  21981. /**
  21982. * Gets the a input component
  21983. */
  21984. get a(): NodeMaterialConnectionPoint;
  21985. protected _buildBlock(state: NodeMaterialBuildState): this;
  21986. }
  21987. }
  21988. declare module BABYLON {
  21989. /**
  21990. * Block used for the particle ramp gradient section
  21991. */
  21992. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21993. /**
  21994. * Create a new ParticleRampGradientBlock
  21995. * @param name defines the block name
  21996. */
  21997. constructor(name: string);
  21998. /**
  21999. * Gets the current class name
  22000. * @returns the class name
  22001. */
  22002. getClassName(): string;
  22003. /**
  22004. * Gets the color input component
  22005. */
  22006. get color(): NodeMaterialConnectionPoint;
  22007. /**
  22008. * Gets the rampColor output component
  22009. */
  22010. get rampColor(): NodeMaterialConnectionPoint;
  22011. /**
  22012. * Initialize the block and prepare the context for build
  22013. * @param state defines the state that will be used for the build
  22014. */
  22015. initialize(state: NodeMaterialBuildState): void;
  22016. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22017. }
  22018. }
  22019. declare module BABYLON {
  22020. /**
  22021. * Block used for the particle blend multiply section
  22022. */
  22023. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22024. /**
  22025. * Create a new ParticleBlendMultiplyBlock
  22026. * @param name defines the block name
  22027. */
  22028. constructor(name: string);
  22029. /**
  22030. * Gets the current class name
  22031. * @returns the class name
  22032. */
  22033. getClassName(): string;
  22034. /**
  22035. * Gets the color input component
  22036. */
  22037. get color(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the alphaTexture input component
  22040. */
  22041. get alphaTexture(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the alphaColor input component
  22044. */
  22045. get alphaColor(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the blendColor output component
  22048. */
  22049. get blendColor(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Initialize the block and prepare the context for build
  22052. * @param state defines the state that will be used for the build
  22053. */
  22054. initialize(state: NodeMaterialBuildState): void;
  22055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22056. }
  22057. }
  22058. declare module BABYLON {
  22059. /**
  22060. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22061. */
  22062. export class VectorMergerBlock extends NodeMaterialBlock {
  22063. /**
  22064. * Create a new VectorMergerBlock
  22065. * @param name defines the block name
  22066. */
  22067. constructor(name: string);
  22068. /**
  22069. * Gets the current class name
  22070. * @returns the class name
  22071. */
  22072. getClassName(): string;
  22073. /**
  22074. * Gets the xyz component (input)
  22075. */
  22076. get xyzIn(): NodeMaterialConnectionPoint;
  22077. /**
  22078. * Gets the xy component (input)
  22079. */
  22080. get xyIn(): NodeMaterialConnectionPoint;
  22081. /**
  22082. * Gets the x component (input)
  22083. */
  22084. get x(): NodeMaterialConnectionPoint;
  22085. /**
  22086. * Gets the y component (input)
  22087. */
  22088. get y(): NodeMaterialConnectionPoint;
  22089. /**
  22090. * Gets the z component (input)
  22091. */
  22092. get z(): NodeMaterialConnectionPoint;
  22093. /**
  22094. * Gets the w component (input)
  22095. */
  22096. get w(): NodeMaterialConnectionPoint;
  22097. /**
  22098. * Gets the xyzw component (output)
  22099. */
  22100. get xyzw(): NodeMaterialConnectionPoint;
  22101. /**
  22102. * Gets the xyz component (output)
  22103. */
  22104. get xyzOut(): NodeMaterialConnectionPoint;
  22105. /**
  22106. * Gets the xy component (output)
  22107. */
  22108. get xyOut(): NodeMaterialConnectionPoint;
  22109. /**
  22110. * Gets the xy component (output)
  22111. * @deprecated Please use xyOut instead.
  22112. */
  22113. get xy(): NodeMaterialConnectionPoint;
  22114. /**
  22115. * Gets the xyz component (output)
  22116. * @deprecated Please use xyzOut instead.
  22117. */
  22118. get xyz(): NodeMaterialConnectionPoint;
  22119. protected _buildBlock(state: NodeMaterialBuildState): this;
  22120. }
  22121. }
  22122. declare module BABYLON {
  22123. /**
  22124. * Block used to remap a float from a range to a new one
  22125. */
  22126. export class RemapBlock extends NodeMaterialBlock {
  22127. /**
  22128. * Gets or sets the source range
  22129. */
  22130. sourceRange: Vector2;
  22131. /**
  22132. * Gets or sets the target range
  22133. */
  22134. targetRange: Vector2;
  22135. /**
  22136. * Creates a new RemapBlock
  22137. * @param name defines the block name
  22138. */
  22139. constructor(name: string);
  22140. /**
  22141. * Gets the current class name
  22142. * @returns the class name
  22143. */
  22144. getClassName(): string;
  22145. /**
  22146. * Gets the input component
  22147. */
  22148. get input(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Gets the source min input component
  22151. */
  22152. get sourceMin(): NodeMaterialConnectionPoint;
  22153. /**
  22154. * Gets the source max input component
  22155. */
  22156. get sourceMax(): NodeMaterialConnectionPoint;
  22157. /**
  22158. * Gets the target min input component
  22159. */
  22160. get targetMin(): NodeMaterialConnectionPoint;
  22161. /**
  22162. * Gets the target max input component
  22163. */
  22164. get targetMax(): NodeMaterialConnectionPoint;
  22165. /**
  22166. * Gets the output component
  22167. */
  22168. get output(): NodeMaterialConnectionPoint;
  22169. protected _buildBlock(state: NodeMaterialBuildState): this;
  22170. protected _dumpPropertiesCode(): string;
  22171. serialize(): any;
  22172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22173. }
  22174. }
  22175. declare module BABYLON {
  22176. /**
  22177. * Block used to multiply 2 values
  22178. */
  22179. export class MultiplyBlock extends NodeMaterialBlock {
  22180. /**
  22181. * Creates a new MultiplyBlock
  22182. * @param name defines the block name
  22183. */
  22184. constructor(name: string);
  22185. /**
  22186. * Gets the current class name
  22187. * @returns the class name
  22188. */
  22189. getClassName(): string;
  22190. /**
  22191. * Gets the left operand input component
  22192. */
  22193. get left(): NodeMaterialConnectionPoint;
  22194. /**
  22195. * Gets the right operand input component
  22196. */
  22197. get right(): NodeMaterialConnectionPoint;
  22198. /**
  22199. * Gets the output component
  22200. */
  22201. get output(): NodeMaterialConnectionPoint;
  22202. protected _buildBlock(state: NodeMaterialBuildState): this;
  22203. }
  22204. }
  22205. declare module BABYLON {
  22206. /**
  22207. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22208. */
  22209. export class ColorSplitterBlock extends NodeMaterialBlock {
  22210. /**
  22211. * Create a new ColorSplitterBlock
  22212. * @param name defines the block name
  22213. */
  22214. constructor(name: string);
  22215. /**
  22216. * Gets the current class name
  22217. * @returns the class name
  22218. */
  22219. getClassName(): string;
  22220. /**
  22221. * Gets the rgba component (input)
  22222. */
  22223. get rgba(): NodeMaterialConnectionPoint;
  22224. /**
  22225. * Gets the rgb component (input)
  22226. */
  22227. get rgbIn(): NodeMaterialConnectionPoint;
  22228. /**
  22229. * Gets the rgb component (output)
  22230. */
  22231. get rgbOut(): NodeMaterialConnectionPoint;
  22232. /**
  22233. * Gets the r component (output)
  22234. */
  22235. get r(): NodeMaterialConnectionPoint;
  22236. /**
  22237. * Gets the g component (output)
  22238. */
  22239. get g(): NodeMaterialConnectionPoint;
  22240. /**
  22241. * Gets the b component (output)
  22242. */
  22243. get b(): NodeMaterialConnectionPoint;
  22244. /**
  22245. * Gets the a component (output)
  22246. */
  22247. get a(): NodeMaterialConnectionPoint;
  22248. protected _inputRename(name: string): string;
  22249. protected _outputRename(name: string): string;
  22250. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22251. }
  22252. }
  22253. declare module BABYLON {
  22254. /**
  22255. * Operations supported by the Trigonometry block
  22256. */
  22257. export enum TrigonometryBlockOperations {
  22258. /** Cos */
  22259. Cos = 0,
  22260. /** Sin */
  22261. Sin = 1,
  22262. /** Abs */
  22263. Abs = 2,
  22264. /** Exp */
  22265. Exp = 3,
  22266. /** Exp2 */
  22267. Exp2 = 4,
  22268. /** Round */
  22269. Round = 5,
  22270. /** Floor */
  22271. Floor = 6,
  22272. /** Ceiling */
  22273. Ceiling = 7,
  22274. /** Square root */
  22275. Sqrt = 8,
  22276. /** Log */
  22277. Log = 9,
  22278. /** Tangent */
  22279. Tan = 10,
  22280. /** Arc tangent */
  22281. ArcTan = 11,
  22282. /** Arc cosinus */
  22283. ArcCos = 12,
  22284. /** Arc sinus */
  22285. ArcSin = 13,
  22286. /** Fraction */
  22287. Fract = 14,
  22288. /** Sign */
  22289. Sign = 15,
  22290. /** To radians (from degrees) */
  22291. Radians = 16,
  22292. /** To degrees (from radians) */
  22293. Degrees = 17
  22294. }
  22295. /**
  22296. * Block used to apply trigonometry operation to floats
  22297. */
  22298. export class TrigonometryBlock extends NodeMaterialBlock {
  22299. /**
  22300. * Gets or sets the operation applied by the block
  22301. */
  22302. operation: TrigonometryBlockOperations;
  22303. /**
  22304. * Creates a new TrigonometryBlock
  22305. * @param name defines the block name
  22306. */
  22307. constructor(name: string);
  22308. /**
  22309. * Gets the current class name
  22310. * @returns the class name
  22311. */
  22312. getClassName(): string;
  22313. /**
  22314. * Gets the input component
  22315. */
  22316. get input(): NodeMaterialConnectionPoint;
  22317. /**
  22318. * Gets the output component
  22319. */
  22320. get output(): NodeMaterialConnectionPoint;
  22321. protected _buildBlock(state: NodeMaterialBuildState): this;
  22322. serialize(): any;
  22323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22324. protected _dumpPropertiesCode(): string;
  22325. }
  22326. }
  22327. declare module BABYLON {
  22328. /**
  22329. * Interface used to configure the node material editor
  22330. */
  22331. export interface INodeMaterialEditorOptions {
  22332. /** Define the URl to load node editor script */
  22333. editorURL?: string;
  22334. }
  22335. /** @hidden */
  22336. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22337. NORMAL: boolean;
  22338. TANGENT: boolean;
  22339. UV1: boolean;
  22340. /** BONES */
  22341. NUM_BONE_INFLUENCERS: number;
  22342. BonesPerMesh: number;
  22343. BONETEXTURE: boolean;
  22344. /** MORPH TARGETS */
  22345. MORPHTARGETS: boolean;
  22346. MORPHTARGETS_NORMAL: boolean;
  22347. MORPHTARGETS_TANGENT: boolean;
  22348. MORPHTARGETS_UV: boolean;
  22349. NUM_MORPH_INFLUENCERS: number;
  22350. /** IMAGE PROCESSING */
  22351. IMAGEPROCESSING: boolean;
  22352. VIGNETTE: boolean;
  22353. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22354. VIGNETTEBLENDMODEOPAQUE: boolean;
  22355. TONEMAPPING: boolean;
  22356. TONEMAPPING_ACES: boolean;
  22357. CONTRAST: boolean;
  22358. EXPOSURE: boolean;
  22359. COLORCURVES: boolean;
  22360. COLORGRADING: boolean;
  22361. COLORGRADING3D: boolean;
  22362. SAMPLER3DGREENDEPTH: boolean;
  22363. SAMPLER3DBGRMAP: boolean;
  22364. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22365. /** MISC. */
  22366. BUMPDIRECTUV: number;
  22367. constructor();
  22368. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22369. }
  22370. /**
  22371. * Class used to configure NodeMaterial
  22372. */
  22373. export interface INodeMaterialOptions {
  22374. /**
  22375. * Defines if blocks should emit comments
  22376. */
  22377. emitComments: boolean;
  22378. }
  22379. /**
  22380. * Class used to create a node based material built by assembling shader blocks
  22381. */
  22382. export class NodeMaterial extends PushMaterial {
  22383. private static _BuildIdGenerator;
  22384. private _options;
  22385. private _vertexCompilationState;
  22386. private _fragmentCompilationState;
  22387. private _sharedData;
  22388. private _buildId;
  22389. private _buildWasSuccessful;
  22390. private _cachedWorldViewMatrix;
  22391. private _cachedWorldViewProjectionMatrix;
  22392. private _optimizers;
  22393. private _animationFrame;
  22394. /** Define the Url to load node editor script */
  22395. static EditorURL: string;
  22396. /** Define the Url to load snippets */
  22397. static SnippetUrl: string;
  22398. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22399. static IgnoreTexturesAtLoadTime: boolean;
  22400. private BJSNODEMATERIALEDITOR;
  22401. /** Get the inspector from bundle or global */
  22402. private _getGlobalNodeMaterialEditor;
  22403. /**
  22404. * Snippet ID if the material was created from the snippet server
  22405. */
  22406. snippetId: string;
  22407. /**
  22408. * Gets or sets data used by visual editor
  22409. * @see https://nme.babylonjs.com
  22410. */
  22411. editorData: any;
  22412. /**
  22413. * 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)
  22414. */
  22415. ignoreAlpha: boolean;
  22416. /**
  22417. * Defines the maximum number of lights that can be used in the material
  22418. */
  22419. maxSimultaneousLights: number;
  22420. /**
  22421. * Observable raised when the material is built
  22422. */
  22423. onBuildObservable: Observable<NodeMaterial>;
  22424. /**
  22425. * Gets or sets the root nodes of the material vertex shader
  22426. */
  22427. _vertexOutputNodes: NodeMaterialBlock[];
  22428. /**
  22429. * Gets or sets the root nodes of the material fragment (pixel) shader
  22430. */
  22431. _fragmentOutputNodes: NodeMaterialBlock[];
  22432. /** Gets or sets options to control the node material overall behavior */
  22433. get options(): INodeMaterialOptions;
  22434. set options(options: INodeMaterialOptions);
  22435. /**
  22436. * Default configuration related to image processing available in the standard Material.
  22437. */
  22438. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22439. /**
  22440. * Gets the image processing configuration used either in this material.
  22441. */
  22442. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22443. /**
  22444. * Sets the Default image processing configuration used either in the this material.
  22445. *
  22446. * If sets to null, the scene one is in use.
  22447. */
  22448. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22449. /**
  22450. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22451. */
  22452. attachedBlocks: NodeMaterialBlock[];
  22453. /**
  22454. * Specifies the mode of the node material
  22455. * @hidden
  22456. */
  22457. _mode: NodeMaterialModes;
  22458. /**
  22459. * Gets the mode property
  22460. */
  22461. get mode(): NodeMaterialModes;
  22462. /**
  22463. * Create a new node based material
  22464. * @param name defines the material name
  22465. * @param scene defines the hosting scene
  22466. * @param options defines creation option
  22467. */
  22468. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22469. /**
  22470. * Gets the current class name of the material e.g. "NodeMaterial"
  22471. * @returns the class name
  22472. */
  22473. getClassName(): string;
  22474. /**
  22475. * Keep track of the image processing observer to allow dispose and replace.
  22476. */
  22477. private _imageProcessingObserver;
  22478. /**
  22479. * Attaches a new image processing configuration to the Standard Material.
  22480. * @param configuration
  22481. */
  22482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22483. /**
  22484. * Get a block by its name
  22485. * @param name defines the name of the block to retrieve
  22486. * @returns the required block or null if not found
  22487. */
  22488. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22489. /**
  22490. * Get a block by its name
  22491. * @param predicate defines the predicate used to find the good candidate
  22492. * @returns the required block or null if not found
  22493. */
  22494. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22495. /**
  22496. * Get an input block by its name
  22497. * @param predicate defines the predicate used to find the good candidate
  22498. * @returns the required input block or null if not found
  22499. */
  22500. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22501. /**
  22502. * Gets the list of input blocks attached to this material
  22503. * @returns an array of InputBlocks
  22504. */
  22505. getInputBlocks(): InputBlock[];
  22506. /**
  22507. * Adds a new optimizer to the list of optimizers
  22508. * @param optimizer defines the optimizers to add
  22509. * @returns the current material
  22510. */
  22511. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22512. /**
  22513. * Remove an optimizer from the list of optimizers
  22514. * @param optimizer defines the optimizers to remove
  22515. * @returns the current material
  22516. */
  22517. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22518. /**
  22519. * Add a new block to the list of output nodes
  22520. * @param node defines the node to add
  22521. * @returns the current material
  22522. */
  22523. addOutputNode(node: NodeMaterialBlock): this;
  22524. /**
  22525. * Remove a block from the list of root nodes
  22526. * @param node defines the node to remove
  22527. * @returns the current material
  22528. */
  22529. removeOutputNode(node: NodeMaterialBlock): this;
  22530. private _addVertexOutputNode;
  22531. private _removeVertexOutputNode;
  22532. private _addFragmentOutputNode;
  22533. private _removeFragmentOutputNode;
  22534. /**
  22535. * Specifies if the material will require alpha blending
  22536. * @returns a boolean specifying if alpha blending is needed
  22537. */
  22538. needAlphaBlending(): boolean;
  22539. /**
  22540. * Specifies if this material should be rendered in alpha test mode
  22541. * @returns a boolean specifying if an alpha test is needed.
  22542. */
  22543. needAlphaTesting(): boolean;
  22544. private _initializeBlock;
  22545. private _resetDualBlocks;
  22546. /**
  22547. * Remove a block from the current node material
  22548. * @param block defines the block to remove
  22549. */
  22550. removeBlock(block: NodeMaterialBlock): void;
  22551. /**
  22552. * Build the material and generates the inner effect
  22553. * @param verbose defines if the build should log activity
  22554. */
  22555. build(verbose?: boolean): void;
  22556. /**
  22557. * Runs an otpimization phase to try to improve the shader code
  22558. */
  22559. optimize(): void;
  22560. private _prepareDefinesForAttributes;
  22561. /**
  22562. * Create a post process from the material
  22563. * @param camera The camera to apply the render pass to.
  22564. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22566. * @param engine The engine which the post process will be applied. (default: current engine)
  22567. * @param reusable If the post process can be reused on the same frame. (default: false)
  22568. * @param textureType Type of textures used when performing the post process. (default: 0)
  22569. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22570. * @returns the post process created
  22571. */
  22572. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22573. /**
  22574. * Create the post process effect from the material
  22575. * @param postProcess The post process to create the effect for
  22576. */
  22577. createEffectForPostProcess(postProcess: PostProcess): void;
  22578. private _createEffectForPostProcess;
  22579. /**
  22580. * Create a new procedural texture based on this node material
  22581. * @param size defines the size of the texture
  22582. * @param scene defines the hosting scene
  22583. * @returns the new procedural texture attached to this node material
  22584. */
  22585. createProceduralTexture(size: number | {
  22586. width: number;
  22587. height: number;
  22588. layers?: number;
  22589. }, scene: Scene): Nullable<ProceduralTexture>;
  22590. private _createEffectForParticles;
  22591. private _checkInternals;
  22592. /**
  22593. * Create the effect to be used as the custom effect for a particle system
  22594. * @param particleSystem Particle system to create the effect for
  22595. * @param onCompiled defines a function to call when the effect creation is successful
  22596. * @param onError defines a function to call when the effect creation has failed
  22597. */
  22598. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22599. private _processDefines;
  22600. /**
  22601. * Get if the submesh is ready to be used and all its information available.
  22602. * Child classes can use it to update shaders
  22603. * @param mesh defines the mesh to check
  22604. * @param subMesh defines which submesh to check
  22605. * @param useInstances specifies that instances should be used
  22606. * @returns a boolean indicating that the submesh is ready or not
  22607. */
  22608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22609. /**
  22610. * Get a string representing the shaders built by the current node graph
  22611. */
  22612. get compiledShaders(): string;
  22613. /**
  22614. * Binds the world matrix to the material
  22615. * @param world defines the world transformation matrix
  22616. */
  22617. bindOnlyWorldMatrix(world: Matrix): void;
  22618. /**
  22619. * Binds the submesh to this material by preparing the effect and shader to draw
  22620. * @param world defines the world transformation matrix
  22621. * @param mesh defines the mesh containing the submesh
  22622. * @param subMesh defines the submesh to bind the material to
  22623. */
  22624. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22625. /**
  22626. * Gets the active textures from the material
  22627. * @returns an array of textures
  22628. */
  22629. getActiveTextures(): BaseTexture[];
  22630. /**
  22631. * Gets the list of texture blocks
  22632. * @returns an array of texture blocks
  22633. */
  22634. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22635. /**
  22636. * Specifies if the material uses a texture
  22637. * @param texture defines the texture to check against the material
  22638. * @returns a boolean specifying if the material uses the texture
  22639. */
  22640. hasTexture(texture: BaseTexture): boolean;
  22641. /**
  22642. * Disposes the material
  22643. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22644. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22645. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22646. */
  22647. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22648. /** Creates the node editor window. */
  22649. private _createNodeEditor;
  22650. /**
  22651. * Launch the node material editor
  22652. * @param config Define the configuration of the editor
  22653. * @return a promise fulfilled when the node editor is visible
  22654. */
  22655. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22656. /**
  22657. * Clear the current material
  22658. */
  22659. clear(): void;
  22660. /**
  22661. * Clear the current material and set it to a default state
  22662. */
  22663. setToDefault(): void;
  22664. /**
  22665. * Clear the current material and set it to a default state for post process
  22666. */
  22667. setToDefaultPostProcess(): void;
  22668. /**
  22669. * Clear the current material and set it to a default state for procedural texture
  22670. */
  22671. setToDefaultProceduralTexture(): void;
  22672. /**
  22673. * Clear the current material and set it to a default state for particle
  22674. */
  22675. setToDefaultParticle(): void;
  22676. /**
  22677. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22678. * @param url defines the url to load from
  22679. * @returns a promise that will fullfil when the material is fully loaded
  22680. */
  22681. loadAsync(url: string): Promise<void>;
  22682. private _gatherBlocks;
  22683. /**
  22684. * Generate a string containing the code declaration required to create an equivalent of this material
  22685. * @returns a string
  22686. */
  22687. generateCode(): string;
  22688. /**
  22689. * Serializes this material in a JSON representation
  22690. * @returns the serialized material object
  22691. */
  22692. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22693. private _restoreConnections;
  22694. /**
  22695. * Clear the current graph and load a new one from a serialization object
  22696. * @param source defines the JSON representation of the material
  22697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22698. * @param merge defines whether or not the source must be merged or replace the current content
  22699. */
  22700. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22701. /**
  22702. * Makes a duplicate of the current material.
  22703. * @param name - name to use for the new material.
  22704. */
  22705. clone(name: string): NodeMaterial;
  22706. /**
  22707. * Creates a node material from parsed material data
  22708. * @param source defines the JSON representation of the material
  22709. * @param scene defines the hosting scene
  22710. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22711. * @returns a new node material
  22712. */
  22713. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22714. /**
  22715. * Creates a node material from a snippet saved in a remote file
  22716. * @param name defines the name of the material to create
  22717. * @param url defines the url to load from
  22718. * @param scene defines the hosting scene
  22719. * @returns a promise that will resolve to the new node material
  22720. */
  22721. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22722. /**
  22723. * Creates a node material from a snippet saved by the node material editor
  22724. * @param snippetId defines the snippet to load
  22725. * @param scene defines the hosting scene
  22726. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22727. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22728. * @returns a promise that will resolve to the new node material
  22729. */
  22730. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22731. /**
  22732. * Creates a new node material set to default basic configuration
  22733. * @param name defines the name of the material
  22734. * @param scene defines the hosting scene
  22735. * @returns a new NodeMaterial
  22736. */
  22737. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22738. }
  22739. }
  22740. declare module BABYLON {
  22741. /**
  22742. * Size options for a post process
  22743. */
  22744. export type PostProcessOptions = {
  22745. width: number;
  22746. height: number;
  22747. };
  22748. /**
  22749. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22750. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22751. */
  22752. export class PostProcess {
  22753. /**
  22754. * Gets or sets the unique id of the post process
  22755. */
  22756. uniqueId: number;
  22757. /** Name of the PostProcess. */
  22758. name: string;
  22759. /**
  22760. * Width of the texture to apply the post process on
  22761. */
  22762. width: number;
  22763. /**
  22764. * Height of the texture to apply the post process on
  22765. */
  22766. height: number;
  22767. /**
  22768. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22769. */
  22770. nodeMaterialSource: Nullable<NodeMaterial>;
  22771. /**
  22772. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22773. * @hidden
  22774. */
  22775. _outputTexture: Nullable<InternalTexture>;
  22776. /**
  22777. * Sampling mode used by the shader
  22778. * See https://doc.babylonjs.com/classes/3.1/texture
  22779. */
  22780. renderTargetSamplingMode: number;
  22781. /**
  22782. * Clear color to use when screen clearing
  22783. */
  22784. clearColor: Color4;
  22785. /**
  22786. * If the buffer needs to be cleared before applying the post process. (default: true)
  22787. * Should be set to false if shader will overwrite all previous pixels.
  22788. */
  22789. autoClear: boolean;
  22790. /**
  22791. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22792. */
  22793. alphaMode: number;
  22794. /**
  22795. * Sets the setAlphaBlendConstants of the babylon engine
  22796. */
  22797. alphaConstants: Color4;
  22798. /**
  22799. * Animations to be used for the post processing
  22800. */
  22801. animations: Animation[];
  22802. /**
  22803. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22804. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22805. */
  22806. enablePixelPerfectMode: boolean;
  22807. /**
  22808. * Force the postprocess to be applied without taking in account viewport
  22809. */
  22810. forceFullscreenViewport: boolean;
  22811. /**
  22812. * List of inspectable custom properties (used by the Inspector)
  22813. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22814. */
  22815. inspectableCustomProperties: IInspectable[];
  22816. /**
  22817. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22818. *
  22819. * | Value | Type | Description |
  22820. * | ----- | ----------------------------------- | ----------- |
  22821. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22822. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22823. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22824. *
  22825. */
  22826. scaleMode: number;
  22827. /**
  22828. * Force textures to be a power of two (default: false)
  22829. */
  22830. alwaysForcePOT: boolean;
  22831. private _samples;
  22832. /**
  22833. * Number of sample textures (default: 1)
  22834. */
  22835. get samples(): number;
  22836. set samples(n: number);
  22837. /**
  22838. * Modify the scale of the post process to be the same as the viewport (default: false)
  22839. */
  22840. adaptScaleToCurrentViewport: boolean;
  22841. private _camera;
  22842. protected _scene: Scene;
  22843. private _engine;
  22844. private _options;
  22845. private _reusable;
  22846. private _textureType;
  22847. private _textureFormat;
  22848. /**
  22849. * Smart array of input and output textures for the post process.
  22850. * @hidden
  22851. */
  22852. _textures: SmartArray<InternalTexture>;
  22853. /**
  22854. * The index in _textures that corresponds to the output texture.
  22855. * @hidden
  22856. */
  22857. _currentRenderTextureInd: number;
  22858. private _effect;
  22859. private _samplers;
  22860. private _fragmentUrl;
  22861. private _vertexUrl;
  22862. private _parameters;
  22863. private _scaleRatio;
  22864. protected _indexParameters: any;
  22865. private _shareOutputWithPostProcess;
  22866. private _texelSize;
  22867. private _forcedOutputTexture;
  22868. /**
  22869. * Returns the fragment url or shader name used in the post process.
  22870. * @returns the fragment url or name in the shader store.
  22871. */
  22872. getEffectName(): string;
  22873. /**
  22874. * An event triggered when the postprocess is activated.
  22875. */
  22876. onActivateObservable: Observable<Camera>;
  22877. private _onActivateObserver;
  22878. /**
  22879. * A function that is added to the onActivateObservable
  22880. */
  22881. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22882. /**
  22883. * An event triggered when the postprocess changes its size.
  22884. */
  22885. onSizeChangedObservable: Observable<PostProcess>;
  22886. private _onSizeChangedObserver;
  22887. /**
  22888. * A function that is added to the onSizeChangedObservable
  22889. */
  22890. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22891. /**
  22892. * An event triggered when the postprocess applies its effect.
  22893. */
  22894. onApplyObservable: Observable<Effect>;
  22895. private _onApplyObserver;
  22896. /**
  22897. * A function that is added to the onApplyObservable
  22898. */
  22899. set onApply(callback: (effect: Effect) => void);
  22900. /**
  22901. * An event triggered before rendering the postprocess
  22902. */
  22903. onBeforeRenderObservable: Observable<Effect>;
  22904. private _onBeforeRenderObserver;
  22905. /**
  22906. * A function that is added to the onBeforeRenderObservable
  22907. */
  22908. set onBeforeRender(callback: (effect: Effect) => void);
  22909. /**
  22910. * An event triggered after rendering the postprocess
  22911. */
  22912. onAfterRenderObservable: Observable<Effect>;
  22913. private _onAfterRenderObserver;
  22914. /**
  22915. * A function that is added to the onAfterRenderObservable
  22916. */
  22917. set onAfterRender(callback: (efect: Effect) => void);
  22918. /**
  22919. * 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
  22920. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22921. */
  22922. get inputTexture(): InternalTexture;
  22923. set inputTexture(value: InternalTexture);
  22924. /**
  22925. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22926. * the only way to unset it is to use this function to restore its internal state
  22927. */
  22928. restoreDefaultInputTexture(): void;
  22929. /**
  22930. * Gets the camera which post process is applied to.
  22931. * @returns The camera the post process is applied to.
  22932. */
  22933. getCamera(): Camera;
  22934. /**
  22935. * Gets the texel size of the postprocess.
  22936. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22937. */
  22938. get texelSize(): Vector2;
  22939. /**
  22940. * Creates a new instance PostProcess
  22941. * @param name The name of the PostProcess.
  22942. * @param fragmentUrl The url of the fragment shader to be used.
  22943. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22944. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22945. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22946. * @param camera The camera to apply the render pass to.
  22947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22948. * @param engine The engine which the post process will be applied. (default: current engine)
  22949. * @param reusable If the post process can be reused on the same frame. (default: false)
  22950. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22951. * @param textureType Type of textures used when performing the post process. (default: 0)
  22952. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22953. * @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
  22954. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22955. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22956. */
  22957. 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);
  22958. /**
  22959. * Gets a string identifying the name of the class
  22960. * @returns "PostProcess" string
  22961. */
  22962. getClassName(): string;
  22963. /**
  22964. * Gets the engine which this post process belongs to.
  22965. * @returns The engine the post process was enabled with.
  22966. */
  22967. getEngine(): Engine;
  22968. /**
  22969. * The effect that is created when initializing the post process.
  22970. * @returns The created effect corresponding the the postprocess.
  22971. */
  22972. getEffect(): Effect;
  22973. /**
  22974. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22975. * @param postProcess The post process to share the output with.
  22976. * @returns This post process.
  22977. */
  22978. shareOutputWith(postProcess: PostProcess): PostProcess;
  22979. /**
  22980. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22981. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22982. */
  22983. useOwnOutput(): void;
  22984. /**
  22985. * Updates the effect with the current post process compile time values and recompiles the shader.
  22986. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22987. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22988. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22989. * @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
  22990. * @param onCompiled Called when the shader has been compiled.
  22991. * @param onError Called if there is an error when compiling a shader.
  22992. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22993. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22994. */
  22995. 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;
  22996. /**
  22997. * The post process is reusable if it can be used multiple times within one frame.
  22998. * @returns If the post process is reusable
  22999. */
  23000. isReusable(): boolean;
  23001. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23002. markTextureDirty(): void;
  23003. /**
  23004. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23005. * 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.
  23006. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23007. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23008. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23009. * @returns The target texture that was bound to be written to.
  23010. */
  23011. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23012. /**
  23013. * If the post process is supported.
  23014. */
  23015. get isSupported(): boolean;
  23016. /**
  23017. * The aspect ratio of the output texture.
  23018. */
  23019. get aspectRatio(): number;
  23020. /**
  23021. * Get a value indicating if the post-process is ready to be used
  23022. * @returns true if the post-process is ready (shader is compiled)
  23023. */
  23024. isReady(): boolean;
  23025. /**
  23026. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23027. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23028. */
  23029. apply(): Nullable<Effect>;
  23030. private _disposeTextures;
  23031. /**
  23032. * Disposes the post process.
  23033. * @param camera The camera to dispose the post process on.
  23034. */
  23035. dispose(camera?: Camera): void;
  23036. /**
  23037. * Serializes the particle system to a JSON object
  23038. * @returns the JSON object
  23039. */
  23040. serialize(): any;
  23041. /**
  23042. * Creates a material from parsed material data
  23043. * @param parsedPostProcess defines parsed post process data
  23044. * @param scene defines the hosting scene
  23045. * @param rootUrl defines the root URL to use to load textures
  23046. * @returns a new post process
  23047. */
  23048. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23049. }
  23050. }
  23051. declare module BABYLON {
  23052. /** @hidden */
  23053. export var kernelBlurVaryingDeclaration: {
  23054. name: string;
  23055. shader: string;
  23056. };
  23057. }
  23058. declare module BABYLON {
  23059. /** @hidden */
  23060. export var kernelBlurFragment: {
  23061. name: string;
  23062. shader: string;
  23063. };
  23064. }
  23065. declare module BABYLON {
  23066. /** @hidden */
  23067. export var kernelBlurFragment2: {
  23068. name: string;
  23069. shader: string;
  23070. };
  23071. }
  23072. declare module BABYLON {
  23073. /** @hidden */
  23074. export var kernelBlurPixelShader: {
  23075. name: string;
  23076. shader: string;
  23077. };
  23078. }
  23079. declare module BABYLON {
  23080. /** @hidden */
  23081. export var kernelBlurVertex: {
  23082. name: string;
  23083. shader: string;
  23084. };
  23085. }
  23086. declare module BABYLON {
  23087. /** @hidden */
  23088. export var kernelBlurVertexShader: {
  23089. name: string;
  23090. shader: string;
  23091. };
  23092. }
  23093. declare module BABYLON {
  23094. /**
  23095. * The Blur Post Process which blurs an image based on a kernel and direction.
  23096. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23097. */
  23098. export class BlurPostProcess extends PostProcess {
  23099. private blockCompilation;
  23100. protected _kernel: number;
  23101. protected _idealKernel: number;
  23102. protected _packedFloat: boolean;
  23103. private _staticDefines;
  23104. /** The direction in which to blur the image. */
  23105. direction: Vector2;
  23106. /**
  23107. * Sets the length in pixels of the blur sample region
  23108. */
  23109. set kernel(v: number);
  23110. /**
  23111. * Gets the length in pixels of the blur sample region
  23112. */
  23113. get kernel(): number;
  23114. /**
  23115. * Sets wether or not the blur needs to unpack/repack floats
  23116. */
  23117. set packedFloat(v: boolean);
  23118. /**
  23119. * Gets wether or not the blur is unpacking/repacking floats
  23120. */
  23121. get packedFloat(): boolean;
  23122. /**
  23123. * Gets a string identifying the name of the class
  23124. * @returns "BlurPostProcess" string
  23125. */
  23126. getClassName(): string;
  23127. /**
  23128. * Creates a new instance BlurPostProcess
  23129. * @param name The name of the effect.
  23130. * @param direction The direction in which to blur the image.
  23131. * @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.
  23132. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23133. * @param camera The camera to apply the render pass to.
  23134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23135. * @param engine The engine which the post process will be applied. (default: current engine)
  23136. * @param reusable If the post process can be reused on the same frame. (default: false)
  23137. * @param textureType Type of textures used when performing the post process. (default: 0)
  23138. * @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)
  23139. */
  23140. 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);
  23141. /**
  23142. * Updates the effect with the current post process compile time values and recompiles the shader.
  23143. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23144. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23145. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23146. * @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
  23147. * @param onCompiled Called when the shader has been compiled.
  23148. * @param onError Called if there is an error when compiling a shader.
  23149. */
  23150. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23151. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23152. /**
  23153. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23154. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23155. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23156. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23157. * The gaps between physical kernels are compensated for in the weighting of the samples
  23158. * @param idealKernel Ideal blur kernel.
  23159. * @return Nearest best kernel.
  23160. */
  23161. protected _nearestBestKernel(idealKernel: number): number;
  23162. /**
  23163. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23164. * @param x The point on the Gaussian distribution to sample.
  23165. * @return the value of the Gaussian function at x.
  23166. */
  23167. protected _gaussianWeight(x: number): number;
  23168. /**
  23169. * Generates a string that can be used as a floating point number in GLSL.
  23170. * @param x Value to print.
  23171. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23172. * @return GLSL float string.
  23173. */
  23174. protected _glslFloat(x: number, decimalFigures?: number): string;
  23175. /** @hidden */
  23176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23177. }
  23178. }
  23179. declare module BABYLON {
  23180. /**
  23181. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23182. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23183. * You can then easily use it as a reflectionTexture on a flat surface.
  23184. * In case the surface is not a plane, please consider relying on reflection probes.
  23185. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23186. */
  23187. export class MirrorTexture extends RenderTargetTexture {
  23188. private scene;
  23189. /**
  23190. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23191. * 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.
  23192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23193. */
  23194. mirrorPlane: Plane;
  23195. /**
  23196. * Define the blur ratio used to blur the reflection if needed.
  23197. */
  23198. set blurRatio(value: number);
  23199. get blurRatio(): number;
  23200. /**
  23201. * Define the adaptive blur kernel used to blur the reflection if needed.
  23202. * This will autocompute the closest best match for the `blurKernel`
  23203. */
  23204. set adaptiveBlurKernel(value: number);
  23205. /**
  23206. * Define the blur kernel used to blur the reflection if needed.
  23207. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23208. */
  23209. set blurKernel(value: number);
  23210. /**
  23211. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23212. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23213. */
  23214. set blurKernelX(value: number);
  23215. get blurKernelX(): number;
  23216. /**
  23217. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23218. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23219. */
  23220. set blurKernelY(value: number);
  23221. get blurKernelY(): number;
  23222. private _autoComputeBlurKernel;
  23223. protected _onRatioRescale(): void;
  23224. private _updateGammaSpace;
  23225. private _imageProcessingConfigChangeObserver;
  23226. private _transformMatrix;
  23227. private _mirrorMatrix;
  23228. private _savedViewMatrix;
  23229. private _blurX;
  23230. private _blurY;
  23231. private _adaptiveBlurKernel;
  23232. private _blurKernelX;
  23233. private _blurKernelY;
  23234. private _blurRatio;
  23235. /**
  23236. * Instantiates a Mirror Texture.
  23237. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23238. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23239. * You can then easily use it as a reflectionTexture on a flat surface.
  23240. * In case the surface is not a plane, please consider relying on reflection probes.
  23241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23242. * @param name
  23243. * @param size
  23244. * @param scene
  23245. * @param generateMipMaps
  23246. * @param type
  23247. * @param samplingMode
  23248. * @param generateDepthBuffer
  23249. */
  23250. constructor(name: string, size: number | {
  23251. width: number;
  23252. height: number;
  23253. } | {
  23254. ratio: number;
  23255. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23256. private _preparePostProcesses;
  23257. /**
  23258. * Clone the mirror texture.
  23259. * @returns the cloned texture
  23260. */
  23261. clone(): MirrorTexture;
  23262. /**
  23263. * Serialize the texture to a JSON representation you could use in Parse later on
  23264. * @returns the serialized JSON representation
  23265. */
  23266. serialize(): any;
  23267. /**
  23268. * Dispose the texture and release its associated resources.
  23269. */
  23270. dispose(): void;
  23271. }
  23272. }
  23273. declare module BABYLON {
  23274. /**
  23275. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23276. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23277. */
  23278. export class Texture extends BaseTexture {
  23279. /**
  23280. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23281. */
  23282. static SerializeBuffers: boolean;
  23283. /** @hidden */
  23284. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23285. /** @hidden */
  23286. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23287. /** @hidden */
  23288. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23289. /** nearest is mag = nearest and min = nearest and mip = linear */
  23290. static readonly NEAREST_SAMPLINGMODE: number;
  23291. /** nearest is mag = nearest and min = nearest and mip = linear */
  23292. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23293. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23294. static readonly BILINEAR_SAMPLINGMODE: number;
  23295. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23296. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23297. /** Trilinear is mag = linear and min = linear and mip = linear */
  23298. static readonly TRILINEAR_SAMPLINGMODE: number;
  23299. /** Trilinear is mag = linear and min = linear and mip = linear */
  23300. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23301. /** mag = nearest and min = nearest and mip = nearest */
  23302. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23303. /** mag = nearest and min = linear and mip = nearest */
  23304. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23305. /** mag = nearest and min = linear and mip = linear */
  23306. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23307. /** mag = nearest and min = linear and mip = none */
  23308. static readonly NEAREST_LINEAR: number;
  23309. /** mag = nearest and min = nearest and mip = none */
  23310. static readonly NEAREST_NEAREST: number;
  23311. /** mag = linear and min = nearest and mip = nearest */
  23312. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23313. /** mag = linear and min = nearest and mip = linear */
  23314. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23315. /** mag = linear and min = linear and mip = none */
  23316. static readonly LINEAR_LINEAR: number;
  23317. /** mag = linear and min = nearest and mip = none */
  23318. static readonly LINEAR_NEAREST: number;
  23319. /** Explicit coordinates mode */
  23320. static readonly EXPLICIT_MODE: number;
  23321. /** Spherical coordinates mode */
  23322. static readonly SPHERICAL_MODE: number;
  23323. /** Planar coordinates mode */
  23324. static readonly PLANAR_MODE: number;
  23325. /** Cubic coordinates mode */
  23326. static readonly CUBIC_MODE: number;
  23327. /** Projection coordinates mode */
  23328. static readonly PROJECTION_MODE: number;
  23329. /** Inverse Cubic coordinates mode */
  23330. static readonly SKYBOX_MODE: number;
  23331. /** Inverse Cubic coordinates mode */
  23332. static readonly INVCUBIC_MODE: number;
  23333. /** Equirectangular coordinates mode */
  23334. static readonly EQUIRECTANGULAR_MODE: number;
  23335. /** Equirectangular Fixed coordinates mode */
  23336. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23337. /** Equirectangular Fixed Mirrored coordinates mode */
  23338. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23339. /** Texture is not repeating outside of 0..1 UVs */
  23340. static readonly CLAMP_ADDRESSMODE: number;
  23341. /** Texture is repeating outside of 0..1 UVs */
  23342. static readonly WRAP_ADDRESSMODE: number;
  23343. /** Texture is repeating and mirrored */
  23344. static readonly MIRROR_ADDRESSMODE: number;
  23345. /**
  23346. * 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
  23347. */
  23348. static UseSerializedUrlIfAny: boolean;
  23349. /**
  23350. * Define the url of the texture.
  23351. */
  23352. url: Nullable<string>;
  23353. /**
  23354. * Define an offset on the texture to offset the u coordinates of the UVs
  23355. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23356. */
  23357. uOffset: number;
  23358. /**
  23359. * Define an offset on the texture to offset the v coordinates of the UVs
  23360. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23361. */
  23362. vOffset: number;
  23363. /**
  23364. * Define an offset on the texture to scale the u coordinates of the UVs
  23365. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23366. */
  23367. uScale: number;
  23368. /**
  23369. * Define an offset on the texture to scale the v coordinates of the UVs
  23370. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23371. */
  23372. vScale: number;
  23373. /**
  23374. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23375. * @see https://doc.babylonjs.com/how_to/more_materials
  23376. */
  23377. uAng: number;
  23378. /**
  23379. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23380. * @see https://doc.babylonjs.com/how_to/more_materials
  23381. */
  23382. vAng: number;
  23383. /**
  23384. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23385. * @see https://doc.babylonjs.com/how_to/more_materials
  23386. */
  23387. wAng: number;
  23388. /**
  23389. * Defines the center of rotation (U)
  23390. */
  23391. uRotationCenter: number;
  23392. /**
  23393. * Defines the center of rotation (V)
  23394. */
  23395. vRotationCenter: number;
  23396. /**
  23397. * Defines the center of rotation (W)
  23398. */
  23399. wRotationCenter: number;
  23400. /**
  23401. * Are mip maps generated for this texture or not.
  23402. */
  23403. get noMipmap(): boolean;
  23404. /**
  23405. * List of inspectable custom properties (used by the Inspector)
  23406. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23407. */
  23408. inspectableCustomProperties: Nullable<IInspectable[]>;
  23409. private _noMipmap;
  23410. /** @hidden */
  23411. _invertY: boolean;
  23412. private _rowGenerationMatrix;
  23413. private _cachedTextureMatrix;
  23414. private _projectionModeMatrix;
  23415. private _t0;
  23416. private _t1;
  23417. private _t2;
  23418. private _cachedUOffset;
  23419. private _cachedVOffset;
  23420. private _cachedUScale;
  23421. private _cachedVScale;
  23422. private _cachedUAng;
  23423. private _cachedVAng;
  23424. private _cachedWAng;
  23425. private _cachedProjectionMatrixId;
  23426. private _cachedCoordinatesMode;
  23427. /** @hidden */
  23428. protected _initialSamplingMode: number;
  23429. /** @hidden */
  23430. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23431. private _deleteBuffer;
  23432. protected _format: Nullable<number>;
  23433. private _delayedOnLoad;
  23434. private _delayedOnError;
  23435. private _mimeType?;
  23436. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23437. get mimeType(): string | undefined;
  23438. /**
  23439. * Observable triggered once the texture has been loaded.
  23440. */
  23441. onLoadObservable: Observable<Texture>;
  23442. protected _isBlocking: boolean;
  23443. /**
  23444. * Is the texture preventing material to render while loading.
  23445. * If false, a default texture will be used instead of the loading one during the preparation step.
  23446. */
  23447. set isBlocking(value: boolean);
  23448. get isBlocking(): boolean;
  23449. /**
  23450. * Get the current sampling mode associated with the texture.
  23451. */
  23452. get samplingMode(): number;
  23453. /**
  23454. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23455. */
  23456. get invertY(): boolean;
  23457. /**
  23458. * Instantiates a new texture.
  23459. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23460. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23461. * @param url defines the url of the picture to load as a texture
  23462. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23463. * @param noMipmap defines if the texture will require mip maps or not
  23464. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23465. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23466. * @param onLoad defines a callback triggered when the texture has been loaded
  23467. * @param onError defines a callback triggered when an error occurred during the loading session
  23468. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23469. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23470. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23471. * @param mimeType defines an optional mime type information
  23472. */
  23473. 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);
  23474. /**
  23475. * Update the url (and optional buffer) of this texture if url was null during construction.
  23476. * @param url the url of the texture
  23477. * @param buffer the buffer of the texture (defaults to null)
  23478. * @param onLoad callback called when the texture is loaded (defaults to null)
  23479. */
  23480. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23481. /**
  23482. * Finish the loading sequence of a texture flagged as delayed load.
  23483. * @hidden
  23484. */
  23485. delayLoad(): void;
  23486. private _prepareRowForTextureGeneration;
  23487. /**
  23488. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23489. * @returns the transform matrix of the texture.
  23490. */
  23491. getTextureMatrix(uBase?: number): Matrix;
  23492. /**
  23493. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23494. * @returns The reflection texture transform
  23495. */
  23496. getReflectionTextureMatrix(): Matrix;
  23497. /**
  23498. * Clones the texture.
  23499. * @returns the cloned texture
  23500. */
  23501. clone(): Texture;
  23502. /**
  23503. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23504. * @returns The JSON representation of the texture
  23505. */
  23506. serialize(): any;
  23507. /**
  23508. * Get the current class name of the texture useful for serialization or dynamic coding.
  23509. * @returns "Texture"
  23510. */
  23511. getClassName(): string;
  23512. /**
  23513. * Dispose the texture and release its associated resources.
  23514. */
  23515. dispose(): void;
  23516. /**
  23517. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23518. * @param parsedTexture Define the JSON representation of the texture
  23519. * @param scene Define the scene the parsed texture should be instantiated in
  23520. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23521. * @returns The parsed texture if successful
  23522. */
  23523. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23524. /**
  23525. * Creates a texture from its base 64 representation.
  23526. * @param data Define the base64 payload without the data: prefix
  23527. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23528. * @param scene Define the scene the texture should belong to
  23529. * @param noMipmap Forces the texture to not create mip map information if true
  23530. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23531. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23532. * @param onLoad define a callback triggered when the texture has been loaded
  23533. * @param onError define a callback triggered when an error occurred during the loading session
  23534. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23535. * @returns the created texture
  23536. */
  23537. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23538. /**
  23539. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23540. * @param data Define the base64 payload without the data: prefix
  23541. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23542. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23543. * @param scene Define the scene the texture should belong to
  23544. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23545. * @param noMipmap Forces the texture to not create mip map information if true
  23546. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23547. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23548. * @param onLoad define a callback triggered when the texture has been loaded
  23549. * @param onError define a callback triggered when an error occurred during the loading session
  23550. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23551. * @returns the created texture
  23552. */
  23553. 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;
  23554. }
  23555. }
  23556. declare module BABYLON {
  23557. /**
  23558. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23559. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23560. */
  23561. export class PostProcessManager {
  23562. private _scene;
  23563. private _indexBuffer;
  23564. private _vertexBuffers;
  23565. /**
  23566. * Creates a new instance PostProcess
  23567. * @param scene The scene that the post process is associated with.
  23568. */
  23569. constructor(scene: Scene);
  23570. private _prepareBuffers;
  23571. private _buildIndexBuffer;
  23572. /**
  23573. * Rebuilds the vertex buffers of the manager.
  23574. * @hidden
  23575. */
  23576. _rebuild(): void;
  23577. /**
  23578. * Prepares a frame to be run through a post process.
  23579. * @param sourceTexture The input texture to the post procesess. (default: null)
  23580. * @param postProcesses An array of post processes to be run. (default: null)
  23581. * @returns True if the post processes were able to be run.
  23582. * @hidden
  23583. */
  23584. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23585. /**
  23586. * Manually render a set of post processes to a texture.
  23587. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23588. * @param postProcesses An array of post processes to be run.
  23589. * @param targetTexture The target texture to render to.
  23590. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23591. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23592. * @param lodLevel defines which lod of the texture to render to
  23593. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23594. */
  23595. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23596. /**
  23597. * Finalize the result of the output of the postprocesses.
  23598. * @param doNotPresent If true the result will not be displayed to the screen.
  23599. * @param targetTexture The target texture to render to.
  23600. * @param faceIndex The index of the face to bind the target texture to.
  23601. * @param postProcesses The array of post processes to render.
  23602. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23603. * @hidden
  23604. */
  23605. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23606. /**
  23607. * Disposes of the post process manager.
  23608. */
  23609. dispose(): void;
  23610. }
  23611. }
  23612. declare module BABYLON {
  23613. /**
  23614. * This Helps creating a texture that will be created from a camera in your scene.
  23615. * It is basically a dynamic texture that could be used to create special effects for instance.
  23616. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23617. */
  23618. export class RenderTargetTexture extends Texture {
  23619. /**
  23620. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23621. */
  23622. static readonly REFRESHRATE_RENDER_ONCE: number;
  23623. /**
  23624. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23625. */
  23626. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23627. /**
  23628. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23629. * the central point of your effect and can save a lot of performances.
  23630. */
  23631. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23632. /**
  23633. * Use this predicate to dynamically define the list of mesh you want to render.
  23634. * If set, the renderList property will be overwritten.
  23635. */
  23636. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23637. private _renderList;
  23638. /**
  23639. * Use this list to define the list of mesh you want to render.
  23640. */
  23641. get renderList(): Nullable<Array<AbstractMesh>>;
  23642. set renderList(value: Nullable<Array<AbstractMesh>>);
  23643. /**
  23644. * Use this function to overload the renderList array at rendering time.
  23645. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23646. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23647. * the cube (if the RTT is a cube, else layerOrFace=0).
  23648. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23649. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23650. * hold dummy elements!
  23651. */
  23652. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23653. private _hookArray;
  23654. /**
  23655. * Define if particles should be rendered in your texture.
  23656. */
  23657. renderParticles: boolean;
  23658. /**
  23659. * Define if sprites should be rendered in your texture.
  23660. */
  23661. renderSprites: boolean;
  23662. /**
  23663. * Define the camera used to render the texture.
  23664. */
  23665. activeCamera: Nullable<Camera>;
  23666. /**
  23667. * Override the mesh isReady function with your own one.
  23668. */
  23669. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23670. /**
  23671. * Override the render function of the texture with your own one.
  23672. */
  23673. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23674. /**
  23675. * Define if camera post processes should be use while rendering the texture.
  23676. */
  23677. useCameraPostProcesses: boolean;
  23678. /**
  23679. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23680. */
  23681. ignoreCameraViewport: boolean;
  23682. private _postProcessManager;
  23683. private _postProcesses;
  23684. private _resizeObserver;
  23685. /**
  23686. * An event triggered when the texture is unbind.
  23687. */
  23688. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23689. /**
  23690. * An event triggered when the texture is unbind.
  23691. */
  23692. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23693. private _onAfterUnbindObserver;
  23694. /**
  23695. * Set a after unbind callback in the texture.
  23696. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23697. */
  23698. set onAfterUnbind(callback: () => void);
  23699. /**
  23700. * An event triggered before rendering the texture
  23701. */
  23702. onBeforeRenderObservable: Observable<number>;
  23703. private _onBeforeRenderObserver;
  23704. /**
  23705. * Set a before render callback in the texture.
  23706. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23707. */
  23708. set onBeforeRender(callback: (faceIndex: number) => void);
  23709. /**
  23710. * An event triggered after rendering the texture
  23711. */
  23712. onAfterRenderObservable: Observable<number>;
  23713. private _onAfterRenderObserver;
  23714. /**
  23715. * Set a after render callback in the texture.
  23716. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23717. */
  23718. set onAfterRender(callback: (faceIndex: number) => void);
  23719. /**
  23720. * An event triggered after the texture clear
  23721. */
  23722. onClearObservable: Observable<Engine>;
  23723. private _onClearObserver;
  23724. /**
  23725. * Set a clear callback in the texture.
  23726. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23727. */
  23728. set onClear(callback: (Engine: Engine) => void);
  23729. /**
  23730. * An event triggered when the texture is resized.
  23731. */
  23732. onResizeObservable: Observable<RenderTargetTexture>;
  23733. /**
  23734. * Define the clear color of the Render Target if it should be different from the scene.
  23735. */
  23736. clearColor: Color4;
  23737. protected _size: number | {
  23738. width: number;
  23739. height: number;
  23740. layers?: number;
  23741. };
  23742. protected _initialSizeParameter: number | {
  23743. width: number;
  23744. height: number;
  23745. } | {
  23746. ratio: number;
  23747. };
  23748. protected _sizeRatio: Nullable<number>;
  23749. /** @hidden */
  23750. _generateMipMaps: boolean;
  23751. protected _renderingManager: RenderingManager;
  23752. /** @hidden */
  23753. _waitingRenderList?: string[];
  23754. protected _doNotChangeAspectRatio: boolean;
  23755. protected _currentRefreshId: number;
  23756. protected _refreshRate: number;
  23757. protected _textureMatrix: Matrix;
  23758. protected _samples: number;
  23759. protected _renderTargetOptions: RenderTargetCreationOptions;
  23760. /**
  23761. * Gets render target creation options that were used.
  23762. */
  23763. get renderTargetOptions(): RenderTargetCreationOptions;
  23764. protected _onRatioRescale(): void;
  23765. /**
  23766. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23767. * It must define where the camera used to render the texture is set
  23768. */
  23769. boundingBoxPosition: Vector3;
  23770. private _boundingBoxSize;
  23771. /**
  23772. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23773. * When defined, the cubemap will switch to local mode
  23774. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23775. * @example https://www.babylonjs-playground.com/#RNASML
  23776. */
  23777. set boundingBoxSize(value: Vector3);
  23778. get boundingBoxSize(): Vector3;
  23779. /**
  23780. * In case the RTT has been created with a depth texture, get the associated
  23781. * depth texture.
  23782. * Otherwise, return null.
  23783. */
  23784. get depthStencilTexture(): Nullable<InternalTexture>;
  23785. /**
  23786. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23787. * or used a shadow, depth texture...
  23788. * @param name The friendly name of the texture
  23789. * @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)
  23790. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23791. * @param generateMipMaps True if mip maps need to be generated after render.
  23792. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23793. * @param type The type of the buffer in the RTT (int, half float, float...)
  23794. * @param isCube True if a cube texture needs to be created
  23795. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23796. * @param generateDepthBuffer True to generate a depth buffer
  23797. * @param generateStencilBuffer True to generate a stencil buffer
  23798. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23799. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23800. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23801. */
  23802. constructor(name: string, size: number | {
  23803. width: number;
  23804. height: number;
  23805. layers?: number;
  23806. } | {
  23807. ratio: number;
  23808. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23809. /**
  23810. * Creates a depth stencil texture.
  23811. * This is only available in WebGL 2 or with the depth texture extension available.
  23812. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23813. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23814. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23815. */
  23816. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23817. private _processSizeParameter;
  23818. /**
  23819. * Define the number of samples to use in case of MSAA.
  23820. * It defaults to one meaning no MSAA has been enabled.
  23821. */
  23822. get samples(): number;
  23823. set samples(value: number);
  23824. /**
  23825. * Resets the refresh counter of the texture and start bak from scratch.
  23826. * Could be useful to regenerate the texture if it is setup to render only once.
  23827. */
  23828. resetRefreshCounter(): void;
  23829. /**
  23830. * Define the refresh rate of the texture or the rendering frequency.
  23831. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23832. */
  23833. get refreshRate(): number;
  23834. set refreshRate(value: number);
  23835. /**
  23836. * Adds a post process to the render target rendering passes.
  23837. * @param postProcess define the post process to add
  23838. */
  23839. addPostProcess(postProcess: PostProcess): void;
  23840. /**
  23841. * Clear all the post processes attached to the render target
  23842. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23843. */
  23844. clearPostProcesses(dispose?: boolean): void;
  23845. /**
  23846. * Remove one of the post process from the list of attached post processes to the texture
  23847. * @param postProcess define the post process to remove from the list
  23848. */
  23849. removePostProcess(postProcess: PostProcess): void;
  23850. /** @hidden */
  23851. _shouldRender(): boolean;
  23852. /**
  23853. * Gets the actual render size of the texture.
  23854. * @returns the width of the render size
  23855. */
  23856. getRenderSize(): number;
  23857. /**
  23858. * Gets the actual render width of the texture.
  23859. * @returns the width of the render size
  23860. */
  23861. getRenderWidth(): number;
  23862. /**
  23863. * Gets the actual render height of the texture.
  23864. * @returns the height of the render size
  23865. */
  23866. getRenderHeight(): number;
  23867. /**
  23868. * Gets the actual number of layers of the texture.
  23869. * @returns the number of layers
  23870. */
  23871. getRenderLayers(): number;
  23872. /**
  23873. * Get if the texture can be rescaled or not.
  23874. */
  23875. get canRescale(): boolean;
  23876. /**
  23877. * Resize the texture using a ratio.
  23878. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23879. */
  23880. scale(ratio: number): void;
  23881. /**
  23882. * Get the texture reflection matrix used to rotate/transform the reflection.
  23883. * @returns the reflection matrix
  23884. */
  23885. getReflectionTextureMatrix(): Matrix;
  23886. /**
  23887. * Resize the texture to a new desired size.
  23888. * Be carrefull as it will recreate all the data in the new texture.
  23889. * @param size Define the new size. It can be:
  23890. * - a number for squared texture,
  23891. * - an object containing { width: number, height: number }
  23892. * - or an object containing a ratio { ratio: number }
  23893. */
  23894. resize(size: number | {
  23895. width: number;
  23896. height: number;
  23897. } | {
  23898. ratio: number;
  23899. }): void;
  23900. private _defaultRenderListPrepared;
  23901. /**
  23902. * Renders all the objects from the render list into the texture.
  23903. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23904. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23905. */
  23906. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23907. private _bestReflectionRenderTargetDimension;
  23908. private _prepareRenderingManager;
  23909. /**
  23910. * @hidden
  23911. * @param faceIndex face index to bind to if this is a cubetexture
  23912. * @param layer defines the index of the texture to bind in the array
  23913. */
  23914. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23915. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23916. private renderToTarget;
  23917. /**
  23918. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23919. * This allowed control for front to back rendering or reversly depending of the special needs.
  23920. *
  23921. * @param renderingGroupId The rendering group id corresponding to its index
  23922. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23923. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23924. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23925. */
  23926. 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;
  23927. /**
  23928. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23929. *
  23930. * @param renderingGroupId The rendering group id corresponding to its index
  23931. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23932. */
  23933. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23934. /**
  23935. * Clones the texture.
  23936. * @returns the cloned texture
  23937. */
  23938. clone(): RenderTargetTexture;
  23939. /**
  23940. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23941. * @returns The JSON representation of the texture
  23942. */
  23943. serialize(): any;
  23944. /**
  23945. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23946. */
  23947. disposeFramebufferObjects(): void;
  23948. /**
  23949. * Dispose the texture and release its associated resources.
  23950. */
  23951. dispose(): void;
  23952. /** @hidden */
  23953. _rebuild(): void;
  23954. /**
  23955. * Clear the info related to rendering groups preventing retention point in material dispose.
  23956. */
  23957. freeRenderingGroups(): void;
  23958. /**
  23959. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23960. * @returns the view count
  23961. */
  23962. getViewCount(): number;
  23963. }
  23964. }
  23965. declare module BABYLON {
  23966. /**
  23967. * Class used to manipulate GUIDs
  23968. */
  23969. export class GUID {
  23970. /**
  23971. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23972. * Be aware Math.random() could cause collisions, but:
  23973. * "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"
  23974. * @returns a pseudo random id
  23975. */
  23976. static RandomId(): string;
  23977. }
  23978. }
  23979. declare module BABYLON {
  23980. /**
  23981. * Options to be used when creating a shadow depth material
  23982. */
  23983. export interface IIOptionShadowDepthMaterial {
  23984. /** Variables in the vertex shader code that need to have their names remapped.
  23985. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23986. * "var_name" should be either: worldPos or vNormalW
  23987. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23988. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23989. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23990. */
  23991. remappedVariables?: string[];
  23992. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23993. standalone?: boolean;
  23994. }
  23995. /**
  23996. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23997. */
  23998. export class ShadowDepthWrapper {
  23999. private _scene;
  24000. private _options?;
  24001. private _baseMaterial;
  24002. private _onEffectCreatedObserver;
  24003. private _subMeshToEffect;
  24004. private _subMeshToDepthEffect;
  24005. private _meshes;
  24006. /** @hidden */
  24007. _matriceNames: any;
  24008. /** Gets the standalone status of the wrapper */
  24009. get standalone(): boolean;
  24010. /** Gets the base material the wrapper is built upon */
  24011. get baseMaterial(): Material;
  24012. /**
  24013. * Instantiate a new shadow depth wrapper.
  24014. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24015. * generate the shadow depth map. For more information, please refer to the documentation:
  24016. * https://doc.babylonjs.com/babylon101/shadows
  24017. * @param baseMaterial Material to wrap
  24018. * @param scene Define the scene the material belongs to
  24019. * @param options Options used to create the wrapper
  24020. */
  24021. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24022. /**
  24023. * Gets the effect to use to generate the depth map
  24024. * @param subMesh subMesh to get the effect for
  24025. * @param shadowGenerator shadow generator to get the effect for
  24026. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24027. */
  24028. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24029. /**
  24030. * Specifies that the submesh is ready to be used for depth rendering
  24031. * @param subMesh submesh to check
  24032. * @param defines the list of defines to take into account when checking the effect
  24033. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24034. * @param useInstances specifies that instances should be used
  24035. * @returns a boolean indicating that the submesh is ready or not
  24036. */
  24037. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24038. /**
  24039. * Disposes the resources
  24040. */
  24041. dispose(): void;
  24042. private _makeEffect;
  24043. }
  24044. }
  24045. declare module BABYLON {
  24046. interface ThinEngine {
  24047. /**
  24048. * Unbind a list of render target textures from the webGL context
  24049. * This is used only when drawBuffer extension or webGL2 are active
  24050. * @param textures defines the render target textures to unbind
  24051. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24052. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24053. */
  24054. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24055. /**
  24056. * Create a multi render target texture
  24057. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24058. * @param size defines the size of the texture
  24059. * @param options defines the creation options
  24060. * @returns the cube texture as an InternalTexture
  24061. */
  24062. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24063. /**
  24064. * Update the sample count for a given multiple render target texture
  24065. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24066. * @param textures defines the textures to update
  24067. * @param samples defines the sample count to set
  24068. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24069. */
  24070. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24071. /**
  24072. * Select a subsets of attachments to draw to.
  24073. * @param attachments gl attachments
  24074. */
  24075. bindAttachments(attachments: number[]): void;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. /**
  24080. * Creation options of the multi render target texture.
  24081. */
  24082. export interface IMultiRenderTargetOptions {
  24083. /**
  24084. * Define if the texture needs to create mip maps after render.
  24085. */
  24086. generateMipMaps?: boolean;
  24087. /**
  24088. * Define the types of all the draw buffers we want to create
  24089. */
  24090. types?: number[];
  24091. /**
  24092. * Define the sampling modes of all the draw buffers we want to create
  24093. */
  24094. samplingModes?: number[];
  24095. /**
  24096. * Define if a depth buffer is required
  24097. */
  24098. generateDepthBuffer?: boolean;
  24099. /**
  24100. * Define if a stencil buffer is required
  24101. */
  24102. generateStencilBuffer?: boolean;
  24103. /**
  24104. * Define if a depth texture is required instead of a depth buffer
  24105. */
  24106. generateDepthTexture?: boolean;
  24107. /**
  24108. * Define the number of desired draw buffers
  24109. */
  24110. textureCount?: number;
  24111. /**
  24112. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24113. */
  24114. doNotChangeAspectRatio?: boolean;
  24115. /**
  24116. * Define the default type of the buffers we are creating
  24117. */
  24118. defaultType?: number;
  24119. }
  24120. /**
  24121. * A multi render target, like a render target provides the ability to render to a texture.
  24122. * Unlike the render target, it can render to several draw buffers in one draw.
  24123. * This is specially interesting in deferred rendering or for any effects requiring more than
  24124. * just one color from a single pass.
  24125. */
  24126. export class MultiRenderTarget extends RenderTargetTexture {
  24127. private _internalTextures;
  24128. private _textures;
  24129. private _multiRenderTargetOptions;
  24130. private _count;
  24131. /**
  24132. * Get if draw buffers are currently supported by the used hardware and browser.
  24133. */
  24134. get isSupported(): boolean;
  24135. /**
  24136. * Get the list of textures generated by the multi render target.
  24137. */
  24138. get textures(): Texture[];
  24139. /**
  24140. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24141. */
  24142. get count(): number;
  24143. /**
  24144. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24145. */
  24146. get depthTexture(): Texture;
  24147. /**
  24148. * Set the wrapping mode on U of all the textures we are rendering to.
  24149. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24150. */
  24151. set wrapU(wrap: number);
  24152. /**
  24153. * Set the wrapping mode on V of all the textures we are rendering to.
  24154. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24155. */
  24156. set wrapV(wrap: number);
  24157. /**
  24158. * Instantiate a new multi render target texture.
  24159. * A multi render target, like a render target provides the ability to render to a texture.
  24160. * Unlike the render target, it can render to several draw buffers in one draw.
  24161. * This is specially interesting in deferred rendering or for any effects requiring more than
  24162. * just one color from a single pass.
  24163. * @param name Define the name of the texture
  24164. * @param size Define the size of the buffers to render to
  24165. * @param count Define the number of target we are rendering into
  24166. * @param scene Define the scene the texture belongs to
  24167. * @param options Define the options used to create the multi render target
  24168. */
  24169. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24170. /** @hidden */
  24171. _rebuild(): void;
  24172. private _createInternalTextures;
  24173. private _createTextures;
  24174. /**
  24175. * Define the number of samples used if MSAA is enabled.
  24176. */
  24177. get samples(): number;
  24178. set samples(value: number);
  24179. /**
  24180. * Resize all the textures in the multi render target.
  24181. * Be carrefull as it will recreate all the data in the new texture.
  24182. * @param size Define the new size
  24183. */
  24184. resize(size: any): void;
  24185. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24186. /**
  24187. * Dispose the render targets and their associated resources
  24188. */
  24189. dispose(): void;
  24190. /**
  24191. * Release all the underlying texture used as draw buffers.
  24192. */
  24193. releaseInternalTextures(): void;
  24194. }
  24195. }
  24196. declare module BABYLON {
  24197. /** @hidden */
  24198. export var imageProcessingPixelShader: {
  24199. name: string;
  24200. shader: string;
  24201. };
  24202. }
  24203. declare module BABYLON {
  24204. /**
  24205. * ImageProcessingPostProcess
  24206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24207. */
  24208. export class ImageProcessingPostProcess extends PostProcess {
  24209. /**
  24210. * Default configuration related to image processing available in the PBR Material.
  24211. */
  24212. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24213. /**
  24214. * Gets the image processing configuration used either in this material.
  24215. */
  24216. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24217. /**
  24218. * Sets the Default image processing configuration used either in the this material.
  24219. *
  24220. * If sets to null, the scene one is in use.
  24221. */
  24222. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24223. /**
  24224. * Keep track of the image processing observer to allow dispose and replace.
  24225. */
  24226. private _imageProcessingObserver;
  24227. /**
  24228. * Attaches a new image processing configuration to the PBR Material.
  24229. * @param configuration
  24230. */
  24231. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24232. /**
  24233. * If the post process is supported.
  24234. */
  24235. get isSupported(): boolean;
  24236. /**
  24237. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24238. */
  24239. get colorCurves(): Nullable<ColorCurves>;
  24240. /**
  24241. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24242. */
  24243. set colorCurves(value: Nullable<ColorCurves>);
  24244. /**
  24245. * Gets wether the color curves effect is enabled.
  24246. */
  24247. get colorCurvesEnabled(): boolean;
  24248. /**
  24249. * Sets wether the color curves effect is enabled.
  24250. */
  24251. set colorCurvesEnabled(value: boolean);
  24252. /**
  24253. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24254. */
  24255. get colorGradingTexture(): Nullable<BaseTexture>;
  24256. /**
  24257. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24258. */
  24259. set colorGradingTexture(value: Nullable<BaseTexture>);
  24260. /**
  24261. * Gets wether the color grading effect is enabled.
  24262. */
  24263. get colorGradingEnabled(): boolean;
  24264. /**
  24265. * Gets wether the color grading effect is enabled.
  24266. */
  24267. set colorGradingEnabled(value: boolean);
  24268. /**
  24269. * Gets exposure used in the effect.
  24270. */
  24271. get exposure(): number;
  24272. /**
  24273. * Sets exposure used in the effect.
  24274. */
  24275. set exposure(value: number);
  24276. /**
  24277. * Gets wether tonemapping is enabled or not.
  24278. */
  24279. get toneMappingEnabled(): boolean;
  24280. /**
  24281. * Sets wether tonemapping is enabled or not
  24282. */
  24283. set toneMappingEnabled(value: boolean);
  24284. /**
  24285. * Gets the type of tone mapping effect.
  24286. */
  24287. get toneMappingType(): number;
  24288. /**
  24289. * Sets the type of tone mapping effect.
  24290. */
  24291. set toneMappingType(value: number);
  24292. /**
  24293. * Gets contrast used in the effect.
  24294. */
  24295. get contrast(): number;
  24296. /**
  24297. * Sets contrast used in the effect.
  24298. */
  24299. set contrast(value: number);
  24300. /**
  24301. * Gets Vignette stretch size.
  24302. */
  24303. get vignetteStretch(): number;
  24304. /**
  24305. * Sets Vignette stretch size.
  24306. */
  24307. set vignetteStretch(value: number);
  24308. /**
  24309. * Gets Vignette centre X Offset.
  24310. */
  24311. get vignetteCentreX(): number;
  24312. /**
  24313. * Sets Vignette centre X Offset.
  24314. */
  24315. set vignetteCentreX(value: number);
  24316. /**
  24317. * Gets Vignette centre Y Offset.
  24318. */
  24319. get vignetteCentreY(): number;
  24320. /**
  24321. * Sets Vignette centre Y Offset.
  24322. */
  24323. set vignetteCentreY(value: number);
  24324. /**
  24325. * Gets Vignette weight or intensity of the vignette effect.
  24326. */
  24327. get vignetteWeight(): number;
  24328. /**
  24329. * Sets Vignette weight or intensity of the vignette effect.
  24330. */
  24331. set vignetteWeight(value: number);
  24332. /**
  24333. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24334. * if vignetteEnabled is set to true.
  24335. */
  24336. get vignetteColor(): Color4;
  24337. /**
  24338. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24339. * if vignetteEnabled is set to true.
  24340. */
  24341. set vignetteColor(value: Color4);
  24342. /**
  24343. * Gets Camera field of view used by the Vignette effect.
  24344. */
  24345. get vignetteCameraFov(): number;
  24346. /**
  24347. * Sets Camera field of view used by the Vignette effect.
  24348. */
  24349. set vignetteCameraFov(value: number);
  24350. /**
  24351. * Gets the vignette blend mode allowing different kind of effect.
  24352. */
  24353. get vignetteBlendMode(): number;
  24354. /**
  24355. * Sets the vignette blend mode allowing different kind of effect.
  24356. */
  24357. set vignetteBlendMode(value: number);
  24358. /**
  24359. * Gets wether the vignette effect is enabled.
  24360. */
  24361. get vignetteEnabled(): boolean;
  24362. /**
  24363. * Sets wether the vignette effect is enabled.
  24364. */
  24365. set vignetteEnabled(value: boolean);
  24366. private _fromLinearSpace;
  24367. /**
  24368. * Gets wether the input of the processing is in Gamma or Linear Space.
  24369. */
  24370. get fromLinearSpace(): boolean;
  24371. /**
  24372. * Sets wether the input of the processing is in Gamma or Linear Space.
  24373. */
  24374. set fromLinearSpace(value: boolean);
  24375. /**
  24376. * Defines cache preventing GC.
  24377. */
  24378. private _defines;
  24379. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24380. /**
  24381. * "ImageProcessingPostProcess"
  24382. * @returns "ImageProcessingPostProcess"
  24383. */
  24384. getClassName(): string;
  24385. /**
  24386. * @hidden
  24387. */
  24388. _updateParameters(): void;
  24389. dispose(camera?: Camera): void;
  24390. }
  24391. }
  24392. declare module BABYLON {
  24393. /** @hidden */
  24394. export var fibonacci: {
  24395. name: string;
  24396. shader: string;
  24397. };
  24398. }
  24399. declare module BABYLON {
  24400. /** @hidden */
  24401. export var subSurfaceScatteringFunctions: {
  24402. name: string;
  24403. shader: string;
  24404. };
  24405. }
  24406. declare module BABYLON {
  24407. /** @hidden */
  24408. export var diffusionProfile: {
  24409. name: string;
  24410. shader: string;
  24411. };
  24412. }
  24413. declare module BABYLON {
  24414. /** @hidden */
  24415. export var subSurfaceScatteringPixelShader: {
  24416. name: string;
  24417. shader: string;
  24418. };
  24419. }
  24420. declare module BABYLON {
  24421. /**
  24422. * Sub surface scattering post process
  24423. */
  24424. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24425. /**
  24426. * Gets a string identifying the name of the class
  24427. * @returns "SubSurfaceScatteringPostProcess" string
  24428. */
  24429. getClassName(): string;
  24430. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24431. }
  24432. }
  24433. declare module BABYLON {
  24434. /**
  24435. * Interface for defining prepass effects in the prepass post-process pipeline
  24436. */
  24437. export interface PrePassEffectConfiguration {
  24438. /**
  24439. * Post process to attach for this effect
  24440. */
  24441. postProcess: PostProcess;
  24442. /**
  24443. * Is the effect enabled
  24444. */
  24445. enabled: boolean;
  24446. /**
  24447. * Disposes the effect configuration
  24448. */
  24449. dispose(): void;
  24450. /**
  24451. * Disposes the effect configuration
  24452. */
  24453. createPostProcess: () => PostProcess;
  24454. }
  24455. }
  24456. declare module BABYLON {
  24457. /**
  24458. * Contains all parameters needed for the prepass to perform
  24459. * screen space subsurface scattering
  24460. */
  24461. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24462. private _ssDiffusionS;
  24463. private _ssFilterRadii;
  24464. private _ssDiffusionD;
  24465. /**
  24466. * Post process to attach for screen space subsurface scattering
  24467. */
  24468. postProcess: SubSurfaceScatteringPostProcess;
  24469. /**
  24470. * Diffusion profile color for subsurface scattering
  24471. */
  24472. get ssDiffusionS(): number[];
  24473. /**
  24474. * Diffusion profile max color channel value for subsurface scattering
  24475. */
  24476. get ssDiffusionD(): number[];
  24477. /**
  24478. * Diffusion profile filter radius for subsurface scattering
  24479. */
  24480. get ssFilterRadii(): number[];
  24481. /**
  24482. * Is subsurface enabled
  24483. */
  24484. enabled: boolean;
  24485. /**
  24486. * Diffusion profile colors for subsurface scattering
  24487. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24488. * See ...
  24489. * Note that you can only store up to 5 of them
  24490. */
  24491. ssDiffusionProfileColors: Color3[];
  24492. /**
  24493. * Defines the ratio real world => scene units.
  24494. * Used for subsurface scattering
  24495. */
  24496. metersPerUnit: number;
  24497. private _scene;
  24498. /**
  24499. * Builds a subsurface configuration object
  24500. * @param scene The scene
  24501. */
  24502. constructor(scene: Scene);
  24503. /**
  24504. * Adds a new diffusion profile.
  24505. * Useful for more realistic subsurface scattering on diverse materials.
  24506. * @param color The color of the diffusion profile. Should be the average color of the material.
  24507. * @return The index of the diffusion profile for the material subsurface configuration
  24508. */
  24509. addDiffusionProfile(color: Color3): number;
  24510. /**
  24511. * Creates the sss post process
  24512. * @return The created post process
  24513. */
  24514. createPostProcess(): SubSurfaceScatteringPostProcess;
  24515. /**
  24516. * Deletes all diffusion profiles.
  24517. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24518. */
  24519. clearAllDiffusionProfiles(): void;
  24520. /**
  24521. * Disposes this object
  24522. */
  24523. dispose(): void;
  24524. /**
  24525. * @hidden
  24526. * https://zero-radiance.github.io/post/sampling-diffusion/
  24527. *
  24528. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24529. * ------------------------------------------------------------------------------------
  24530. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24531. * PDF[r, phi, s] = r * R[r, phi, s]
  24532. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24533. * ------------------------------------------------------------------------------------
  24534. * We importance sample the color channel with the widest scattering distance.
  24535. */
  24536. getDiffusionProfileParameters(color: Color3): number;
  24537. /**
  24538. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24539. * 'u' is the random number (the value of the CDF): [0, 1).
  24540. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24541. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24542. */
  24543. private _sampleBurleyDiffusionProfile;
  24544. }
  24545. }
  24546. declare module BABYLON {
  24547. /**
  24548. * Renders a pre pass of the scene
  24549. * This means every mesh in the scene will be rendered to a render target texture
  24550. * And then this texture will be composited to the rendering canvas with post processes
  24551. * It is necessary for effects like subsurface scattering or deferred shading
  24552. */
  24553. export class PrePassRenderer {
  24554. /** @hidden */
  24555. static _SceneComponentInitialization: (scene: Scene) => void;
  24556. private _scene;
  24557. private _engine;
  24558. private _isDirty;
  24559. /**
  24560. * Number of textures in the multi render target texture where the scene is directly rendered
  24561. */
  24562. readonly mrtCount: number;
  24563. /**
  24564. * The render target where the scene is directly rendered
  24565. */
  24566. prePassRT: MultiRenderTarget;
  24567. private _mrtTypes;
  24568. private _multiRenderAttachments;
  24569. private _defaultAttachments;
  24570. private _clearAttachments;
  24571. private _postProcesses;
  24572. private readonly _clearColor;
  24573. /**
  24574. * Image processing post process for composition
  24575. */
  24576. imageProcessingPostProcess: ImageProcessingPostProcess;
  24577. /**
  24578. * Configuration for sub surface scattering post process
  24579. */
  24580. subSurfaceConfiguration: SubSurfaceConfiguration;
  24581. /**
  24582. * Should materials render their geometry on the MRT
  24583. */
  24584. materialsShouldRenderGeometry: boolean;
  24585. /**
  24586. * Should materials render the irradiance information on the MRT
  24587. */
  24588. materialsShouldRenderIrradiance: boolean;
  24589. private _enabled;
  24590. /**
  24591. * Indicates if the prepass is enabled
  24592. */
  24593. get enabled(): boolean;
  24594. /**
  24595. * How many samples are used for MSAA of the scene render target
  24596. */
  24597. get samples(): number;
  24598. set samples(n: number);
  24599. /**
  24600. * Instanciates a prepass renderer
  24601. * @param scene The scene
  24602. */
  24603. constructor(scene: Scene);
  24604. private _initializeAttachments;
  24605. private _createCompositionEffect;
  24606. /**
  24607. * Indicates if rendering a prepass is supported
  24608. */
  24609. get isSupported(): boolean;
  24610. /**
  24611. * Sets the proper output textures to draw in the engine.
  24612. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24613. */
  24614. bindAttachmentsForEffect(effect: Effect): void;
  24615. /**
  24616. * @hidden
  24617. */
  24618. _beforeCameraDraw(): void;
  24619. /**
  24620. * @hidden
  24621. */
  24622. _afterCameraDraw(): void;
  24623. private _checkRTSize;
  24624. private _bindFrameBuffer;
  24625. /**
  24626. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24627. */
  24628. clear(): void;
  24629. private _setState;
  24630. private _enable;
  24631. private _disable;
  24632. private _resetPostProcessChain;
  24633. private _bindPostProcessChain;
  24634. /**
  24635. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24636. */
  24637. markAsDirty(): void;
  24638. private _update;
  24639. /**
  24640. * Disposes the prepass renderer.
  24641. */
  24642. dispose(): void;
  24643. }
  24644. }
  24645. declare module BABYLON {
  24646. /**
  24647. * Options for compiling materials.
  24648. */
  24649. export interface IMaterialCompilationOptions {
  24650. /**
  24651. * Defines whether clip planes are enabled.
  24652. */
  24653. clipPlane: boolean;
  24654. /**
  24655. * Defines whether instances are enabled.
  24656. */
  24657. useInstances: boolean;
  24658. }
  24659. /**
  24660. * Options passed when calling customShaderNameResolve
  24661. */
  24662. export interface ICustomShaderNameResolveOptions {
  24663. /**
  24664. * 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
  24665. */
  24666. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24667. }
  24668. /**
  24669. * Base class for the main features of a material in Babylon.js
  24670. */
  24671. export class Material implements IAnimatable {
  24672. /**
  24673. * Returns the triangle fill mode
  24674. */
  24675. static readonly TriangleFillMode: number;
  24676. /**
  24677. * Returns the wireframe mode
  24678. */
  24679. static readonly WireFrameFillMode: number;
  24680. /**
  24681. * Returns the point fill mode
  24682. */
  24683. static readonly PointFillMode: number;
  24684. /**
  24685. * Returns the point list draw mode
  24686. */
  24687. static readonly PointListDrawMode: number;
  24688. /**
  24689. * Returns the line list draw mode
  24690. */
  24691. static readonly LineListDrawMode: number;
  24692. /**
  24693. * Returns the line loop draw mode
  24694. */
  24695. static readonly LineLoopDrawMode: number;
  24696. /**
  24697. * Returns the line strip draw mode
  24698. */
  24699. static readonly LineStripDrawMode: number;
  24700. /**
  24701. * Returns the triangle strip draw mode
  24702. */
  24703. static readonly TriangleStripDrawMode: number;
  24704. /**
  24705. * Returns the triangle fan draw mode
  24706. */
  24707. static readonly TriangleFanDrawMode: number;
  24708. /**
  24709. * Stores the clock-wise side orientation
  24710. */
  24711. static readonly ClockWiseSideOrientation: number;
  24712. /**
  24713. * Stores the counter clock-wise side orientation
  24714. */
  24715. static readonly CounterClockWiseSideOrientation: number;
  24716. /**
  24717. * The dirty texture flag value
  24718. */
  24719. static readonly TextureDirtyFlag: number;
  24720. /**
  24721. * The dirty light flag value
  24722. */
  24723. static readonly LightDirtyFlag: number;
  24724. /**
  24725. * The dirty fresnel flag value
  24726. */
  24727. static readonly FresnelDirtyFlag: number;
  24728. /**
  24729. * The dirty attribute flag value
  24730. */
  24731. static readonly AttributesDirtyFlag: number;
  24732. /**
  24733. * The dirty misc flag value
  24734. */
  24735. static readonly MiscDirtyFlag: number;
  24736. /**
  24737. * The all dirty flag value
  24738. */
  24739. static readonly AllDirtyFlag: number;
  24740. /**
  24741. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24742. */
  24743. static readonly MATERIAL_OPAQUE: number;
  24744. /**
  24745. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24746. */
  24747. static readonly MATERIAL_ALPHATEST: number;
  24748. /**
  24749. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24750. */
  24751. static readonly MATERIAL_ALPHABLEND: number;
  24752. /**
  24753. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24754. * They are also discarded below the alpha cutoff threshold to improve performances.
  24755. */
  24756. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24757. /**
  24758. * The Whiteout method is used to blend normals.
  24759. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24760. */
  24761. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24762. /**
  24763. * The Reoriented Normal Mapping method is used to blend normals.
  24764. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24765. */
  24766. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24767. /**
  24768. * Custom callback helping to override the default shader used in the material.
  24769. */
  24770. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24771. /**
  24772. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24773. */
  24774. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24775. /**
  24776. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24777. * This means that the material can keep using a previous shader while a new one is being compiled.
  24778. * This is mostly used when shader parallel compilation is supported (true by default)
  24779. */
  24780. allowShaderHotSwapping: boolean;
  24781. /**
  24782. * The ID of the material
  24783. */
  24784. id: string;
  24785. /**
  24786. * Gets or sets the unique id of the material
  24787. */
  24788. uniqueId: number;
  24789. /**
  24790. * The name of the material
  24791. */
  24792. name: string;
  24793. /**
  24794. * Gets or sets user defined metadata
  24795. */
  24796. metadata: any;
  24797. /**
  24798. * For internal use only. Please do not use.
  24799. */
  24800. reservedDataStore: any;
  24801. /**
  24802. * Specifies if the ready state should be checked on each call
  24803. */
  24804. checkReadyOnEveryCall: boolean;
  24805. /**
  24806. * Specifies if the ready state should be checked once
  24807. */
  24808. checkReadyOnlyOnce: boolean;
  24809. /**
  24810. * The state of the material
  24811. */
  24812. state: string;
  24813. /**
  24814. * If the material can be rendered to several textures with MRT extension
  24815. */
  24816. get canRenderToMRT(): boolean;
  24817. /**
  24818. * The alpha value of the material
  24819. */
  24820. protected _alpha: number;
  24821. /**
  24822. * List of inspectable custom properties (used by the Inspector)
  24823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24824. */
  24825. inspectableCustomProperties: IInspectable[];
  24826. /**
  24827. * Sets the alpha value of the material
  24828. */
  24829. set alpha(value: number);
  24830. /**
  24831. * Gets the alpha value of the material
  24832. */
  24833. get alpha(): number;
  24834. /**
  24835. * Specifies if back face culling is enabled
  24836. */
  24837. protected _backFaceCulling: boolean;
  24838. /**
  24839. * Sets the back-face culling state
  24840. */
  24841. set backFaceCulling(value: boolean);
  24842. /**
  24843. * Gets the back-face culling state
  24844. */
  24845. get backFaceCulling(): boolean;
  24846. /**
  24847. * Stores the value for side orientation
  24848. */
  24849. sideOrientation: number;
  24850. /**
  24851. * Callback triggered when the material is compiled
  24852. */
  24853. onCompiled: Nullable<(effect: Effect) => void>;
  24854. /**
  24855. * Callback triggered when an error occurs
  24856. */
  24857. onError: Nullable<(effect: Effect, errors: string) => void>;
  24858. /**
  24859. * Callback triggered to get the render target textures
  24860. */
  24861. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24862. /**
  24863. * Gets a boolean indicating that current material needs to register RTT
  24864. */
  24865. get hasRenderTargetTextures(): boolean;
  24866. /**
  24867. * Specifies if the material should be serialized
  24868. */
  24869. doNotSerialize: boolean;
  24870. /**
  24871. * @hidden
  24872. */
  24873. _storeEffectOnSubMeshes: boolean;
  24874. /**
  24875. * Stores the animations for the material
  24876. */
  24877. animations: Nullable<Array<Animation>>;
  24878. /**
  24879. * An event triggered when the material is disposed
  24880. */
  24881. onDisposeObservable: Observable<Material>;
  24882. /**
  24883. * An observer which watches for dispose events
  24884. */
  24885. private _onDisposeObserver;
  24886. private _onUnBindObservable;
  24887. /**
  24888. * Called during a dispose event
  24889. */
  24890. set onDispose(callback: () => void);
  24891. private _onBindObservable;
  24892. /**
  24893. * An event triggered when the material is bound
  24894. */
  24895. get onBindObservable(): Observable<AbstractMesh>;
  24896. /**
  24897. * An observer which watches for bind events
  24898. */
  24899. private _onBindObserver;
  24900. /**
  24901. * Called during a bind event
  24902. */
  24903. set onBind(callback: (Mesh: AbstractMesh) => void);
  24904. /**
  24905. * An event triggered when the material is unbound
  24906. */
  24907. get onUnBindObservable(): Observable<Material>;
  24908. protected _onEffectCreatedObservable: Nullable<Observable<{
  24909. effect: Effect;
  24910. subMesh: Nullable<SubMesh>;
  24911. }>>;
  24912. /**
  24913. * An event triggered when the effect is (re)created
  24914. */
  24915. get onEffectCreatedObservable(): Observable<{
  24916. effect: Effect;
  24917. subMesh: Nullable<SubMesh>;
  24918. }>;
  24919. /**
  24920. * Stores the value of the alpha mode
  24921. */
  24922. private _alphaMode;
  24923. /**
  24924. * Sets the value of the alpha mode.
  24925. *
  24926. * | Value | Type | Description |
  24927. * | --- | --- | --- |
  24928. * | 0 | ALPHA_DISABLE | |
  24929. * | 1 | ALPHA_ADD | |
  24930. * | 2 | ALPHA_COMBINE | |
  24931. * | 3 | ALPHA_SUBTRACT | |
  24932. * | 4 | ALPHA_MULTIPLY | |
  24933. * | 5 | ALPHA_MAXIMIZED | |
  24934. * | 6 | ALPHA_ONEONE | |
  24935. * | 7 | ALPHA_PREMULTIPLIED | |
  24936. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24937. * | 9 | ALPHA_INTERPOLATE | |
  24938. * | 10 | ALPHA_SCREENMODE | |
  24939. *
  24940. */
  24941. set alphaMode(value: number);
  24942. /**
  24943. * Gets the value of the alpha mode
  24944. */
  24945. get alphaMode(): number;
  24946. /**
  24947. * Stores the state of the need depth pre-pass value
  24948. */
  24949. private _needDepthPrePass;
  24950. /**
  24951. * Sets the need depth pre-pass value
  24952. */
  24953. set needDepthPrePass(value: boolean);
  24954. /**
  24955. * Gets the depth pre-pass value
  24956. */
  24957. get needDepthPrePass(): boolean;
  24958. /**
  24959. * Specifies if depth writing should be disabled
  24960. */
  24961. disableDepthWrite: boolean;
  24962. /**
  24963. * Specifies if color writing should be disabled
  24964. */
  24965. disableColorWrite: boolean;
  24966. /**
  24967. * Specifies if depth writing should be forced
  24968. */
  24969. forceDepthWrite: boolean;
  24970. /**
  24971. * Specifies the depth function that should be used. 0 means the default engine function
  24972. */
  24973. depthFunction: number;
  24974. /**
  24975. * Specifies if there should be a separate pass for culling
  24976. */
  24977. separateCullingPass: boolean;
  24978. /**
  24979. * Stores the state specifing if fog should be enabled
  24980. */
  24981. private _fogEnabled;
  24982. /**
  24983. * Sets the state for enabling fog
  24984. */
  24985. set fogEnabled(value: boolean);
  24986. /**
  24987. * Gets the value of the fog enabled state
  24988. */
  24989. get fogEnabled(): boolean;
  24990. /**
  24991. * Stores the size of points
  24992. */
  24993. pointSize: number;
  24994. /**
  24995. * Stores the z offset value
  24996. */
  24997. zOffset: number;
  24998. get wireframe(): boolean;
  24999. /**
  25000. * Sets the state of wireframe mode
  25001. */
  25002. set wireframe(value: boolean);
  25003. /**
  25004. * Gets the value specifying if point clouds are enabled
  25005. */
  25006. get pointsCloud(): boolean;
  25007. /**
  25008. * Sets the state of point cloud mode
  25009. */
  25010. set pointsCloud(value: boolean);
  25011. /**
  25012. * Gets the material fill mode
  25013. */
  25014. get fillMode(): number;
  25015. /**
  25016. * Sets the material fill mode
  25017. */
  25018. set fillMode(value: number);
  25019. /**
  25020. * @hidden
  25021. * Stores the effects for the material
  25022. */
  25023. _effect: Nullable<Effect>;
  25024. /**
  25025. * Specifies if uniform buffers should be used
  25026. */
  25027. private _useUBO;
  25028. /**
  25029. * Stores a reference to the scene
  25030. */
  25031. private _scene;
  25032. /**
  25033. * Stores the fill mode state
  25034. */
  25035. private _fillMode;
  25036. /**
  25037. * Specifies if the depth write state should be cached
  25038. */
  25039. private _cachedDepthWriteState;
  25040. /**
  25041. * Specifies if the color write state should be cached
  25042. */
  25043. private _cachedColorWriteState;
  25044. /**
  25045. * Specifies if the depth function state should be cached
  25046. */
  25047. private _cachedDepthFunctionState;
  25048. /**
  25049. * Stores the uniform buffer
  25050. */
  25051. protected _uniformBuffer: UniformBuffer;
  25052. /** @hidden */
  25053. _indexInSceneMaterialArray: number;
  25054. /** @hidden */
  25055. meshMap: Nullable<{
  25056. [id: string]: AbstractMesh | undefined;
  25057. }>;
  25058. /**
  25059. * Creates a material instance
  25060. * @param name defines the name of the material
  25061. * @param scene defines the scene to reference
  25062. * @param doNotAdd specifies if the material should be added to the scene
  25063. */
  25064. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25065. /**
  25066. * Returns a string representation of the current material
  25067. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25068. * @returns a string with material information
  25069. */
  25070. toString(fullDetails?: boolean): string;
  25071. /**
  25072. * Gets the class name of the material
  25073. * @returns a string with the class name of the material
  25074. */
  25075. getClassName(): string;
  25076. /**
  25077. * Specifies if updates for the material been locked
  25078. */
  25079. get isFrozen(): boolean;
  25080. /**
  25081. * Locks updates for the material
  25082. */
  25083. freeze(): void;
  25084. /**
  25085. * Unlocks updates for the material
  25086. */
  25087. unfreeze(): void;
  25088. /**
  25089. * Specifies if the material is ready to be used
  25090. * @param mesh defines the mesh to check
  25091. * @param useInstances specifies if instances should be used
  25092. * @returns a boolean indicating if the material is ready to be used
  25093. */
  25094. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25095. /**
  25096. * Specifies that the submesh is ready to be used
  25097. * @param mesh defines the mesh to check
  25098. * @param subMesh defines which submesh to check
  25099. * @param useInstances specifies that instances should be used
  25100. * @returns a boolean indicating that the submesh is ready or not
  25101. */
  25102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25103. /**
  25104. * Returns the material effect
  25105. * @returns the effect associated with the material
  25106. */
  25107. getEffect(): Nullable<Effect>;
  25108. /**
  25109. * Returns the current scene
  25110. * @returns a Scene
  25111. */
  25112. getScene(): Scene;
  25113. /**
  25114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25115. */
  25116. protected _forceAlphaTest: boolean;
  25117. /**
  25118. * The transparency mode of the material.
  25119. */
  25120. protected _transparencyMode: Nullable<number>;
  25121. /**
  25122. * Gets the current transparency mode.
  25123. */
  25124. get transparencyMode(): Nullable<number>;
  25125. /**
  25126. * Sets the transparency mode of the material.
  25127. *
  25128. * | Value | Type | Description |
  25129. * | ----- | ----------------------------------- | ----------- |
  25130. * | 0 | OPAQUE | |
  25131. * | 1 | ALPHATEST | |
  25132. * | 2 | ALPHABLEND | |
  25133. * | 3 | ALPHATESTANDBLEND | |
  25134. *
  25135. */
  25136. set transparencyMode(value: Nullable<number>);
  25137. /**
  25138. * Returns true if alpha blending should be disabled.
  25139. */
  25140. protected get _disableAlphaBlending(): boolean;
  25141. /**
  25142. * Specifies whether or not this material should be rendered in alpha blend mode.
  25143. * @returns a boolean specifying if alpha blending is needed
  25144. */
  25145. needAlphaBlending(): boolean;
  25146. /**
  25147. * Specifies if the mesh will require alpha blending
  25148. * @param mesh defines the mesh to check
  25149. * @returns a boolean specifying if alpha blending is needed for the mesh
  25150. */
  25151. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25152. /**
  25153. * Specifies whether or not this material should be rendered in alpha test mode.
  25154. * @returns a boolean specifying if an alpha test is needed.
  25155. */
  25156. needAlphaTesting(): boolean;
  25157. /**
  25158. * Specifies if material alpha testing should be turned on for the mesh
  25159. * @param mesh defines the mesh to check
  25160. */
  25161. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25162. /**
  25163. * Gets the texture used for the alpha test
  25164. * @returns the texture to use for alpha testing
  25165. */
  25166. getAlphaTestTexture(): Nullable<BaseTexture>;
  25167. /**
  25168. * Marks the material to indicate that it needs to be re-calculated
  25169. */
  25170. markDirty(): void;
  25171. /** @hidden */
  25172. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25173. /**
  25174. * Binds the material to the mesh
  25175. * @param world defines the world transformation matrix
  25176. * @param mesh defines the mesh to bind the material to
  25177. */
  25178. bind(world: Matrix, mesh?: Mesh): void;
  25179. /**
  25180. * Binds the submesh to the material
  25181. * @param world defines the world transformation matrix
  25182. * @param mesh defines the mesh containing the submesh
  25183. * @param subMesh defines the submesh to bind the material to
  25184. */
  25185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25186. /**
  25187. * Binds the world matrix to the material
  25188. * @param world defines the world transformation matrix
  25189. */
  25190. bindOnlyWorldMatrix(world: Matrix): void;
  25191. /**
  25192. * Binds the scene's uniform buffer to the effect.
  25193. * @param effect defines the effect to bind to the scene uniform buffer
  25194. * @param sceneUbo defines the uniform buffer storing scene data
  25195. */
  25196. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25197. /**
  25198. * Binds the view matrix to the effect
  25199. * @param effect defines the effect to bind the view matrix to
  25200. */
  25201. bindView(effect: Effect): void;
  25202. /**
  25203. * Binds the view projection matrix to the effect
  25204. * @param effect defines the effect to bind the view projection matrix to
  25205. */
  25206. bindViewProjection(effect: Effect): void;
  25207. /**
  25208. * Processes to execute after binding the material to a mesh
  25209. * @param mesh defines the rendered mesh
  25210. */
  25211. protected _afterBind(mesh?: Mesh): void;
  25212. /**
  25213. * Unbinds the material from the mesh
  25214. */
  25215. unbind(): void;
  25216. /**
  25217. * Gets the active textures from the material
  25218. * @returns an array of textures
  25219. */
  25220. getActiveTextures(): BaseTexture[];
  25221. /**
  25222. * Specifies if the material uses a texture
  25223. * @param texture defines the texture to check against the material
  25224. * @returns a boolean specifying if the material uses the texture
  25225. */
  25226. hasTexture(texture: BaseTexture): boolean;
  25227. /**
  25228. * Makes a duplicate of the material, and gives it a new name
  25229. * @param name defines the new name for the duplicated material
  25230. * @returns the cloned material
  25231. */
  25232. clone(name: string): Nullable<Material>;
  25233. /**
  25234. * Gets the meshes bound to the material
  25235. * @returns an array of meshes bound to the material
  25236. */
  25237. getBindedMeshes(): AbstractMesh[];
  25238. /**
  25239. * Force shader compilation
  25240. * @param mesh defines the mesh associated with this material
  25241. * @param onCompiled defines a function to execute once the material is compiled
  25242. * @param options defines the options to configure the compilation
  25243. * @param onError defines a function to execute if the material fails compiling
  25244. */
  25245. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25246. /**
  25247. * Force shader compilation
  25248. * @param mesh defines the mesh that will use this material
  25249. * @param options defines additional options for compiling the shaders
  25250. * @returns a promise that resolves when the compilation completes
  25251. */
  25252. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25253. private static readonly _AllDirtyCallBack;
  25254. private static readonly _ImageProcessingDirtyCallBack;
  25255. private static readonly _TextureDirtyCallBack;
  25256. private static readonly _FresnelDirtyCallBack;
  25257. private static readonly _MiscDirtyCallBack;
  25258. private static readonly _LightsDirtyCallBack;
  25259. private static readonly _AttributeDirtyCallBack;
  25260. private static _FresnelAndMiscDirtyCallBack;
  25261. private static _TextureAndMiscDirtyCallBack;
  25262. private static readonly _DirtyCallbackArray;
  25263. private static readonly _RunDirtyCallBacks;
  25264. /**
  25265. * Marks a define in the material to indicate that it needs to be re-computed
  25266. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25267. */
  25268. markAsDirty(flag: number): void;
  25269. /**
  25270. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25271. * @param func defines a function which checks material defines against the submeshes
  25272. */
  25273. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25274. /**
  25275. * Indicates that the scene should check if the rendering now needs a prepass
  25276. */
  25277. protected _markScenePrePassDirty(): void;
  25278. /**
  25279. * Indicates that we need to re-calculated for all submeshes
  25280. */
  25281. protected _markAllSubMeshesAsAllDirty(): void;
  25282. /**
  25283. * Indicates that image processing needs to be re-calculated for all submeshes
  25284. */
  25285. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25286. /**
  25287. * Indicates that textures need to be re-calculated for all submeshes
  25288. */
  25289. protected _markAllSubMeshesAsTexturesDirty(): void;
  25290. /**
  25291. * Indicates that fresnel needs to be re-calculated for all submeshes
  25292. */
  25293. protected _markAllSubMeshesAsFresnelDirty(): void;
  25294. /**
  25295. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25296. */
  25297. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25298. /**
  25299. * Indicates that lights need to be re-calculated for all submeshes
  25300. */
  25301. protected _markAllSubMeshesAsLightsDirty(): void;
  25302. /**
  25303. * Indicates that attributes need to be re-calculated for all submeshes
  25304. */
  25305. protected _markAllSubMeshesAsAttributesDirty(): void;
  25306. /**
  25307. * Indicates that misc needs to be re-calculated for all submeshes
  25308. */
  25309. protected _markAllSubMeshesAsMiscDirty(): void;
  25310. /**
  25311. * Indicates that textures and misc need to be re-calculated for all submeshes
  25312. */
  25313. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25314. /**
  25315. * Sets the required values to the prepass renderer.
  25316. * @param prePassRenderer defines the prepass renderer to setup.
  25317. * @returns true if the pre pass is needed.
  25318. */
  25319. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25320. /**
  25321. * Disposes the material
  25322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25324. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25325. */
  25326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25327. /** @hidden */
  25328. private releaseVertexArrayObject;
  25329. /**
  25330. * Serializes this material
  25331. * @returns the serialized material object
  25332. */
  25333. serialize(): any;
  25334. /**
  25335. * Creates a material from parsed material data
  25336. * @param parsedMaterial defines parsed material data
  25337. * @param scene defines the hosting scene
  25338. * @param rootUrl defines the root URL to use to load textures
  25339. * @returns a new material
  25340. */
  25341. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25342. }
  25343. }
  25344. declare module BABYLON {
  25345. /**
  25346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25347. * separate meshes. This can be use to improve performances.
  25348. * @see https://doc.babylonjs.com/how_to/multi_materials
  25349. */
  25350. export class MultiMaterial extends Material {
  25351. private _subMaterials;
  25352. /**
  25353. * Gets or Sets the list of Materials used within the multi material.
  25354. * They need to be ordered according to the submeshes order in the associated mesh
  25355. */
  25356. get subMaterials(): Nullable<Material>[];
  25357. set subMaterials(value: Nullable<Material>[]);
  25358. /**
  25359. * Function used to align with Node.getChildren()
  25360. * @returns the list of Materials used within the multi material
  25361. */
  25362. getChildren(): Nullable<Material>[];
  25363. /**
  25364. * Instantiates a new Multi Material
  25365. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25366. * separate meshes. This can be use to improve performances.
  25367. * @see https://doc.babylonjs.com/how_to/multi_materials
  25368. * @param name Define the name in the scene
  25369. * @param scene Define the scene the material belongs to
  25370. */
  25371. constructor(name: string, scene: Scene);
  25372. private _hookArray;
  25373. /**
  25374. * Get one of the submaterial by its index in the submaterials array
  25375. * @param index The index to look the sub material at
  25376. * @returns The Material if the index has been defined
  25377. */
  25378. getSubMaterial(index: number): Nullable<Material>;
  25379. /**
  25380. * Get the list of active textures for the whole sub materials list.
  25381. * @returns All the textures that will be used during the rendering
  25382. */
  25383. getActiveTextures(): BaseTexture[];
  25384. /**
  25385. * Gets the current class name of the material e.g. "MultiMaterial"
  25386. * Mainly use in serialization.
  25387. * @returns the class name
  25388. */
  25389. getClassName(): string;
  25390. /**
  25391. * Checks if the material is ready to render the requested sub mesh
  25392. * @param mesh Define the mesh the submesh belongs to
  25393. * @param subMesh Define the sub mesh to look readyness for
  25394. * @param useInstances Define whether or not the material is used with instances
  25395. * @returns true if ready, otherwise false
  25396. */
  25397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25398. /**
  25399. * Clones the current material and its related sub materials
  25400. * @param name Define the name of the newly cloned material
  25401. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25402. * @returns the cloned material
  25403. */
  25404. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25405. /**
  25406. * Serializes the materials into a JSON representation.
  25407. * @returns the JSON representation
  25408. */
  25409. serialize(): any;
  25410. /**
  25411. * Dispose the material and release its associated resources
  25412. * @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)
  25413. * @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)
  25414. * @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)
  25415. */
  25416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25417. /**
  25418. * Creates a MultiMaterial from parsed MultiMaterial data.
  25419. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25420. * @param scene defines the hosting scene
  25421. * @returns a new MultiMaterial
  25422. */
  25423. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25424. }
  25425. }
  25426. declare module BABYLON {
  25427. /**
  25428. * Defines a subdivision inside a mesh
  25429. */
  25430. export class SubMesh implements ICullable {
  25431. /** the material index to use */
  25432. materialIndex: number;
  25433. /** vertex index start */
  25434. verticesStart: number;
  25435. /** vertices count */
  25436. verticesCount: number;
  25437. /** index start */
  25438. indexStart: number;
  25439. /** indices count */
  25440. indexCount: number;
  25441. /** @hidden */
  25442. _materialDefines: Nullable<MaterialDefines>;
  25443. /** @hidden */
  25444. _materialEffect: Nullable<Effect>;
  25445. /** @hidden */
  25446. _effectOverride: Nullable<Effect>;
  25447. /**
  25448. * Gets material defines used by the effect associated to the sub mesh
  25449. */
  25450. get materialDefines(): Nullable<MaterialDefines>;
  25451. /**
  25452. * Sets material defines used by the effect associated to the sub mesh
  25453. */
  25454. set materialDefines(defines: Nullable<MaterialDefines>);
  25455. /**
  25456. * Gets associated effect
  25457. */
  25458. get effect(): Nullable<Effect>;
  25459. /**
  25460. * Sets associated effect (effect used to render this submesh)
  25461. * @param effect defines the effect to associate with
  25462. * @param defines defines the set of defines used to compile this effect
  25463. */
  25464. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25465. /** @hidden */
  25466. _linesIndexCount: number;
  25467. private _mesh;
  25468. private _renderingMesh;
  25469. private _boundingInfo;
  25470. private _linesIndexBuffer;
  25471. /** @hidden */
  25472. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25473. /** @hidden */
  25474. _trianglePlanes: Plane[];
  25475. /** @hidden */
  25476. _lastColliderTransformMatrix: Nullable<Matrix>;
  25477. /** @hidden */
  25478. _renderId: number;
  25479. /** @hidden */
  25480. _alphaIndex: number;
  25481. /** @hidden */
  25482. _distanceToCamera: number;
  25483. /** @hidden */
  25484. _id: number;
  25485. private _currentMaterial;
  25486. /**
  25487. * Add a new submesh to a mesh
  25488. * @param materialIndex defines the material index to use
  25489. * @param verticesStart defines vertex index start
  25490. * @param verticesCount defines vertices count
  25491. * @param indexStart defines index start
  25492. * @param indexCount defines indices count
  25493. * @param mesh defines the parent mesh
  25494. * @param renderingMesh defines an optional rendering mesh
  25495. * @param createBoundingBox defines if bounding box should be created for this submesh
  25496. * @returns the new submesh
  25497. */
  25498. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25499. /**
  25500. * Creates a new submesh
  25501. * @param materialIndex defines the material index to use
  25502. * @param verticesStart defines vertex index start
  25503. * @param verticesCount defines vertices count
  25504. * @param indexStart defines index start
  25505. * @param indexCount defines indices count
  25506. * @param mesh defines the parent mesh
  25507. * @param renderingMesh defines an optional rendering mesh
  25508. * @param createBoundingBox defines if bounding box should be created for this submesh
  25509. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25510. */
  25511. constructor(
  25512. /** the material index to use */
  25513. materialIndex: number,
  25514. /** vertex index start */
  25515. verticesStart: number,
  25516. /** vertices count */
  25517. verticesCount: number,
  25518. /** index start */
  25519. indexStart: number,
  25520. /** indices count */
  25521. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25522. /**
  25523. * Returns true if this submesh covers the entire parent mesh
  25524. * @ignorenaming
  25525. */
  25526. get IsGlobal(): boolean;
  25527. /**
  25528. * Returns the submesh BoudingInfo object
  25529. * @returns current bounding info (or mesh's one if the submesh is global)
  25530. */
  25531. getBoundingInfo(): BoundingInfo;
  25532. /**
  25533. * Sets the submesh BoundingInfo
  25534. * @param boundingInfo defines the new bounding info to use
  25535. * @returns the SubMesh
  25536. */
  25537. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25538. /**
  25539. * Returns the mesh of the current submesh
  25540. * @return the parent mesh
  25541. */
  25542. getMesh(): AbstractMesh;
  25543. /**
  25544. * Returns the rendering mesh of the submesh
  25545. * @returns the rendering mesh (could be different from parent mesh)
  25546. */
  25547. getRenderingMesh(): Mesh;
  25548. /**
  25549. * Returns the replacement mesh of the submesh
  25550. * @returns the replacement mesh (could be different from parent mesh)
  25551. */
  25552. getReplacementMesh(): Nullable<AbstractMesh>;
  25553. /**
  25554. * Returns the effective mesh of the submesh
  25555. * @returns the effective mesh (could be different from parent mesh)
  25556. */
  25557. getEffectiveMesh(): AbstractMesh;
  25558. /**
  25559. * Returns the submesh material
  25560. * @returns null or the current material
  25561. */
  25562. getMaterial(): Nullable<Material>;
  25563. private _IsMultiMaterial;
  25564. /**
  25565. * Sets a new updated BoundingInfo object to the submesh
  25566. * @param data defines an optional position array to use to determine the bounding info
  25567. * @returns the SubMesh
  25568. */
  25569. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25570. /** @hidden */
  25571. _checkCollision(collider: Collider): boolean;
  25572. /**
  25573. * Updates the submesh BoundingInfo
  25574. * @param world defines the world matrix to use to update the bounding info
  25575. * @returns the submesh
  25576. */
  25577. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25578. /**
  25579. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25580. * @param frustumPlanes defines the frustum planes
  25581. * @returns true if the submesh is intersecting with the frustum
  25582. */
  25583. isInFrustum(frustumPlanes: Plane[]): boolean;
  25584. /**
  25585. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25586. * @param frustumPlanes defines the frustum planes
  25587. * @returns true if the submesh is inside the frustum
  25588. */
  25589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25590. /**
  25591. * Renders the submesh
  25592. * @param enableAlphaMode defines if alpha needs to be used
  25593. * @returns the submesh
  25594. */
  25595. render(enableAlphaMode: boolean): SubMesh;
  25596. /**
  25597. * @hidden
  25598. */
  25599. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25600. /**
  25601. * Checks if the submesh intersects with a ray
  25602. * @param ray defines the ray to test
  25603. * @returns true is the passed ray intersects the submesh bounding box
  25604. */
  25605. canIntersects(ray: Ray): boolean;
  25606. /**
  25607. * Intersects current submesh with a ray
  25608. * @param ray defines the ray to test
  25609. * @param positions defines mesh's positions array
  25610. * @param indices defines mesh's indices array
  25611. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25612. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25613. * @returns intersection info or null if no intersection
  25614. */
  25615. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25616. /** @hidden */
  25617. private _intersectLines;
  25618. /** @hidden */
  25619. private _intersectUnIndexedLines;
  25620. /** @hidden */
  25621. private _intersectTriangles;
  25622. /** @hidden */
  25623. private _intersectUnIndexedTriangles;
  25624. /** @hidden */
  25625. _rebuild(): void;
  25626. /**
  25627. * Creates a new submesh from the passed mesh
  25628. * @param newMesh defines the new hosting mesh
  25629. * @param newRenderingMesh defines an optional rendering mesh
  25630. * @returns the new submesh
  25631. */
  25632. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25633. /**
  25634. * Release associated resources
  25635. */
  25636. dispose(): void;
  25637. /**
  25638. * Gets the class name
  25639. * @returns the string "SubMesh".
  25640. */
  25641. getClassName(): string;
  25642. /**
  25643. * Creates a new submesh from indices data
  25644. * @param materialIndex the index of the main mesh material
  25645. * @param startIndex the index where to start the copy in the mesh indices array
  25646. * @param indexCount the number of indices to copy then from the startIndex
  25647. * @param mesh the main mesh to create the submesh from
  25648. * @param renderingMesh the optional rendering mesh
  25649. * @returns a new submesh
  25650. */
  25651. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25652. }
  25653. }
  25654. declare module BABYLON {
  25655. /**
  25656. * Class used to represent data loading progression
  25657. */
  25658. export class SceneLoaderFlags {
  25659. private static _ForceFullSceneLoadingForIncremental;
  25660. private static _ShowLoadingScreen;
  25661. private static _CleanBoneMatrixWeights;
  25662. private static _loggingLevel;
  25663. /**
  25664. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25665. */
  25666. static get ForceFullSceneLoadingForIncremental(): boolean;
  25667. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25668. /**
  25669. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25670. */
  25671. static get ShowLoadingScreen(): boolean;
  25672. static set ShowLoadingScreen(value: boolean);
  25673. /**
  25674. * Defines the current logging level (while loading the scene)
  25675. * @ignorenaming
  25676. */
  25677. static get loggingLevel(): number;
  25678. static set loggingLevel(value: number);
  25679. /**
  25680. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25681. */
  25682. static get CleanBoneMatrixWeights(): boolean;
  25683. static set CleanBoneMatrixWeights(value: boolean);
  25684. }
  25685. }
  25686. declare module BABYLON {
  25687. /**
  25688. * Class used to store geometry data (vertex buffers + index buffer)
  25689. */
  25690. export class Geometry implements IGetSetVerticesData {
  25691. /**
  25692. * Gets or sets the ID of the geometry
  25693. */
  25694. id: string;
  25695. /**
  25696. * Gets or sets the unique ID of the geometry
  25697. */
  25698. uniqueId: number;
  25699. /**
  25700. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25701. */
  25702. delayLoadState: number;
  25703. /**
  25704. * Gets the file containing the data to load when running in delay load state
  25705. */
  25706. delayLoadingFile: Nullable<string>;
  25707. /**
  25708. * Callback called when the geometry is updated
  25709. */
  25710. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25711. private _scene;
  25712. private _engine;
  25713. private _meshes;
  25714. private _totalVertices;
  25715. /** @hidden */
  25716. _indices: IndicesArray;
  25717. /** @hidden */
  25718. _vertexBuffers: {
  25719. [key: string]: VertexBuffer;
  25720. };
  25721. private _isDisposed;
  25722. private _extend;
  25723. private _boundingBias;
  25724. /** @hidden */
  25725. _delayInfo: Array<string>;
  25726. private _indexBuffer;
  25727. private _indexBufferIsUpdatable;
  25728. /** @hidden */
  25729. _boundingInfo: Nullable<BoundingInfo>;
  25730. /** @hidden */
  25731. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25732. /** @hidden */
  25733. _softwareSkinningFrameId: number;
  25734. private _vertexArrayObjects;
  25735. private _updatable;
  25736. /** @hidden */
  25737. _positions: Nullable<Vector3[]>;
  25738. /**
  25739. * 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
  25740. */
  25741. get boundingBias(): Vector2;
  25742. /**
  25743. * 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
  25744. */
  25745. set boundingBias(value: Vector2);
  25746. /**
  25747. * Static function used to attach a new empty geometry to a mesh
  25748. * @param mesh defines the mesh to attach the geometry to
  25749. * @returns the new Geometry
  25750. */
  25751. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25752. /** Get the list of meshes using this geometry */
  25753. get meshes(): Mesh[];
  25754. /**
  25755. * 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
  25756. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25757. */
  25758. useBoundingInfoFromGeometry: boolean;
  25759. /**
  25760. * Creates a new geometry
  25761. * @param id defines the unique ID
  25762. * @param scene defines the hosting scene
  25763. * @param vertexData defines the VertexData used to get geometry data
  25764. * @param updatable defines if geometry must be updatable (false by default)
  25765. * @param mesh defines the mesh that will be associated with the geometry
  25766. */
  25767. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25768. /**
  25769. * Gets the current extend of the geometry
  25770. */
  25771. get extend(): {
  25772. minimum: Vector3;
  25773. maximum: Vector3;
  25774. };
  25775. /**
  25776. * Gets the hosting scene
  25777. * @returns the hosting Scene
  25778. */
  25779. getScene(): Scene;
  25780. /**
  25781. * Gets the hosting engine
  25782. * @returns the hosting Engine
  25783. */
  25784. getEngine(): Engine;
  25785. /**
  25786. * Defines if the geometry is ready to use
  25787. * @returns true if the geometry is ready to be used
  25788. */
  25789. isReady(): boolean;
  25790. /**
  25791. * Gets a value indicating that the geometry should not be serialized
  25792. */
  25793. get doNotSerialize(): boolean;
  25794. /** @hidden */
  25795. _rebuild(): void;
  25796. /**
  25797. * Affects all geometry data in one call
  25798. * @param vertexData defines the geometry data
  25799. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25800. */
  25801. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25802. /**
  25803. * Set specific vertex data
  25804. * @param kind defines the data kind (Position, normal, etc...)
  25805. * @param data defines the vertex data to use
  25806. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25807. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25808. */
  25809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25810. /**
  25811. * Removes a specific vertex data
  25812. * @param kind defines the data kind (Position, normal, etc...)
  25813. */
  25814. removeVerticesData(kind: string): void;
  25815. /**
  25816. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25817. * @param buffer defines the vertex buffer to use
  25818. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25819. */
  25820. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25821. /**
  25822. * Update a specific vertex buffer
  25823. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25824. * It will do nothing if the buffer is not updatable
  25825. * @param kind defines the data kind (Position, normal, etc...)
  25826. * @param data defines the data to use
  25827. * @param offset defines the offset in the target buffer where to store the data
  25828. * @param useBytes set to true if the offset is in bytes
  25829. */
  25830. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25831. /**
  25832. * Update a specific vertex buffer
  25833. * This function will create a new buffer if the current one is not updatable
  25834. * @param kind defines the data kind (Position, normal, etc...)
  25835. * @param data defines the data to use
  25836. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25837. */
  25838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25839. private _updateBoundingInfo;
  25840. /** @hidden */
  25841. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25842. /**
  25843. * Gets total number of vertices
  25844. * @returns the total number of vertices
  25845. */
  25846. getTotalVertices(): number;
  25847. /**
  25848. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25849. * @param kind defines the data kind (Position, normal, etc...)
  25850. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25851. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25852. * @returns a float array containing vertex data
  25853. */
  25854. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25855. /**
  25856. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25857. * @param kind defines the data kind (Position, normal, etc...)
  25858. * @returns true if the vertex buffer with the specified kind is updatable
  25859. */
  25860. isVertexBufferUpdatable(kind: string): boolean;
  25861. /**
  25862. * Gets a specific vertex buffer
  25863. * @param kind defines the data kind (Position, normal, etc...)
  25864. * @returns a VertexBuffer
  25865. */
  25866. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25867. /**
  25868. * Returns all vertex buffers
  25869. * @return an object holding all vertex buffers indexed by kind
  25870. */
  25871. getVertexBuffers(): Nullable<{
  25872. [key: string]: VertexBuffer;
  25873. }>;
  25874. /**
  25875. * Gets a boolean indicating if specific vertex buffer is present
  25876. * @param kind defines the data kind (Position, normal, etc...)
  25877. * @returns true if data is present
  25878. */
  25879. isVerticesDataPresent(kind: string): boolean;
  25880. /**
  25881. * Gets a list of all attached data kinds (Position, normal, etc...)
  25882. * @returns a list of string containing all kinds
  25883. */
  25884. getVerticesDataKinds(): string[];
  25885. /**
  25886. * Update index buffer
  25887. * @param indices defines the indices to store in the index buffer
  25888. * @param offset defines the offset in the target buffer where to store the data
  25889. * @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)
  25890. */
  25891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25892. /**
  25893. * Creates a new index buffer
  25894. * @param indices defines the indices to store in the index buffer
  25895. * @param totalVertices defines the total number of vertices (could be null)
  25896. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25897. */
  25898. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25899. /**
  25900. * Return the total number of indices
  25901. * @returns the total number of indices
  25902. */
  25903. getTotalIndices(): number;
  25904. /**
  25905. * Gets the index buffer array
  25906. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25907. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25908. * @returns the index buffer array
  25909. */
  25910. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25911. /**
  25912. * Gets the index buffer
  25913. * @return the index buffer
  25914. */
  25915. getIndexBuffer(): Nullable<DataBuffer>;
  25916. /** @hidden */
  25917. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25918. /**
  25919. * Release the associated resources for a specific mesh
  25920. * @param mesh defines the source mesh
  25921. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25922. */
  25923. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25924. /**
  25925. * Apply current geometry to a given mesh
  25926. * @param mesh defines the mesh to apply geometry to
  25927. */
  25928. applyToMesh(mesh: Mesh): void;
  25929. private _updateExtend;
  25930. private _applyToMesh;
  25931. private notifyUpdate;
  25932. /**
  25933. * Load the geometry if it was flagged as delay loaded
  25934. * @param scene defines the hosting scene
  25935. * @param onLoaded defines a callback called when the geometry is loaded
  25936. */
  25937. load(scene: Scene, onLoaded?: () => void): void;
  25938. private _queueLoad;
  25939. /**
  25940. * Invert the geometry to move from a right handed system to a left handed one.
  25941. */
  25942. toLeftHanded(): void;
  25943. /** @hidden */
  25944. _resetPointsArrayCache(): void;
  25945. /** @hidden */
  25946. _generatePointsArray(): boolean;
  25947. /**
  25948. * Gets a value indicating if the geometry is disposed
  25949. * @returns true if the geometry was disposed
  25950. */
  25951. isDisposed(): boolean;
  25952. private _disposeVertexArrayObjects;
  25953. /**
  25954. * Free all associated resources
  25955. */
  25956. dispose(): void;
  25957. /**
  25958. * Clone the current geometry into a new geometry
  25959. * @param id defines the unique ID of the new geometry
  25960. * @returns a new geometry object
  25961. */
  25962. copy(id: string): Geometry;
  25963. /**
  25964. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25965. * @return a JSON representation of the current geometry data (without the vertices data)
  25966. */
  25967. serialize(): any;
  25968. private toNumberArray;
  25969. /**
  25970. * Serialize all vertices data into a JSON oject
  25971. * @returns a JSON representation of the current geometry data
  25972. */
  25973. serializeVerticeData(): any;
  25974. /**
  25975. * Extracts a clone of a mesh geometry
  25976. * @param mesh defines the source mesh
  25977. * @param id defines the unique ID of the new geometry object
  25978. * @returns the new geometry object
  25979. */
  25980. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25981. /**
  25982. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25983. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25984. * Be aware Math.random() could cause collisions, but:
  25985. * "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"
  25986. * @returns a string containing a new GUID
  25987. */
  25988. static RandomId(): string;
  25989. /** @hidden */
  25990. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25991. private static _CleanMatricesWeights;
  25992. /**
  25993. * Create a new geometry from persisted data (Using .babylon file format)
  25994. * @param parsedVertexData defines the persisted data
  25995. * @param scene defines the hosting scene
  25996. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25997. * @returns the new geometry object
  25998. */
  25999. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26000. }
  26001. }
  26002. declare module BABYLON {
  26003. /**
  26004. * Define an interface for all classes that will get and set the data on vertices
  26005. */
  26006. export interface IGetSetVerticesData {
  26007. /**
  26008. * Gets a boolean indicating if specific vertex data is present
  26009. * @param kind defines the vertex data kind to use
  26010. * @returns true is data kind is present
  26011. */
  26012. isVerticesDataPresent(kind: string): boolean;
  26013. /**
  26014. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26015. * @param kind defines the data kind (Position, normal, etc...)
  26016. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26017. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26018. * @returns a float array containing vertex data
  26019. */
  26020. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26021. /**
  26022. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26023. * @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.
  26024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26025. * @returns the indices array or an empty array if the mesh has no geometry
  26026. */
  26027. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26028. /**
  26029. * Set specific vertex data
  26030. * @param kind defines the data kind (Position, normal, etc...)
  26031. * @param data defines the vertex data to use
  26032. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26033. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26034. */
  26035. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26036. /**
  26037. * Update a specific associated vertex buffer
  26038. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26039. * - VertexBuffer.PositionKind
  26040. * - VertexBuffer.UVKind
  26041. * - VertexBuffer.UV2Kind
  26042. * - VertexBuffer.UV3Kind
  26043. * - VertexBuffer.UV4Kind
  26044. * - VertexBuffer.UV5Kind
  26045. * - VertexBuffer.UV6Kind
  26046. * - VertexBuffer.ColorKind
  26047. * - VertexBuffer.MatricesIndicesKind
  26048. * - VertexBuffer.MatricesIndicesExtraKind
  26049. * - VertexBuffer.MatricesWeightsKind
  26050. * - VertexBuffer.MatricesWeightsExtraKind
  26051. * @param data defines the data source
  26052. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26053. * @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)
  26054. */
  26055. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26056. /**
  26057. * Creates a new index buffer
  26058. * @param indices defines the indices to store in the index buffer
  26059. * @param totalVertices defines the total number of vertices (could be null)
  26060. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26061. */
  26062. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26063. }
  26064. /**
  26065. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26066. */
  26067. export class VertexData {
  26068. /**
  26069. * Mesh side orientation : usually the external or front surface
  26070. */
  26071. static readonly FRONTSIDE: number;
  26072. /**
  26073. * Mesh side orientation : usually the internal or back surface
  26074. */
  26075. static readonly BACKSIDE: number;
  26076. /**
  26077. * Mesh side orientation : both internal and external or front and back surfaces
  26078. */
  26079. static readonly DOUBLESIDE: number;
  26080. /**
  26081. * Mesh side orientation : by default, `FRONTSIDE`
  26082. */
  26083. static readonly DEFAULTSIDE: number;
  26084. /**
  26085. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26086. */
  26087. positions: Nullable<FloatArray>;
  26088. /**
  26089. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26090. */
  26091. normals: Nullable<FloatArray>;
  26092. /**
  26093. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26094. */
  26095. tangents: Nullable<FloatArray>;
  26096. /**
  26097. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26098. */
  26099. uvs: Nullable<FloatArray>;
  26100. /**
  26101. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26102. */
  26103. uvs2: Nullable<FloatArray>;
  26104. /**
  26105. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26106. */
  26107. uvs3: Nullable<FloatArray>;
  26108. /**
  26109. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26110. */
  26111. uvs4: Nullable<FloatArray>;
  26112. /**
  26113. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26114. */
  26115. uvs5: Nullable<FloatArray>;
  26116. /**
  26117. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26118. */
  26119. uvs6: Nullable<FloatArray>;
  26120. /**
  26121. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26122. */
  26123. colors: Nullable<FloatArray>;
  26124. /**
  26125. * 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).
  26126. */
  26127. matricesIndices: Nullable<FloatArray>;
  26128. /**
  26129. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26130. */
  26131. matricesWeights: Nullable<FloatArray>;
  26132. /**
  26133. * An array extending the number of possible indices
  26134. */
  26135. matricesIndicesExtra: Nullable<FloatArray>;
  26136. /**
  26137. * An array extending the number of possible weights when the number of indices is extended
  26138. */
  26139. matricesWeightsExtra: Nullable<FloatArray>;
  26140. /**
  26141. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26142. */
  26143. indices: Nullable<IndicesArray>;
  26144. /**
  26145. * Uses the passed data array to set the set the values for the specified kind of data
  26146. * @param data a linear array of floating numbers
  26147. * @param kind the type of data that is being set, eg positions, colors etc
  26148. */
  26149. set(data: FloatArray, kind: string): void;
  26150. /**
  26151. * Associates the vertexData to the passed Mesh.
  26152. * Sets it as updatable or not (default `false`)
  26153. * @param mesh the mesh the vertexData is applied to
  26154. * @param updatable when used and having the value true allows new data to update the vertexData
  26155. * @returns the VertexData
  26156. */
  26157. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26158. /**
  26159. * Associates the vertexData to the passed Geometry.
  26160. * Sets it as updatable or not (default `false`)
  26161. * @param geometry the geometry the vertexData is applied to
  26162. * @param updatable when used and having the value true allows new data to update the vertexData
  26163. * @returns VertexData
  26164. */
  26165. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26166. /**
  26167. * Updates the associated mesh
  26168. * @param mesh the mesh to be updated
  26169. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26170. * @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
  26171. * @returns VertexData
  26172. */
  26173. updateMesh(mesh: Mesh): VertexData;
  26174. /**
  26175. * Updates the associated geometry
  26176. * @param geometry the geometry to be updated
  26177. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26178. * @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
  26179. * @returns VertexData.
  26180. */
  26181. updateGeometry(geometry: Geometry): VertexData;
  26182. private _applyTo;
  26183. private _update;
  26184. /**
  26185. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26186. * @param matrix the transforming matrix
  26187. * @returns the VertexData
  26188. */
  26189. transform(matrix: Matrix): VertexData;
  26190. /**
  26191. * Merges the passed VertexData into the current one
  26192. * @param other the VertexData to be merged into the current one
  26193. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26194. * @returns the modified VertexData
  26195. */
  26196. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26197. private _mergeElement;
  26198. private _validate;
  26199. /**
  26200. * Serializes the VertexData
  26201. * @returns a serialized object
  26202. */
  26203. serialize(): any;
  26204. /**
  26205. * Extracts the vertexData from a mesh
  26206. * @param mesh the mesh from which to extract the VertexData
  26207. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26209. * @returns the object VertexData associated to the passed mesh
  26210. */
  26211. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26212. /**
  26213. * Extracts the vertexData from the geometry
  26214. * @param geometry the geometry from which to extract the VertexData
  26215. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26216. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26217. * @returns the object VertexData associated to the passed mesh
  26218. */
  26219. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26220. private static _ExtractFrom;
  26221. /**
  26222. * Creates the VertexData for a Ribbon
  26223. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26224. * * pathArray array of paths, each of which an array of successive Vector3
  26225. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26226. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26227. * * 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
  26228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26229. * * 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)
  26230. * * 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)
  26231. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26232. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26233. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26234. * @returns the VertexData of the ribbon
  26235. */
  26236. static CreateRibbon(options: {
  26237. pathArray: Vector3[][];
  26238. closeArray?: boolean;
  26239. closePath?: boolean;
  26240. offset?: number;
  26241. sideOrientation?: number;
  26242. frontUVs?: Vector4;
  26243. backUVs?: Vector4;
  26244. invertUV?: boolean;
  26245. uvs?: Vector2[];
  26246. colors?: Color4[];
  26247. }): VertexData;
  26248. /**
  26249. * Creates the VertexData for a box
  26250. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26251. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26252. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26253. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26254. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26255. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26256. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26258. * * 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)
  26259. * * 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)
  26260. * @returns the VertexData of the box
  26261. */
  26262. static CreateBox(options: {
  26263. size?: number;
  26264. width?: number;
  26265. height?: number;
  26266. depth?: number;
  26267. faceUV?: Vector4[];
  26268. faceColors?: Color4[];
  26269. sideOrientation?: number;
  26270. frontUVs?: Vector4;
  26271. backUVs?: Vector4;
  26272. }): VertexData;
  26273. /**
  26274. * Creates the VertexData for a tiled box
  26275. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26276. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26277. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26278. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26280. * @returns the VertexData of the box
  26281. */
  26282. static CreateTiledBox(options: {
  26283. pattern?: number;
  26284. width?: number;
  26285. height?: number;
  26286. depth?: number;
  26287. tileSize?: number;
  26288. tileWidth?: number;
  26289. tileHeight?: number;
  26290. alignHorizontal?: number;
  26291. alignVertical?: number;
  26292. faceUV?: Vector4[];
  26293. faceColors?: Color4[];
  26294. sideOrientation?: number;
  26295. }): VertexData;
  26296. /**
  26297. * Creates the VertexData for a tiled plane
  26298. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26299. * * pattern a limited pattern arrangement depending on the number
  26300. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26301. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26302. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26304. * * 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)
  26305. * * 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)
  26306. * @returns the VertexData of the tiled plane
  26307. */
  26308. static CreateTiledPlane(options: {
  26309. pattern?: number;
  26310. tileSize?: number;
  26311. tileWidth?: number;
  26312. tileHeight?: number;
  26313. size?: number;
  26314. width?: number;
  26315. height?: number;
  26316. alignHorizontal?: number;
  26317. alignVertical?: number;
  26318. sideOrientation?: number;
  26319. frontUVs?: Vector4;
  26320. backUVs?: Vector4;
  26321. }): VertexData;
  26322. /**
  26323. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26324. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26325. * * segments sets the number of horizontal strips optional, default 32
  26326. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26327. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26328. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26329. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26330. * * 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
  26331. * * 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
  26332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26333. * * 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)
  26334. * * 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)
  26335. * @returns the VertexData of the ellipsoid
  26336. */
  26337. static CreateSphere(options: {
  26338. segments?: number;
  26339. diameter?: number;
  26340. diameterX?: number;
  26341. diameterY?: number;
  26342. diameterZ?: number;
  26343. arc?: number;
  26344. slice?: number;
  26345. sideOrientation?: number;
  26346. frontUVs?: Vector4;
  26347. backUVs?: Vector4;
  26348. }): VertexData;
  26349. /**
  26350. * Creates the VertexData for a cylinder, cone or prism
  26351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26352. * * height sets the height (y direction) of the cylinder, optional, default 2
  26353. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26354. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26355. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26356. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26357. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26358. * * 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
  26359. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26360. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26361. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26362. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26364. * * 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)
  26365. * * 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)
  26366. * @returns the VertexData of the cylinder, cone or prism
  26367. */
  26368. static CreateCylinder(options: {
  26369. height?: number;
  26370. diameterTop?: number;
  26371. diameterBottom?: number;
  26372. diameter?: number;
  26373. tessellation?: number;
  26374. subdivisions?: number;
  26375. arc?: number;
  26376. faceColors?: Color4[];
  26377. faceUV?: Vector4[];
  26378. hasRings?: boolean;
  26379. enclose?: boolean;
  26380. sideOrientation?: number;
  26381. frontUVs?: Vector4;
  26382. backUVs?: Vector4;
  26383. }): VertexData;
  26384. /**
  26385. * Creates the VertexData for a torus
  26386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26387. * * diameter the diameter of the torus, optional default 1
  26388. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26389. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26391. * * 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)
  26392. * * 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)
  26393. * @returns the VertexData of the torus
  26394. */
  26395. static CreateTorus(options: {
  26396. diameter?: number;
  26397. thickness?: number;
  26398. tessellation?: number;
  26399. sideOrientation?: number;
  26400. frontUVs?: Vector4;
  26401. backUVs?: Vector4;
  26402. }): VertexData;
  26403. /**
  26404. * Creates the VertexData of the LineSystem
  26405. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26406. * - lines an array of lines, each line being an array of successive Vector3
  26407. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26408. * @returns the VertexData of the LineSystem
  26409. */
  26410. static CreateLineSystem(options: {
  26411. lines: Vector3[][];
  26412. colors?: Nullable<Color4[][]>;
  26413. }): VertexData;
  26414. /**
  26415. * Create the VertexData for a DashedLines
  26416. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26417. * - points an array successive Vector3
  26418. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26419. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26420. * - dashNb the intended total number of dashes, optional, default 200
  26421. * @returns the VertexData for the DashedLines
  26422. */
  26423. static CreateDashedLines(options: {
  26424. points: Vector3[];
  26425. dashSize?: number;
  26426. gapSize?: number;
  26427. dashNb?: number;
  26428. }): VertexData;
  26429. /**
  26430. * Creates the VertexData for a Ground
  26431. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26432. * - width the width (x direction) of the ground, optional, default 1
  26433. * - height the height (z direction) of the ground, optional, default 1
  26434. * - subdivisions the number of subdivisions per side, optional, default 1
  26435. * @returns the VertexData of the Ground
  26436. */
  26437. static CreateGround(options: {
  26438. width?: number;
  26439. height?: number;
  26440. subdivisions?: number;
  26441. subdivisionsX?: number;
  26442. subdivisionsY?: number;
  26443. }): VertexData;
  26444. /**
  26445. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26446. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26447. * * xmin the ground minimum X coordinate, optional, default -1
  26448. * * zmin the ground minimum Z coordinate, optional, default -1
  26449. * * xmax the ground maximum X coordinate, optional, default 1
  26450. * * zmax the ground maximum Z coordinate, optional, default 1
  26451. * * 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}
  26452. * * 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}
  26453. * @returns the VertexData of the TiledGround
  26454. */
  26455. static CreateTiledGround(options: {
  26456. xmin: number;
  26457. zmin: number;
  26458. xmax: number;
  26459. zmax: number;
  26460. subdivisions?: {
  26461. w: number;
  26462. h: number;
  26463. };
  26464. precision?: {
  26465. w: number;
  26466. h: number;
  26467. };
  26468. }): VertexData;
  26469. /**
  26470. * Creates the VertexData of the Ground designed from a heightmap
  26471. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26472. * * width the width (x direction) of the ground
  26473. * * height the height (z direction) of the ground
  26474. * * subdivisions the number of subdivisions per side
  26475. * * minHeight the minimum altitude on the ground, optional, default 0
  26476. * * maxHeight the maximum altitude on the ground, optional default 1
  26477. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26478. * * buffer the array holding the image color data
  26479. * * bufferWidth the width of image
  26480. * * bufferHeight the height of image
  26481. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26482. * @returns the VertexData of the Ground designed from a heightmap
  26483. */
  26484. static CreateGroundFromHeightMap(options: {
  26485. width: number;
  26486. height: number;
  26487. subdivisions: number;
  26488. minHeight: number;
  26489. maxHeight: number;
  26490. colorFilter: Color3;
  26491. buffer: Uint8Array;
  26492. bufferWidth: number;
  26493. bufferHeight: number;
  26494. alphaFilter: number;
  26495. }): VertexData;
  26496. /**
  26497. * Creates the VertexData for a Plane
  26498. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26499. * * size sets the width and height of the plane to the value of size, optional default 1
  26500. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26501. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26503. * * 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)
  26504. * * 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)
  26505. * @returns the VertexData of the box
  26506. */
  26507. static CreatePlane(options: {
  26508. size?: number;
  26509. width?: number;
  26510. height?: number;
  26511. sideOrientation?: number;
  26512. frontUVs?: Vector4;
  26513. backUVs?: Vector4;
  26514. }): VertexData;
  26515. /**
  26516. * Creates the VertexData of the Disc or regular Polygon
  26517. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26518. * * radius the radius of the disc, optional default 0.5
  26519. * * tessellation the number of polygon sides, optional, default 64
  26520. * * 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
  26521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26522. * * 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)
  26523. * * 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)
  26524. * @returns the VertexData of the box
  26525. */
  26526. static CreateDisc(options: {
  26527. radius?: number;
  26528. tessellation?: number;
  26529. arc?: number;
  26530. sideOrientation?: number;
  26531. frontUVs?: Vector4;
  26532. backUVs?: Vector4;
  26533. }): VertexData;
  26534. /**
  26535. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26536. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26537. * @param polygon a mesh built from polygonTriangulation.build()
  26538. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26539. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26540. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26541. * @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)
  26542. * @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)
  26543. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26544. * @returns the VertexData of the Polygon
  26545. */
  26546. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26547. /**
  26548. * Creates the VertexData of the IcoSphere
  26549. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26550. * * radius the radius of the IcoSphere, optional default 1
  26551. * * radiusX allows stretching in the x direction, optional, default radius
  26552. * * radiusY allows stretching in the y direction, optional, default radius
  26553. * * radiusZ allows stretching in the z direction, optional, default radius
  26554. * * flat when true creates a flat shaded mesh, optional, default true
  26555. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26557. * * 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)
  26558. * * 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)
  26559. * @returns the VertexData of the IcoSphere
  26560. */
  26561. static CreateIcoSphere(options: {
  26562. radius?: number;
  26563. radiusX?: number;
  26564. radiusY?: number;
  26565. radiusZ?: number;
  26566. flat?: boolean;
  26567. subdivisions?: number;
  26568. sideOrientation?: number;
  26569. frontUVs?: Vector4;
  26570. backUVs?: Vector4;
  26571. }): VertexData;
  26572. /**
  26573. * Creates the VertexData for a Polyhedron
  26574. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26575. * * type provided types are:
  26576. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26577. * * 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)
  26578. * * size the size of the IcoSphere, optional default 1
  26579. * * sizeX allows stretching in the x direction, optional, default size
  26580. * * sizeY allows stretching in the y direction, optional, default size
  26581. * * sizeZ allows stretching in the z direction, optional, default size
  26582. * * 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
  26583. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26584. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26585. * * flat when true creates a flat shaded mesh, optional, default true
  26586. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26588. * * 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)
  26589. * * 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)
  26590. * @returns the VertexData of the Polyhedron
  26591. */
  26592. static CreatePolyhedron(options: {
  26593. type?: number;
  26594. size?: number;
  26595. sizeX?: number;
  26596. sizeY?: number;
  26597. sizeZ?: number;
  26598. custom?: any;
  26599. faceUV?: Vector4[];
  26600. faceColors?: Color4[];
  26601. flat?: boolean;
  26602. sideOrientation?: number;
  26603. frontUVs?: Vector4;
  26604. backUVs?: Vector4;
  26605. }): VertexData;
  26606. /**
  26607. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26608. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26609. * @returns the VertexData of the Capsule
  26610. */
  26611. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26612. /**
  26613. * Creates the VertexData for a TorusKnot
  26614. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26615. * * radius the radius of the torus knot, optional, default 2
  26616. * * tube the thickness of the tube, optional, default 0.5
  26617. * * radialSegments the number of sides on each tube segments, optional, default 32
  26618. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26619. * * p the number of windings around the z axis, optional, default 2
  26620. * * q the number of windings around the x axis, optional, default 3
  26621. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26622. * * 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)
  26623. * * 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)
  26624. * @returns the VertexData of the Torus Knot
  26625. */
  26626. static CreateTorusKnot(options: {
  26627. radius?: number;
  26628. tube?: number;
  26629. radialSegments?: number;
  26630. tubularSegments?: number;
  26631. p?: number;
  26632. q?: number;
  26633. sideOrientation?: number;
  26634. frontUVs?: Vector4;
  26635. backUVs?: Vector4;
  26636. }): VertexData;
  26637. /**
  26638. * Compute normals for given positions and indices
  26639. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26640. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26641. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26642. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26643. * * facetNormals : optional array of facet normals (vector3)
  26644. * * facetPositions : optional array of facet positions (vector3)
  26645. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26646. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26647. * * bInfo : optional bounding info, required for facetPartitioning computation
  26648. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26649. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26650. * * useRightHandedSystem: optional boolean to for right handed system computation
  26651. * * depthSort : optional boolean to enable the facet depth sort computation
  26652. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26653. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26654. */
  26655. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26656. facetNormals?: any;
  26657. facetPositions?: any;
  26658. facetPartitioning?: any;
  26659. ratio?: number;
  26660. bInfo?: any;
  26661. bbSize?: Vector3;
  26662. subDiv?: any;
  26663. useRightHandedSystem?: boolean;
  26664. depthSort?: boolean;
  26665. distanceTo?: Vector3;
  26666. depthSortedFacets?: any;
  26667. }): void;
  26668. /** @hidden */
  26669. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26670. /**
  26671. * Applies VertexData created from the imported parameters to the geometry
  26672. * @param parsedVertexData the parsed data from an imported file
  26673. * @param geometry the geometry to apply the VertexData to
  26674. */
  26675. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26676. }
  26677. }
  26678. declare module BABYLON {
  26679. /**
  26680. * Defines a target to use with MorphTargetManager
  26681. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26682. */
  26683. export class MorphTarget implements IAnimatable {
  26684. /** defines the name of the target */
  26685. name: string;
  26686. /**
  26687. * Gets or sets the list of animations
  26688. */
  26689. animations: Animation[];
  26690. private _scene;
  26691. private _positions;
  26692. private _normals;
  26693. private _tangents;
  26694. private _uvs;
  26695. private _influence;
  26696. private _uniqueId;
  26697. /**
  26698. * Observable raised when the influence changes
  26699. */
  26700. onInfluenceChanged: Observable<boolean>;
  26701. /** @hidden */
  26702. _onDataLayoutChanged: Observable<void>;
  26703. /**
  26704. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26705. */
  26706. get influence(): number;
  26707. set influence(influence: number);
  26708. /**
  26709. * Gets or sets the id of the morph Target
  26710. */
  26711. id: string;
  26712. private _animationPropertiesOverride;
  26713. /**
  26714. * Gets or sets the animation properties override
  26715. */
  26716. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26717. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26718. /**
  26719. * Creates a new MorphTarget
  26720. * @param name defines the name of the target
  26721. * @param influence defines the influence to use
  26722. * @param scene defines the scene the morphtarget belongs to
  26723. */
  26724. constructor(
  26725. /** defines the name of the target */
  26726. name: string, influence?: number, scene?: Nullable<Scene>);
  26727. /**
  26728. * Gets the unique ID of this manager
  26729. */
  26730. get uniqueId(): number;
  26731. /**
  26732. * Gets a boolean defining if the target contains position data
  26733. */
  26734. get hasPositions(): boolean;
  26735. /**
  26736. * Gets a boolean defining if the target contains normal data
  26737. */
  26738. get hasNormals(): boolean;
  26739. /**
  26740. * Gets a boolean defining if the target contains tangent data
  26741. */
  26742. get hasTangents(): boolean;
  26743. /**
  26744. * Gets a boolean defining if the target contains texture coordinates data
  26745. */
  26746. get hasUVs(): boolean;
  26747. /**
  26748. * Affects position data to this target
  26749. * @param data defines the position data to use
  26750. */
  26751. setPositions(data: Nullable<FloatArray>): void;
  26752. /**
  26753. * Gets the position data stored in this target
  26754. * @returns a FloatArray containing the position data (or null if not present)
  26755. */
  26756. getPositions(): Nullable<FloatArray>;
  26757. /**
  26758. * Affects normal data to this target
  26759. * @param data defines the normal data to use
  26760. */
  26761. setNormals(data: Nullable<FloatArray>): void;
  26762. /**
  26763. * Gets the normal data stored in this target
  26764. * @returns a FloatArray containing the normal data (or null if not present)
  26765. */
  26766. getNormals(): Nullable<FloatArray>;
  26767. /**
  26768. * Affects tangent data to this target
  26769. * @param data defines the tangent data to use
  26770. */
  26771. setTangents(data: Nullable<FloatArray>): void;
  26772. /**
  26773. * Gets the tangent data stored in this target
  26774. * @returns a FloatArray containing the tangent data (or null if not present)
  26775. */
  26776. getTangents(): Nullable<FloatArray>;
  26777. /**
  26778. * Affects texture coordinates data to this target
  26779. * @param data defines the texture coordinates data to use
  26780. */
  26781. setUVs(data: Nullable<FloatArray>): void;
  26782. /**
  26783. * Gets the texture coordinates data stored in this target
  26784. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26785. */
  26786. getUVs(): Nullable<FloatArray>;
  26787. /**
  26788. * Clone the current target
  26789. * @returns a new MorphTarget
  26790. */
  26791. clone(): MorphTarget;
  26792. /**
  26793. * Serializes the current target into a Serialization object
  26794. * @returns the serialized object
  26795. */
  26796. serialize(): any;
  26797. /**
  26798. * Returns the string "MorphTarget"
  26799. * @returns "MorphTarget"
  26800. */
  26801. getClassName(): string;
  26802. /**
  26803. * Creates a new target from serialized data
  26804. * @param serializationObject defines the serialized data to use
  26805. * @returns a new MorphTarget
  26806. */
  26807. static Parse(serializationObject: any): MorphTarget;
  26808. /**
  26809. * Creates a MorphTarget from mesh data
  26810. * @param mesh defines the source mesh
  26811. * @param name defines the name to use for the new target
  26812. * @param influence defines the influence to attach to the target
  26813. * @returns a new MorphTarget
  26814. */
  26815. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26816. }
  26817. }
  26818. declare module BABYLON {
  26819. /**
  26820. * This class is used to deform meshes using morphing between different targets
  26821. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26822. */
  26823. export class MorphTargetManager {
  26824. private _targets;
  26825. private _targetInfluenceChangedObservers;
  26826. private _targetDataLayoutChangedObservers;
  26827. private _activeTargets;
  26828. private _scene;
  26829. private _influences;
  26830. private _supportsNormals;
  26831. private _supportsTangents;
  26832. private _supportsUVs;
  26833. private _vertexCount;
  26834. private _uniqueId;
  26835. private _tempInfluences;
  26836. /**
  26837. * Gets or sets a boolean indicating if normals must be morphed
  26838. */
  26839. enableNormalMorphing: boolean;
  26840. /**
  26841. * Gets or sets a boolean indicating if tangents must be morphed
  26842. */
  26843. enableTangentMorphing: boolean;
  26844. /**
  26845. * Gets or sets a boolean indicating if UV must be morphed
  26846. */
  26847. enableUVMorphing: boolean;
  26848. /**
  26849. * Creates a new MorphTargetManager
  26850. * @param scene defines the current scene
  26851. */
  26852. constructor(scene?: Nullable<Scene>);
  26853. /**
  26854. * Gets the unique ID of this manager
  26855. */
  26856. get uniqueId(): number;
  26857. /**
  26858. * Gets the number of vertices handled by this manager
  26859. */
  26860. get vertexCount(): number;
  26861. /**
  26862. * Gets a boolean indicating if this manager supports morphing of normals
  26863. */
  26864. get supportsNormals(): boolean;
  26865. /**
  26866. * Gets a boolean indicating if this manager supports morphing of tangents
  26867. */
  26868. get supportsTangents(): boolean;
  26869. /**
  26870. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26871. */
  26872. get supportsUVs(): boolean;
  26873. /**
  26874. * Gets the number of targets stored in this manager
  26875. */
  26876. get numTargets(): number;
  26877. /**
  26878. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26879. */
  26880. get numInfluencers(): number;
  26881. /**
  26882. * Gets the list of influences (one per target)
  26883. */
  26884. get influences(): Float32Array;
  26885. /**
  26886. * Gets the active target at specified index. An active target is a target with an influence > 0
  26887. * @param index defines the index to check
  26888. * @returns the requested target
  26889. */
  26890. getActiveTarget(index: number): MorphTarget;
  26891. /**
  26892. * Gets the target at specified index
  26893. * @param index defines the index to check
  26894. * @returns the requested target
  26895. */
  26896. getTarget(index: number): MorphTarget;
  26897. /**
  26898. * Add a new target to this manager
  26899. * @param target defines the target to add
  26900. */
  26901. addTarget(target: MorphTarget): void;
  26902. /**
  26903. * Removes a target from the manager
  26904. * @param target defines the target to remove
  26905. */
  26906. removeTarget(target: MorphTarget): void;
  26907. /**
  26908. * Clone the current manager
  26909. * @returns a new MorphTargetManager
  26910. */
  26911. clone(): MorphTargetManager;
  26912. /**
  26913. * Serializes the current manager into a Serialization object
  26914. * @returns the serialized object
  26915. */
  26916. serialize(): any;
  26917. private _syncActiveTargets;
  26918. /**
  26919. * Syncrhonize the targets with all the meshes using this morph target manager
  26920. */
  26921. synchronize(): void;
  26922. /**
  26923. * Creates a new MorphTargetManager from serialized data
  26924. * @param serializationObject defines the serialized data
  26925. * @param scene defines the hosting scene
  26926. * @returns the new MorphTargetManager
  26927. */
  26928. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26929. }
  26930. }
  26931. declare module BABYLON {
  26932. /**
  26933. * Class used to represent a specific level of detail of a mesh
  26934. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26935. */
  26936. export class MeshLODLevel {
  26937. /** Defines the distance where this level should start being displayed */
  26938. distance: number;
  26939. /** Defines the mesh to use to render this level */
  26940. mesh: Nullable<Mesh>;
  26941. /**
  26942. * Creates a new LOD level
  26943. * @param distance defines the distance where this level should star being displayed
  26944. * @param mesh defines the mesh to use to render this level
  26945. */
  26946. constructor(
  26947. /** Defines the distance where this level should start being displayed */
  26948. distance: number,
  26949. /** Defines the mesh to use to render this level */
  26950. mesh: Nullable<Mesh>);
  26951. }
  26952. }
  26953. declare module BABYLON {
  26954. /**
  26955. * Helper class used to generate a canvas to manipulate images
  26956. */
  26957. export class CanvasGenerator {
  26958. /**
  26959. * Create a new canvas (or offscreen canvas depending on the context)
  26960. * @param width defines the expected width
  26961. * @param height defines the expected height
  26962. * @return a new canvas or offscreen canvas
  26963. */
  26964. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26965. }
  26966. }
  26967. declare module BABYLON {
  26968. /**
  26969. * Mesh representing the gorund
  26970. */
  26971. export class GroundMesh extends Mesh {
  26972. /** If octree should be generated */
  26973. generateOctree: boolean;
  26974. private _heightQuads;
  26975. /** @hidden */
  26976. _subdivisionsX: number;
  26977. /** @hidden */
  26978. _subdivisionsY: number;
  26979. /** @hidden */
  26980. _width: number;
  26981. /** @hidden */
  26982. _height: number;
  26983. /** @hidden */
  26984. _minX: number;
  26985. /** @hidden */
  26986. _maxX: number;
  26987. /** @hidden */
  26988. _minZ: number;
  26989. /** @hidden */
  26990. _maxZ: number;
  26991. constructor(name: string, scene: Scene);
  26992. /**
  26993. * "GroundMesh"
  26994. * @returns "GroundMesh"
  26995. */
  26996. getClassName(): string;
  26997. /**
  26998. * The minimum of x and y subdivisions
  26999. */
  27000. get subdivisions(): number;
  27001. /**
  27002. * X subdivisions
  27003. */
  27004. get subdivisionsX(): number;
  27005. /**
  27006. * Y subdivisions
  27007. */
  27008. get subdivisionsY(): number;
  27009. /**
  27010. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27011. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27012. * @param chunksCount the number of subdivisions for x and y
  27013. * @param octreeBlocksSize (Default: 32)
  27014. */
  27015. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27016. /**
  27017. * Returns a height (y) value in the Worl system :
  27018. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27019. * @param x x coordinate
  27020. * @param z z coordinate
  27021. * @returns the ground y position if (x, z) are outside the ground surface.
  27022. */
  27023. getHeightAtCoordinates(x: number, z: number): number;
  27024. /**
  27025. * Returns a normalized vector (Vector3) orthogonal to the ground
  27026. * at the ground coordinates (x, z) expressed in the World system.
  27027. * @param x x coordinate
  27028. * @param z z coordinate
  27029. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27030. */
  27031. getNormalAtCoordinates(x: number, z: number): Vector3;
  27032. /**
  27033. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27034. * at the ground coordinates (x, z) expressed in the World system.
  27035. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27036. * @param x x coordinate
  27037. * @param z z coordinate
  27038. * @param ref vector to store the result
  27039. * @returns the GroundMesh.
  27040. */
  27041. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27042. /**
  27043. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27044. * if the ground has been updated.
  27045. * This can be used in the render loop.
  27046. * @returns the GroundMesh.
  27047. */
  27048. updateCoordinateHeights(): GroundMesh;
  27049. private _getFacetAt;
  27050. private _initHeightQuads;
  27051. private _computeHeightQuads;
  27052. /**
  27053. * Serializes this ground mesh
  27054. * @param serializationObject object to write serialization to
  27055. */
  27056. serialize(serializationObject: any): void;
  27057. /**
  27058. * Parses a serialized ground mesh
  27059. * @param parsedMesh the serialized mesh
  27060. * @param scene the scene to create the ground mesh in
  27061. * @returns the created ground mesh
  27062. */
  27063. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27064. }
  27065. }
  27066. declare module BABYLON {
  27067. /**
  27068. * Interface for Physics-Joint data
  27069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27070. */
  27071. export interface PhysicsJointData {
  27072. /**
  27073. * The main pivot of the joint
  27074. */
  27075. mainPivot?: Vector3;
  27076. /**
  27077. * The connected pivot of the joint
  27078. */
  27079. connectedPivot?: Vector3;
  27080. /**
  27081. * The main axis of the joint
  27082. */
  27083. mainAxis?: Vector3;
  27084. /**
  27085. * The connected axis of the joint
  27086. */
  27087. connectedAxis?: Vector3;
  27088. /**
  27089. * The collision of the joint
  27090. */
  27091. collision?: boolean;
  27092. /**
  27093. * Native Oimo/Cannon/Energy data
  27094. */
  27095. nativeParams?: any;
  27096. }
  27097. /**
  27098. * This is a holder class for the physics joint created by the physics plugin
  27099. * It holds a set of functions to control the underlying joint
  27100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27101. */
  27102. export class PhysicsJoint {
  27103. /**
  27104. * The type of the physics joint
  27105. */
  27106. type: number;
  27107. /**
  27108. * The data for the physics joint
  27109. */
  27110. jointData: PhysicsJointData;
  27111. private _physicsJoint;
  27112. protected _physicsPlugin: IPhysicsEnginePlugin;
  27113. /**
  27114. * Initializes the physics joint
  27115. * @param type The type of the physics joint
  27116. * @param jointData The data for the physics joint
  27117. */
  27118. constructor(
  27119. /**
  27120. * The type of the physics joint
  27121. */
  27122. type: number,
  27123. /**
  27124. * The data for the physics joint
  27125. */
  27126. jointData: PhysicsJointData);
  27127. /**
  27128. * Gets the physics joint
  27129. */
  27130. get physicsJoint(): any;
  27131. /**
  27132. * Sets the physics joint
  27133. */
  27134. set physicsJoint(newJoint: any);
  27135. /**
  27136. * Sets the physics plugin
  27137. */
  27138. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27139. /**
  27140. * Execute a function that is physics-plugin specific.
  27141. * @param {Function} func the function that will be executed.
  27142. * It accepts two parameters: the physics world and the physics joint
  27143. */
  27144. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27145. /**
  27146. * Distance-Joint type
  27147. */
  27148. static DistanceJoint: number;
  27149. /**
  27150. * Hinge-Joint type
  27151. */
  27152. static HingeJoint: number;
  27153. /**
  27154. * Ball-and-Socket joint type
  27155. */
  27156. static BallAndSocketJoint: number;
  27157. /**
  27158. * Wheel-Joint type
  27159. */
  27160. static WheelJoint: number;
  27161. /**
  27162. * Slider-Joint type
  27163. */
  27164. static SliderJoint: number;
  27165. /**
  27166. * Prismatic-Joint type
  27167. */
  27168. static PrismaticJoint: number;
  27169. /**
  27170. * Universal-Joint type
  27171. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27172. */
  27173. static UniversalJoint: number;
  27174. /**
  27175. * Hinge-Joint 2 type
  27176. */
  27177. static Hinge2Joint: number;
  27178. /**
  27179. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27180. */
  27181. static PointToPointJoint: number;
  27182. /**
  27183. * Spring-Joint type
  27184. */
  27185. static SpringJoint: number;
  27186. /**
  27187. * Lock-Joint type
  27188. */
  27189. static LockJoint: number;
  27190. }
  27191. /**
  27192. * A class representing a physics distance joint
  27193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27194. */
  27195. export class DistanceJoint extends PhysicsJoint {
  27196. /**
  27197. *
  27198. * @param jointData The data for the Distance-Joint
  27199. */
  27200. constructor(jointData: DistanceJointData);
  27201. /**
  27202. * Update the predefined distance.
  27203. * @param maxDistance The maximum preferred distance
  27204. * @param minDistance The minimum preferred distance
  27205. */
  27206. updateDistance(maxDistance: number, minDistance?: number): void;
  27207. }
  27208. /**
  27209. * Represents a Motor-Enabled Joint
  27210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27211. */
  27212. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27213. /**
  27214. * Initializes the Motor-Enabled Joint
  27215. * @param type The type of the joint
  27216. * @param jointData The physica joint data for the joint
  27217. */
  27218. constructor(type: number, jointData: PhysicsJointData);
  27219. /**
  27220. * Set the motor values.
  27221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27222. * @param force the force to apply
  27223. * @param maxForce max force for this motor.
  27224. */
  27225. setMotor(force?: number, maxForce?: number): void;
  27226. /**
  27227. * Set the motor's limits.
  27228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27229. * @param upperLimit The upper limit of the motor
  27230. * @param lowerLimit The lower limit of the motor
  27231. */
  27232. setLimit(upperLimit: number, lowerLimit?: number): void;
  27233. }
  27234. /**
  27235. * This class represents a single physics Hinge-Joint
  27236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27237. */
  27238. export class HingeJoint extends MotorEnabledJoint {
  27239. /**
  27240. * Initializes the Hinge-Joint
  27241. * @param jointData The joint data for the Hinge-Joint
  27242. */
  27243. constructor(jointData: PhysicsJointData);
  27244. /**
  27245. * Set the motor values.
  27246. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27247. * @param {number} force the force to apply
  27248. * @param {number} maxForce max force for this motor.
  27249. */
  27250. setMotor(force?: number, maxForce?: number): void;
  27251. /**
  27252. * Set the motor's limits.
  27253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27254. * @param upperLimit The upper limit of the motor
  27255. * @param lowerLimit The lower limit of the motor
  27256. */
  27257. setLimit(upperLimit: number, lowerLimit?: number): void;
  27258. }
  27259. /**
  27260. * This class represents a dual hinge physics joint (same as wheel joint)
  27261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27262. */
  27263. export class Hinge2Joint extends MotorEnabledJoint {
  27264. /**
  27265. * Initializes the Hinge2-Joint
  27266. * @param jointData The joint data for the Hinge2-Joint
  27267. */
  27268. constructor(jointData: PhysicsJointData);
  27269. /**
  27270. * Set the motor values.
  27271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27272. * @param {number} targetSpeed the speed the motor is to reach
  27273. * @param {number} maxForce max force for this motor.
  27274. * @param {motorIndex} the motor's index, 0 or 1.
  27275. */
  27276. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27277. /**
  27278. * Set the motor limits.
  27279. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27280. * @param {number} upperLimit the upper limit
  27281. * @param {number} lowerLimit lower limit
  27282. * @param {motorIndex} the motor's index, 0 or 1.
  27283. */
  27284. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27285. }
  27286. /**
  27287. * Interface for a motor enabled joint
  27288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27289. */
  27290. export interface IMotorEnabledJoint {
  27291. /**
  27292. * Physics joint
  27293. */
  27294. physicsJoint: any;
  27295. /**
  27296. * Sets the motor of the motor-enabled joint
  27297. * @param force The force of the motor
  27298. * @param maxForce The maximum force of the motor
  27299. * @param motorIndex The index of the motor
  27300. */
  27301. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27302. /**
  27303. * Sets the limit of the motor
  27304. * @param upperLimit The upper limit of the motor
  27305. * @param lowerLimit The lower limit of the motor
  27306. * @param motorIndex The index of the motor
  27307. */
  27308. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27309. }
  27310. /**
  27311. * Joint data for a Distance-Joint
  27312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27313. */
  27314. export interface DistanceJointData extends PhysicsJointData {
  27315. /**
  27316. * Max distance the 2 joint objects can be apart
  27317. */
  27318. maxDistance: number;
  27319. }
  27320. /**
  27321. * Joint data from a spring joint
  27322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27323. */
  27324. export interface SpringJointData extends PhysicsJointData {
  27325. /**
  27326. * Length of the spring
  27327. */
  27328. length: number;
  27329. /**
  27330. * Stiffness of the spring
  27331. */
  27332. stiffness: number;
  27333. /**
  27334. * Damping of the spring
  27335. */
  27336. damping: number;
  27337. /** this callback will be called when applying the force to the impostors. */
  27338. forceApplicationCallback: () => void;
  27339. }
  27340. }
  27341. declare module BABYLON {
  27342. /**
  27343. * Holds the data for the raycast result
  27344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27345. */
  27346. export class PhysicsRaycastResult {
  27347. private _hasHit;
  27348. private _hitDistance;
  27349. private _hitNormalWorld;
  27350. private _hitPointWorld;
  27351. private _rayFromWorld;
  27352. private _rayToWorld;
  27353. /**
  27354. * Gets if there was a hit
  27355. */
  27356. get hasHit(): boolean;
  27357. /**
  27358. * Gets the distance from the hit
  27359. */
  27360. get hitDistance(): number;
  27361. /**
  27362. * Gets the hit normal/direction in the world
  27363. */
  27364. get hitNormalWorld(): Vector3;
  27365. /**
  27366. * Gets the hit point in the world
  27367. */
  27368. get hitPointWorld(): Vector3;
  27369. /**
  27370. * Gets the ray "start point" of the ray in the world
  27371. */
  27372. get rayFromWorld(): Vector3;
  27373. /**
  27374. * Gets the ray "end point" of the ray in the world
  27375. */
  27376. get rayToWorld(): Vector3;
  27377. /**
  27378. * Sets the hit data (normal & point in world space)
  27379. * @param hitNormalWorld defines the normal in world space
  27380. * @param hitPointWorld defines the point in world space
  27381. */
  27382. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27383. /**
  27384. * Sets the distance from the start point to the hit point
  27385. * @param distance
  27386. */
  27387. setHitDistance(distance: number): void;
  27388. /**
  27389. * Calculates the distance manually
  27390. */
  27391. calculateHitDistance(): void;
  27392. /**
  27393. * Resets all the values to default
  27394. * @param from The from point on world space
  27395. * @param to The to point on world space
  27396. */
  27397. reset(from?: Vector3, to?: Vector3): void;
  27398. }
  27399. /**
  27400. * Interface for the size containing width and height
  27401. */
  27402. interface IXYZ {
  27403. /**
  27404. * X
  27405. */
  27406. x: number;
  27407. /**
  27408. * Y
  27409. */
  27410. y: number;
  27411. /**
  27412. * Z
  27413. */
  27414. z: number;
  27415. }
  27416. }
  27417. declare module BABYLON {
  27418. /**
  27419. * Interface used to describe a physics joint
  27420. */
  27421. export interface PhysicsImpostorJoint {
  27422. /** Defines the main impostor to which the joint is linked */
  27423. mainImpostor: PhysicsImpostor;
  27424. /** Defines the impostor that is connected to the main impostor using this joint */
  27425. connectedImpostor: PhysicsImpostor;
  27426. /** Defines the joint itself */
  27427. joint: PhysicsJoint;
  27428. }
  27429. /** @hidden */
  27430. export interface IPhysicsEnginePlugin {
  27431. world: any;
  27432. name: string;
  27433. setGravity(gravity: Vector3): void;
  27434. setTimeStep(timeStep: number): void;
  27435. getTimeStep(): number;
  27436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27437. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27438. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27440. removePhysicsBody(impostor: PhysicsImpostor): void;
  27441. generateJoint(joint: PhysicsImpostorJoint): void;
  27442. removeJoint(joint: PhysicsImpostorJoint): void;
  27443. isSupported(): boolean;
  27444. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27445. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27446. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27447. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27448. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27449. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27450. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27451. getBodyMass(impostor: PhysicsImpostor): number;
  27452. getBodyFriction(impostor: PhysicsImpostor): number;
  27453. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27454. getBodyRestitution(impostor: PhysicsImpostor): number;
  27455. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27456. getBodyPressure?(impostor: PhysicsImpostor): number;
  27457. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27458. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27459. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27460. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27461. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27462. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27463. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27464. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27465. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27466. sleepBody(impostor: PhysicsImpostor): void;
  27467. wakeUpBody(impostor: PhysicsImpostor): void;
  27468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27469. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27470. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27471. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27472. getRadius(impostor: PhysicsImpostor): number;
  27473. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27474. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27475. dispose(): void;
  27476. }
  27477. /**
  27478. * Interface used to define a physics engine
  27479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27480. */
  27481. export interface IPhysicsEngine {
  27482. /**
  27483. * Gets the gravity vector used by the simulation
  27484. */
  27485. gravity: Vector3;
  27486. /**
  27487. * Sets the gravity vector used by the simulation
  27488. * @param gravity defines the gravity vector to use
  27489. */
  27490. setGravity(gravity: Vector3): void;
  27491. /**
  27492. * Set the time step of the physics engine.
  27493. * Default is 1/60.
  27494. * To slow it down, enter 1/600 for example.
  27495. * To speed it up, 1/30
  27496. * @param newTimeStep the new timestep to apply to this world.
  27497. */
  27498. setTimeStep(newTimeStep: number): void;
  27499. /**
  27500. * Get the time step of the physics engine.
  27501. * @returns the current time step
  27502. */
  27503. getTimeStep(): number;
  27504. /**
  27505. * Set the sub time step of the physics engine.
  27506. * Default is 0 meaning there is no sub steps
  27507. * To increase physics resolution precision, set a small value (like 1 ms)
  27508. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27509. */
  27510. setSubTimeStep(subTimeStep: number): void;
  27511. /**
  27512. * Get the sub time step of the physics engine.
  27513. * @returns the current sub time step
  27514. */
  27515. getSubTimeStep(): number;
  27516. /**
  27517. * Release all resources
  27518. */
  27519. dispose(): void;
  27520. /**
  27521. * Gets the name of the current physics plugin
  27522. * @returns the name of the plugin
  27523. */
  27524. getPhysicsPluginName(): string;
  27525. /**
  27526. * Adding a new impostor for the impostor tracking.
  27527. * This will be done by the impostor itself.
  27528. * @param impostor the impostor to add
  27529. */
  27530. addImpostor(impostor: PhysicsImpostor): void;
  27531. /**
  27532. * Remove an impostor from the engine.
  27533. * This impostor and its mesh will not longer be updated by the physics engine.
  27534. * @param impostor the impostor to remove
  27535. */
  27536. removeImpostor(impostor: PhysicsImpostor): void;
  27537. /**
  27538. * Add a joint to the physics engine
  27539. * @param mainImpostor defines the main impostor to which the joint is added.
  27540. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27541. * @param joint defines the joint that will connect both impostors.
  27542. */
  27543. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27544. /**
  27545. * Removes a joint from the simulation
  27546. * @param mainImpostor defines the impostor used with the joint
  27547. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27548. * @param joint defines the joint to remove
  27549. */
  27550. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27551. /**
  27552. * Gets the current plugin used to run the simulation
  27553. * @returns current plugin
  27554. */
  27555. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27556. /**
  27557. * Gets the list of physic impostors
  27558. * @returns an array of PhysicsImpostor
  27559. */
  27560. getImpostors(): Array<PhysicsImpostor>;
  27561. /**
  27562. * Gets the impostor for a physics enabled object
  27563. * @param object defines the object impersonated by the impostor
  27564. * @returns the PhysicsImpostor or null if not found
  27565. */
  27566. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27567. /**
  27568. * Gets the impostor for a physics body object
  27569. * @param body defines physics body used by the impostor
  27570. * @returns the PhysicsImpostor or null if not found
  27571. */
  27572. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27573. /**
  27574. * Does a raycast in the physics world
  27575. * @param from when should the ray start?
  27576. * @param to when should the ray end?
  27577. * @returns PhysicsRaycastResult
  27578. */
  27579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27580. /**
  27581. * Called by the scene. No need to call it.
  27582. * @param delta defines the timespam between frames
  27583. */
  27584. _step(delta: number): void;
  27585. }
  27586. }
  27587. declare module BABYLON {
  27588. /**
  27589. * The interface for the physics imposter parameters
  27590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27591. */
  27592. export interface PhysicsImpostorParameters {
  27593. /**
  27594. * The mass of the physics imposter
  27595. */
  27596. mass: number;
  27597. /**
  27598. * The friction of the physics imposter
  27599. */
  27600. friction?: number;
  27601. /**
  27602. * The coefficient of restitution of the physics imposter
  27603. */
  27604. restitution?: number;
  27605. /**
  27606. * The native options of the physics imposter
  27607. */
  27608. nativeOptions?: any;
  27609. /**
  27610. * Specifies if the parent should be ignored
  27611. */
  27612. ignoreParent?: boolean;
  27613. /**
  27614. * Specifies if bi-directional transformations should be disabled
  27615. */
  27616. disableBidirectionalTransformation?: boolean;
  27617. /**
  27618. * The pressure inside the physics imposter, soft object only
  27619. */
  27620. pressure?: number;
  27621. /**
  27622. * The stiffness the physics imposter, soft object only
  27623. */
  27624. stiffness?: number;
  27625. /**
  27626. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27627. */
  27628. velocityIterations?: number;
  27629. /**
  27630. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27631. */
  27632. positionIterations?: number;
  27633. /**
  27634. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27635. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27636. * Add to fix multiple points
  27637. */
  27638. fixedPoints?: number;
  27639. /**
  27640. * The collision margin around a soft object
  27641. */
  27642. margin?: number;
  27643. /**
  27644. * The collision margin around a soft object
  27645. */
  27646. damping?: number;
  27647. /**
  27648. * The path for a rope based on an extrusion
  27649. */
  27650. path?: any;
  27651. /**
  27652. * The shape of an extrusion used for a rope based on an extrusion
  27653. */
  27654. shape?: any;
  27655. }
  27656. /**
  27657. * Interface for a physics-enabled object
  27658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27659. */
  27660. export interface IPhysicsEnabledObject {
  27661. /**
  27662. * The position of the physics-enabled object
  27663. */
  27664. position: Vector3;
  27665. /**
  27666. * The rotation of the physics-enabled object
  27667. */
  27668. rotationQuaternion: Nullable<Quaternion>;
  27669. /**
  27670. * The scale of the physics-enabled object
  27671. */
  27672. scaling: Vector3;
  27673. /**
  27674. * The rotation of the physics-enabled object
  27675. */
  27676. rotation?: Vector3;
  27677. /**
  27678. * The parent of the physics-enabled object
  27679. */
  27680. parent?: any;
  27681. /**
  27682. * The bounding info of the physics-enabled object
  27683. * @returns The bounding info of the physics-enabled object
  27684. */
  27685. getBoundingInfo(): BoundingInfo;
  27686. /**
  27687. * Computes the world matrix
  27688. * @param force Specifies if the world matrix should be computed by force
  27689. * @returns A world matrix
  27690. */
  27691. computeWorldMatrix(force: boolean): Matrix;
  27692. /**
  27693. * Gets the world matrix
  27694. * @returns A world matrix
  27695. */
  27696. getWorldMatrix?(): Matrix;
  27697. /**
  27698. * Gets the child meshes
  27699. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27700. * @returns An array of abstract meshes
  27701. */
  27702. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27703. /**
  27704. * Gets the vertex data
  27705. * @param kind The type of vertex data
  27706. * @returns A nullable array of numbers, or a float32 array
  27707. */
  27708. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27709. /**
  27710. * Gets the indices from the mesh
  27711. * @returns A nullable array of index arrays
  27712. */
  27713. getIndices?(): Nullable<IndicesArray>;
  27714. /**
  27715. * Gets the scene from the mesh
  27716. * @returns the indices array or null
  27717. */
  27718. getScene?(): Scene;
  27719. /**
  27720. * Gets the absolute position from the mesh
  27721. * @returns the absolute position
  27722. */
  27723. getAbsolutePosition(): Vector3;
  27724. /**
  27725. * Gets the absolute pivot point from the mesh
  27726. * @returns the absolute pivot point
  27727. */
  27728. getAbsolutePivotPoint(): Vector3;
  27729. /**
  27730. * Rotates the mesh
  27731. * @param axis The axis of rotation
  27732. * @param amount The amount of rotation
  27733. * @param space The space of the rotation
  27734. * @returns The rotation transform node
  27735. */
  27736. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27737. /**
  27738. * Translates the mesh
  27739. * @param axis The axis of translation
  27740. * @param distance The distance of translation
  27741. * @param space The space of the translation
  27742. * @returns The transform node
  27743. */
  27744. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27745. /**
  27746. * Sets the absolute position of the mesh
  27747. * @param absolutePosition The absolute position of the mesh
  27748. * @returns The transform node
  27749. */
  27750. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27751. /**
  27752. * Gets the class name of the mesh
  27753. * @returns The class name
  27754. */
  27755. getClassName(): string;
  27756. }
  27757. /**
  27758. * Represents a physics imposter
  27759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27760. */
  27761. export class PhysicsImpostor {
  27762. /**
  27763. * The physics-enabled object used as the physics imposter
  27764. */
  27765. object: IPhysicsEnabledObject;
  27766. /**
  27767. * The type of the physics imposter
  27768. */
  27769. type: number;
  27770. private _options;
  27771. private _scene?;
  27772. /**
  27773. * The default object size of the imposter
  27774. */
  27775. static DEFAULT_OBJECT_SIZE: Vector3;
  27776. /**
  27777. * The identity quaternion of the imposter
  27778. */
  27779. static IDENTITY_QUATERNION: Quaternion;
  27780. /** @hidden */
  27781. _pluginData: any;
  27782. private _physicsEngine;
  27783. private _physicsBody;
  27784. private _bodyUpdateRequired;
  27785. private _onBeforePhysicsStepCallbacks;
  27786. private _onAfterPhysicsStepCallbacks;
  27787. /** @hidden */
  27788. _onPhysicsCollideCallbacks: Array<{
  27789. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27790. otherImpostors: Array<PhysicsImpostor>;
  27791. }>;
  27792. private _deltaPosition;
  27793. private _deltaRotation;
  27794. private _deltaRotationConjugated;
  27795. /** @hidden */
  27796. _isFromLine: boolean;
  27797. private _parent;
  27798. private _isDisposed;
  27799. private static _tmpVecs;
  27800. private static _tmpQuat;
  27801. /**
  27802. * Specifies if the physics imposter is disposed
  27803. */
  27804. get isDisposed(): boolean;
  27805. /**
  27806. * Gets the mass of the physics imposter
  27807. */
  27808. get mass(): number;
  27809. set mass(value: number);
  27810. /**
  27811. * Gets the coefficient of friction
  27812. */
  27813. get friction(): number;
  27814. /**
  27815. * Sets the coefficient of friction
  27816. */
  27817. set friction(value: number);
  27818. /**
  27819. * Gets the coefficient of restitution
  27820. */
  27821. get restitution(): number;
  27822. /**
  27823. * Sets the coefficient of restitution
  27824. */
  27825. set restitution(value: number);
  27826. /**
  27827. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27828. */
  27829. get pressure(): number;
  27830. /**
  27831. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27832. */
  27833. set pressure(value: number);
  27834. /**
  27835. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27836. */
  27837. get stiffness(): number;
  27838. /**
  27839. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27840. */
  27841. set stiffness(value: number);
  27842. /**
  27843. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27844. */
  27845. get velocityIterations(): number;
  27846. /**
  27847. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27848. */
  27849. set velocityIterations(value: number);
  27850. /**
  27851. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27852. */
  27853. get positionIterations(): number;
  27854. /**
  27855. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27856. */
  27857. set positionIterations(value: number);
  27858. /**
  27859. * The unique id of the physics imposter
  27860. * set by the physics engine when adding this impostor to the array
  27861. */
  27862. uniqueId: number;
  27863. /**
  27864. * @hidden
  27865. */
  27866. soft: boolean;
  27867. /**
  27868. * @hidden
  27869. */
  27870. segments: number;
  27871. private _joints;
  27872. /**
  27873. * Initializes the physics imposter
  27874. * @param object The physics-enabled object used as the physics imposter
  27875. * @param type The type of the physics imposter
  27876. * @param _options The options for the physics imposter
  27877. * @param _scene The Babylon scene
  27878. */
  27879. constructor(
  27880. /**
  27881. * The physics-enabled object used as the physics imposter
  27882. */
  27883. object: IPhysicsEnabledObject,
  27884. /**
  27885. * The type of the physics imposter
  27886. */
  27887. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27888. /**
  27889. * This function will completly initialize this impostor.
  27890. * It will create a new body - but only if this mesh has no parent.
  27891. * If it has, this impostor will not be used other than to define the impostor
  27892. * of the child mesh.
  27893. * @hidden
  27894. */
  27895. _init(): void;
  27896. private _getPhysicsParent;
  27897. /**
  27898. * Should a new body be generated.
  27899. * @returns boolean specifying if body initialization is required
  27900. */
  27901. isBodyInitRequired(): boolean;
  27902. /**
  27903. * Sets the updated scaling
  27904. * @param updated Specifies if the scaling is updated
  27905. */
  27906. setScalingUpdated(): void;
  27907. /**
  27908. * Force a regeneration of this or the parent's impostor's body.
  27909. * Use under cautious - This will remove all joints already implemented.
  27910. */
  27911. forceUpdate(): void;
  27912. /**
  27913. * Gets the body that holds this impostor. Either its own, or its parent.
  27914. */
  27915. get physicsBody(): any;
  27916. /**
  27917. * Get the parent of the physics imposter
  27918. * @returns Physics imposter or null
  27919. */
  27920. get parent(): Nullable<PhysicsImpostor>;
  27921. /**
  27922. * Sets the parent of the physics imposter
  27923. */
  27924. set parent(value: Nullable<PhysicsImpostor>);
  27925. /**
  27926. * Set the physics body. Used mainly by the physics engine/plugin
  27927. */
  27928. set physicsBody(physicsBody: any);
  27929. /**
  27930. * Resets the update flags
  27931. */
  27932. resetUpdateFlags(): void;
  27933. /**
  27934. * Gets the object extend size
  27935. * @returns the object extend size
  27936. */
  27937. getObjectExtendSize(): Vector3;
  27938. /**
  27939. * Gets the object center
  27940. * @returns The object center
  27941. */
  27942. getObjectCenter(): Vector3;
  27943. /**
  27944. * Get a specific parameter from the options parameters
  27945. * @param paramName The object parameter name
  27946. * @returns The object parameter
  27947. */
  27948. getParam(paramName: string): any;
  27949. /**
  27950. * Sets a specific parameter in the options given to the physics plugin
  27951. * @param paramName The parameter name
  27952. * @param value The value of the parameter
  27953. */
  27954. setParam(paramName: string, value: number): void;
  27955. /**
  27956. * Specifically change the body's mass option. Won't recreate the physics body object
  27957. * @param mass The mass of the physics imposter
  27958. */
  27959. setMass(mass: number): void;
  27960. /**
  27961. * Gets the linear velocity
  27962. * @returns linear velocity or null
  27963. */
  27964. getLinearVelocity(): Nullable<Vector3>;
  27965. /**
  27966. * Sets the linear velocity
  27967. * @param velocity linear velocity or null
  27968. */
  27969. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27970. /**
  27971. * Gets the angular velocity
  27972. * @returns angular velocity or null
  27973. */
  27974. getAngularVelocity(): Nullable<Vector3>;
  27975. /**
  27976. * Sets the angular velocity
  27977. * @param velocity The velocity or null
  27978. */
  27979. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27980. /**
  27981. * Execute a function with the physics plugin native code
  27982. * Provide a function the will have two variables - the world object and the physics body object
  27983. * @param func The function to execute with the physics plugin native code
  27984. */
  27985. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27986. /**
  27987. * Register a function that will be executed before the physics world is stepping forward
  27988. * @param func The function to execute before the physics world is stepped forward
  27989. */
  27990. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27991. /**
  27992. * Unregister a function that will be executed before the physics world is stepping forward
  27993. * @param func The function to execute before the physics world is stepped forward
  27994. */
  27995. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27996. /**
  27997. * Register a function that will be executed after the physics step
  27998. * @param func The function to execute after physics step
  27999. */
  28000. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28001. /**
  28002. * Unregisters a function that will be executed after the physics step
  28003. * @param func The function to execute after physics step
  28004. */
  28005. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28006. /**
  28007. * register a function that will be executed when this impostor collides against a different body
  28008. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28009. * @param func Callback that is executed on collision
  28010. */
  28011. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28012. /**
  28013. * Unregisters the physics imposter on contact
  28014. * @param collideAgainst The physics object to collide against
  28015. * @param func Callback to execute on collision
  28016. */
  28017. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28018. private _tmpQuat;
  28019. private _tmpQuat2;
  28020. /**
  28021. * Get the parent rotation
  28022. * @returns The parent rotation
  28023. */
  28024. getParentsRotation(): Quaternion;
  28025. /**
  28026. * this function is executed by the physics engine.
  28027. */
  28028. beforeStep: () => void;
  28029. /**
  28030. * this function is executed by the physics engine
  28031. */
  28032. afterStep: () => void;
  28033. /**
  28034. * Legacy collision detection event support
  28035. */
  28036. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28037. /**
  28038. * event and body object due to cannon's event-based architecture.
  28039. */
  28040. onCollide: (e: {
  28041. body: any;
  28042. }) => void;
  28043. /**
  28044. * Apply a force
  28045. * @param force The force to apply
  28046. * @param contactPoint The contact point for the force
  28047. * @returns The physics imposter
  28048. */
  28049. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28050. /**
  28051. * Apply an impulse
  28052. * @param force The impulse force
  28053. * @param contactPoint The contact point for the impulse force
  28054. * @returns The physics imposter
  28055. */
  28056. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28057. /**
  28058. * A help function to create a joint
  28059. * @param otherImpostor A physics imposter used to create a joint
  28060. * @param jointType The type of joint
  28061. * @param jointData The data for the joint
  28062. * @returns The physics imposter
  28063. */
  28064. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28065. /**
  28066. * Add a joint to this impostor with a different impostor
  28067. * @param otherImpostor A physics imposter used to add a joint
  28068. * @param joint The joint to add
  28069. * @returns The physics imposter
  28070. */
  28071. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28072. /**
  28073. * Add an anchor to a cloth impostor
  28074. * @param otherImpostor rigid impostor to anchor to
  28075. * @param width ratio across width from 0 to 1
  28076. * @param height ratio up height from 0 to 1
  28077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28078. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28079. * @returns impostor the soft imposter
  28080. */
  28081. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28082. /**
  28083. * Add a hook to a rope impostor
  28084. * @param otherImpostor rigid impostor to anchor to
  28085. * @param length ratio across rope from 0 to 1
  28086. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28088. * @returns impostor the rope imposter
  28089. */
  28090. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28091. /**
  28092. * Will keep this body still, in a sleep mode.
  28093. * @returns the physics imposter
  28094. */
  28095. sleep(): PhysicsImpostor;
  28096. /**
  28097. * Wake the body up.
  28098. * @returns The physics imposter
  28099. */
  28100. wakeUp(): PhysicsImpostor;
  28101. /**
  28102. * Clones the physics imposter
  28103. * @param newObject The physics imposter clones to this physics-enabled object
  28104. * @returns A nullable physics imposter
  28105. */
  28106. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28107. /**
  28108. * Disposes the physics imposter
  28109. */
  28110. dispose(): void;
  28111. /**
  28112. * Sets the delta position
  28113. * @param position The delta position amount
  28114. */
  28115. setDeltaPosition(position: Vector3): void;
  28116. /**
  28117. * Sets the delta rotation
  28118. * @param rotation The delta rotation amount
  28119. */
  28120. setDeltaRotation(rotation: Quaternion): void;
  28121. /**
  28122. * Gets the box size of the physics imposter and stores the result in the input parameter
  28123. * @param result Stores the box size
  28124. * @returns The physics imposter
  28125. */
  28126. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28127. /**
  28128. * Gets the radius of the physics imposter
  28129. * @returns Radius of the physics imposter
  28130. */
  28131. getRadius(): number;
  28132. /**
  28133. * Sync a bone with this impostor
  28134. * @param bone The bone to sync to the impostor.
  28135. * @param boneMesh The mesh that the bone is influencing.
  28136. * @param jointPivot The pivot of the joint / bone in local space.
  28137. * @param distToJoint Optional distance from the impostor to the joint.
  28138. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28139. */
  28140. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28141. /**
  28142. * Sync impostor to a bone
  28143. * @param bone The bone that the impostor will be synced to.
  28144. * @param boneMesh The mesh that the bone is influencing.
  28145. * @param jointPivot The pivot of the joint / bone in local space.
  28146. * @param distToJoint Optional distance from the impostor to the joint.
  28147. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28148. * @param boneAxis Optional vector3 axis the bone is aligned with
  28149. */
  28150. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28151. /**
  28152. * No-Imposter type
  28153. */
  28154. static NoImpostor: number;
  28155. /**
  28156. * Sphere-Imposter type
  28157. */
  28158. static SphereImpostor: number;
  28159. /**
  28160. * Box-Imposter type
  28161. */
  28162. static BoxImpostor: number;
  28163. /**
  28164. * Plane-Imposter type
  28165. */
  28166. static PlaneImpostor: number;
  28167. /**
  28168. * Mesh-imposter type
  28169. */
  28170. static MeshImpostor: number;
  28171. /**
  28172. * Capsule-Impostor type (Ammo.js plugin only)
  28173. */
  28174. static CapsuleImpostor: number;
  28175. /**
  28176. * Cylinder-Imposter type
  28177. */
  28178. static CylinderImpostor: number;
  28179. /**
  28180. * Particle-Imposter type
  28181. */
  28182. static ParticleImpostor: number;
  28183. /**
  28184. * Heightmap-Imposter type
  28185. */
  28186. static HeightmapImpostor: number;
  28187. /**
  28188. * ConvexHull-Impostor type (Ammo.js plugin only)
  28189. */
  28190. static ConvexHullImpostor: number;
  28191. /**
  28192. * Custom-Imposter type (Ammo.js plugin only)
  28193. */
  28194. static CustomImpostor: number;
  28195. /**
  28196. * Rope-Imposter type
  28197. */
  28198. static RopeImpostor: number;
  28199. /**
  28200. * Cloth-Imposter type
  28201. */
  28202. static ClothImpostor: number;
  28203. /**
  28204. * Softbody-Imposter type
  28205. */
  28206. static SoftbodyImpostor: number;
  28207. }
  28208. }
  28209. declare module BABYLON {
  28210. /**
  28211. * @hidden
  28212. **/
  28213. export class _CreationDataStorage {
  28214. closePath?: boolean;
  28215. closeArray?: boolean;
  28216. idx: number[];
  28217. dashSize: number;
  28218. gapSize: number;
  28219. path3D: Path3D;
  28220. pathArray: Vector3[][];
  28221. arc: number;
  28222. radius: number;
  28223. cap: number;
  28224. tessellation: number;
  28225. }
  28226. /**
  28227. * @hidden
  28228. **/
  28229. class _InstanceDataStorage {
  28230. visibleInstances: any;
  28231. batchCache: _InstancesBatch;
  28232. instancesBufferSize: number;
  28233. instancesBuffer: Nullable<Buffer>;
  28234. instancesData: Float32Array;
  28235. overridenInstanceCount: number;
  28236. isFrozen: boolean;
  28237. previousBatch: Nullable<_InstancesBatch>;
  28238. hardwareInstancedRendering: boolean;
  28239. sideOrientation: number;
  28240. manualUpdate: boolean;
  28241. previousRenderId: number;
  28242. }
  28243. /**
  28244. * @hidden
  28245. **/
  28246. export class _InstancesBatch {
  28247. mustReturn: boolean;
  28248. visibleInstances: Nullable<InstancedMesh[]>[];
  28249. renderSelf: boolean[];
  28250. hardwareInstancedRendering: boolean[];
  28251. }
  28252. /**
  28253. * @hidden
  28254. **/
  28255. class _ThinInstanceDataStorage {
  28256. instancesCount: number;
  28257. matrixBuffer: Nullable<Buffer>;
  28258. matrixBufferSize: number;
  28259. matrixData: Nullable<Float32Array>;
  28260. boundingVectors: Array<Vector3>;
  28261. worldMatrices: Nullable<Matrix[]>;
  28262. }
  28263. /**
  28264. * Class used to represent renderable models
  28265. */
  28266. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28267. /**
  28268. * Mesh side orientation : usually the external or front surface
  28269. */
  28270. static readonly FRONTSIDE: number;
  28271. /**
  28272. * Mesh side orientation : usually the internal or back surface
  28273. */
  28274. static readonly BACKSIDE: number;
  28275. /**
  28276. * Mesh side orientation : both internal and external or front and back surfaces
  28277. */
  28278. static readonly DOUBLESIDE: number;
  28279. /**
  28280. * Mesh side orientation : by default, `FRONTSIDE`
  28281. */
  28282. static readonly DEFAULTSIDE: number;
  28283. /**
  28284. * Mesh cap setting : no cap
  28285. */
  28286. static readonly NO_CAP: number;
  28287. /**
  28288. * Mesh cap setting : one cap at the beginning of the mesh
  28289. */
  28290. static readonly CAP_START: number;
  28291. /**
  28292. * Mesh cap setting : one cap at the end of the mesh
  28293. */
  28294. static readonly CAP_END: number;
  28295. /**
  28296. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28297. */
  28298. static readonly CAP_ALL: number;
  28299. /**
  28300. * Mesh pattern setting : no flip or rotate
  28301. */
  28302. static readonly NO_FLIP: number;
  28303. /**
  28304. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28305. */
  28306. static readonly FLIP_TILE: number;
  28307. /**
  28308. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28309. */
  28310. static readonly ROTATE_TILE: number;
  28311. /**
  28312. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28313. */
  28314. static readonly FLIP_ROW: number;
  28315. /**
  28316. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28317. */
  28318. static readonly ROTATE_ROW: number;
  28319. /**
  28320. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28321. */
  28322. static readonly FLIP_N_ROTATE_TILE: number;
  28323. /**
  28324. * Mesh pattern setting : rotate pattern and rotate
  28325. */
  28326. static readonly FLIP_N_ROTATE_ROW: number;
  28327. /**
  28328. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28329. */
  28330. static readonly CENTER: number;
  28331. /**
  28332. * Mesh tile positioning : part tiles on left
  28333. */
  28334. static readonly LEFT: number;
  28335. /**
  28336. * Mesh tile positioning : part tiles on right
  28337. */
  28338. static readonly RIGHT: number;
  28339. /**
  28340. * Mesh tile positioning : part tiles on top
  28341. */
  28342. static readonly TOP: number;
  28343. /**
  28344. * Mesh tile positioning : part tiles on bottom
  28345. */
  28346. static readonly BOTTOM: number;
  28347. /**
  28348. * Gets the default side orientation.
  28349. * @param orientation the orientation to value to attempt to get
  28350. * @returns the default orientation
  28351. * @hidden
  28352. */
  28353. static _GetDefaultSideOrientation(orientation?: number): number;
  28354. private _internalMeshDataInfo;
  28355. get computeBonesUsingShaders(): boolean;
  28356. set computeBonesUsingShaders(value: boolean);
  28357. /**
  28358. * An event triggered before rendering the mesh
  28359. */
  28360. get onBeforeRenderObservable(): Observable<Mesh>;
  28361. /**
  28362. * An event triggered before binding the mesh
  28363. */
  28364. get onBeforeBindObservable(): Observable<Mesh>;
  28365. /**
  28366. * An event triggered after rendering the mesh
  28367. */
  28368. get onAfterRenderObservable(): Observable<Mesh>;
  28369. /**
  28370. * An event triggered before drawing the mesh
  28371. */
  28372. get onBeforeDrawObservable(): Observable<Mesh>;
  28373. private _onBeforeDrawObserver;
  28374. /**
  28375. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28376. */
  28377. set onBeforeDraw(callback: () => void);
  28378. get hasInstances(): boolean;
  28379. get hasThinInstances(): boolean;
  28380. /**
  28381. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28382. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28383. */
  28384. delayLoadState: number;
  28385. /**
  28386. * Gets the list of instances created from this mesh
  28387. * it is not supposed to be modified manually.
  28388. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28389. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28390. */
  28391. instances: InstancedMesh[];
  28392. /**
  28393. * Gets the file containing delay loading data for this mesh
  28394. */
  28395. delayLoadingFile: string;
  28396. /** @hidden */
  28397. _binaryInfo: any;
  28398. /**
  28399. * User defined function used to change how LOD level selection is done
  28400. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28401. */
  28402. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28403. /**
  28404. * Gets or sets the morph target manager
  28405. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28406. */
  28407. get morphTargetManager(): Nullable<MorphTargetManager>;
  28408. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28409. /** @hidden */
  28410. _creationDataStorage: Nullable<_CreationDataStorage>;
  28411. /** @hidden */
  28412. _geometry: Nullable<Geometry>;
  28413. /** @hidden */
  28414. _delayInfo: Array<string>;
  28415. /** @hidden */
  28416. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28417. /** @hidden */
  28418. _instanceDataStorage: _InstanceDataStorage;
  28419. /** @hidden */
  28420. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28421. private _effectiveMaterial;
  28422. /** @hidden */
  28423. _shouldGenerateFlatShading: boolean;
  28424. /** @hidden */
  28425. _originalBuilderSideOrientation: number;
  28426. /**
  28427. * Use this property to change the original side orientation defined at construction time
  28428. */
  28429. overrideMaterialSideOrientation: Nullable<number>;
  28430. /**
  28431. * Gets the source mesh (the one used to clone this one from)
  28432. */
  28433. get source(): Nullable<Mesh>;
  28434. /**
  28435. * Gets the list of clones of this mesh
  28436. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28437. * Note that useClonedMeshMap=true is the default setting
  28438. */
  28439. get cloneMeshMap(): Nullable<{
  28440. [id: string]: Mesh | undefined;
  28441. }>;
  28442. /**
  28443. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28444. */
  28445. get isUnIndexed(): boolean;
  28446. set isUnIndexed(value: boolean);
  28447. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28448. get worldMatrixInstancedBuffer(): Float32Array;
  28449. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28450. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28451. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28452. /**
  28453. * @constructor
  28454. * @param name The value used by scene.getMeshByName() to do a lookup.
  28455. * @param scene The scene to add this mesh to.
  28456. * @param parent The parent of this mesh, if it has one
  28457. * @param source An optional Mesh from which geometry is shared, cloned.
  28458. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28459. * When false, achieved by calling a clone(), also passing False.
  28460. * This will make creation of children, recursive.
  28461. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28462. */
  28463. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28464. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28465. doNotInstantiate: boolean;
  28466. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28467. /**
  28468. * Gets the class name
  28469. * @returns the string "Mesh".
  28470. */
  28471. getClassName(): string;
  28472. /** @hidden */
  28473. get _isMesh(): boolean;
  28474. /**
  28475. * Returns a description of this mesh
  28476. * @param fullDetails define if full details about this mesh must be used
  28477. * @returns a descriptive string representing this mesh
  28478. */
  28479. toString(fullDetails?: boolean): string;
  28480. /** @hidden */
  28481. _unBindEffect(): void;
  28482. /**
  28483. * Gets a boolean indicating if this mesh has LOD
  28484. */
  28485. get hasLODLevels(): boolean;
  28486. /**
  28487. * Gets the list of MeshLODLevel associated with the current mesh
  28488. * @returns an array of MeshLODLevel
  28489. */
  28490. getLODLevels(): MeshLODLevel[];
  28491. private _sortLODLevels;
  28492. /**
  28493. * Add a mesh as LOD level triggered at the given distance.
  28494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28495. * @param distance The distance from the center of the object to show this level
  28496. * @param mesh The mesh to be added as LOD level (can be null)
  28497. * @return This mesh (for chaining)
  28498. */
  28499. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28500. /**
  28501. * Returns the LOD level mesh at the passed distance or null if not found.
  28502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28503. * @param distance The distance from the center of the object to show this level
  28504. * @returns a Mesh or `null`
  28505. */
  28506. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28507. /**
  28508. * Remove a mesh from the LOD array
  28509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28510. * @param mesh defines the mesh to be removed
  28511. * @return This mesh (for chaining)
  28512. */
  28513. removeLODLevel(mesh: Mesh): Mesh;
  28514. /**
  28515. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28517. * @param camera defines the camera to use to compute distance
  28518. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28519. * @return This mesh (for chaining)
  28520. */
  28521. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28522. /**
  28523. * Gets the mesh internal Geometry object
  28524. */
  28525. get geometry(): Nullable<Geometry>;
  28526. /**
  28527. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28528. * @returns the total number of vertices
  28529. */
  28530. getTotalVertices(): number;
  28531. /**
  28532. * Returns the content of an associated vertex buffer
  28533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28534. * - VertexBuffer.PositionKind
  28535. * - VertexBuffer.UVKind
  28536. * - VertexBuffer.UV2Kind
  28537. * - VertexBuffer.UV3Kind
  28538. * - VertexBuffer.UV4Kind
  28539. * - VertexBuffer.UV5Kind
  28540. * - VertexBuffer.UV6Kind
  28541. * - VertexBuffer.ColorKind
  28542. * - VertexBuffer.MatricesIndicesKind
  28543. * - VertexBuffer.MatricesIndicesExtraKind
  28544. * - VertexBuffer.MatricesWeightsKind
  28545. * - VertexBuffer.MatricesWeightsExtraKind
  28546. * @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
  28547. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28548. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28549. */
  28550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28551. /**
  28552. * Returns the mesh VertexBuffer object from the requested `kind`
  28553. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28554. * - VertexBuffer.PositionKind
  28555. * - VertexBuffer.NormalKind
  28556. * - VertexBuffer.UVKind
  28557. * - VertexBuffer.UV2Kind
  28558. * - VertexBuffer.UV3Kind
  28559. * - VertexBuffer.UV4Kind
  28560. * - VertexBuffer.UV5Kind
  28561. * - VertexBuffer.UV6Kind
  28562. * - VertexBuffer.ColorKind
  28563. * - VertexBuffer.MatricesIndicesKind
  28564. * - VertexBuffer.MatricesIndicesExtraKind
  28565. * - VertexBuffer.MatricesWeightsKind
  28566. * - VertexBuffer.MatricesWeightsExtraKind
  28567. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28568. */
  28569. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28570. /**
  28571. * Tests if a specific vertex buffer is associated with this mesh
  28572. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28573. * - VertexBuffer.PositionKind
  28574. * - VertexBuffer.NormalKind
  28575. * - VertexBuffer.UVKind
  28576. * - VertexBuffer.UV2Kind
  28577. * - VertexBuffer.UV3Kind
  28578. * - VertexBuffer.UV4Kind
  28579. * - VertexBuffer.UV5Kind
  28580. * - VertexBuffer.UV6Kind
  28581. * - VertexBuffer.ColorKind
  28582. * - VertexBuffer.MatricesIndicesKind
  28583. * - VertexBuffer.MatricesIndicesExtraKind
  28584. * - VertexBuffer.MatricesWeightsKind
  28585. * - VertexBuffer.MatricesWeightsExtraKind
  28586. * @returns a boolean
  28587. */
  28588. isVerticesDataPresent(kind: string): boolean;
  28589. /**
  28590. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28591. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28592. * - VertexBuffer.PositionKind
  28593. * - VertexBuffer.UVKind
  28594. * - VertexBuffer.UV2Kind
  28595. * - VertexBuffer.UV3Kind
  28596. * - VertexBuffer.UV4Kind
  28597. * - VertexBuffer.UV5Kind
  28598. * - VertexBuffer.UV6Kind
  28599. * - VertexBuffer.ColorKind
  28600. * - VertexBuffer.MatricesIndicesKind
  28601. * - VertexBuffer.MatricesIndicesExtraKind
  28602. * - VertexBuffer.MatricesWeightsKind
  28603. * - VertexBuffer.MatricesWeightsExtraKind
  28604. * @returns a boolean
  28605. */
  28606. isVertexBufferUpdatable(kind: string): boolean;
  28607. /**
  28608. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28610. * - VertexBuffer.PositionKind
  28611. * - VertexBuffer.NormalKind
  28612. * - VertexBuffer.UVKind
  28613. * - VertexBuffer.UV2Kind
  28614. * - VertexBuffer.UV3Kind
  28615. * - VertexBuffer.UV4Kind
  28616. * - VertexBuffer.UV5Kind
  28617. * - VertexBuffer.UV6Kind
  28618. * - VertexBuffer.ColorKind
  28619. * - VertexBuffer.MatricesIndicesKind
  28620. * - VertexBuffer.MatricesIndicesExtraKind
  28621. * - VertexBuffer.MatricesWeightsKind
  28622. * - VertexBuffer.MatricesWeightsExtraKind
  28623. * @returns an array of strings
  28624. */
  28625. getVerticesDataKinds(): string[];
  28626. /**
  28627. * Returns a positive integer : the total number of indices in this mesh geometry.
  28628. * @returns the numner of indices or zero if the mesh has no geometry.
  28629. */
  28630. getTotalIndices(): number;
  28631. /**
  28632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28633. * @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.
  28634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28635. * @returns the indices array or an empty array if the mesh has no geometry
  28636. */
  28637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28638. get isBlocked(): boolean;
  28639. /**
  28640. * Determine if the current mesh is ready to be rendered
  28641. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28642. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28643. * @returns true if all associated assets are ready (material, textures, shaders)
  28644. */
  28645. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28646. /**
  28647. * 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.
  28648. */
  28649. get areNormalsFrozen(): boolean;
  28650. /**
  28651. * 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.
  28652. * @returns the current mesh
  28653. */
  28654. freezeNormals(): Mesh;
  28655. /**
  28656. * 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
  28657. * @returns the current mesh
  28658. */
  28659. unfreezeNormals(): Mesh;
  28660. /**
  28661. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28662. */
  28663. set overridenInstanceCount(count: number);
  28664. /** @hidden */
  28665. _preActivate(): Mesh;
  28666. /** @hidden */
  28667. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28668. /** @hidden */
  28669. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28670. protected _afterComputeWorldMatrix(): void;
  28671. /** @hidden */
  28672. _postActivate(): void;
  28673. /**
  28674. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28675. * This means the mesh underlying bounding box and sphere are recomputed.
  28676. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28677. * @returns the current mesh
  28678. */
  28679. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28680. /** @hidden */
  28681. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28682. /**
  28683. * This function will subdivide the mesh into multiple submeshes
  28684. * @param count defines the expected number of submeshes
  28685. */
  28686. subdivide(count: number): void;
  28687. /**
  28688. * Copy a FloatArray into a specific associated vertex buffer
  28689. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28690. * - VertexBuffer.PositionKind
  28691. * - VertexBuffer.UVKind
  28692. * - VertexBuffer.UV2Kind
  28693. * - VertexBuffer.UV3Kind
  28694. * - VertexBuffer.UV4Kind
  28695. * - VertexBuffer.UV5Kind
  28696. * - VertexBuffer.UV6Kind
  28697. * - VertexBuffer.ColorKind
  28698. * - VertexBuffer.MatricesIndicesKind
  28699. * - VertexBuffer.MatricesIndicesExtraKind
  28700. * - VertexBuffer.MatricesWeightsKind
  28701. * - VertexBuffer.MatricesWeightsExtraKind
  28702. * @param data defines the data source
  28703. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28704. * @param stride defines the data stride size (can be null)
  28705. * @returns the current mesh
  28706. */
  28707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28708. /**
  28709. * Delete a vertex buffer associated with this mesh
  28710. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28711. * - VertexBuffer.PositionKind
  28712. * - VertexBuffer.UVKind
  28713. * - VertexBuffer.UV2Kind
  28714. * - VertexBuffer.UV3Kind
  28715. * - VertexBuffer.UV4Kind
  28716. * - VertexBuffer.UV5Kind
  28717. * - VertexBuffer.UV6Kind
  28718. * - VertexBuffer.ColorKind
  28719. * - VertexBuffer.MatricesIndicesKind
  28720. * - VertexBuffer.MatricesIndicesExtraKind
  28721. * - VertexBuffer.MatricesWeightsKind
  28722. * - VertexBuffer.MatricesWeightsExtraKind
  28723. */
  28724. removeVerticesData(kind: string): void;
  28725. /**
  28726. * Flags an associated vertex buffer as updatable
  28727. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28728. * - VertexBuffer.PositionKind
  28729. * - VertexBuffer.UVKind
  28730. * - VertexBuffer.UV2Kind
  28731. * - VertexBuffer.UV3Kind
  28732. * - VertexBuffer.UV4Kind
  28733. * - VertexBuffer.UV5Kind
  28734. * - VertexBuffer.UV6Kind
  28735. * - VertexBuffer.ColorKind
  28736. * - VertexBuffer.MatricesIndicesKind
  28737. * - VertexBuffer.MatricesIndicesExtraKind
  28738. * - VertexBuffer.MatricesWeightsKind
  28739. * - VertexBuffer.MatricesWeightsExtraKind
  28740. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28741. */
  28742. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28743. /**
  28744. * Sets the mesh global Vertex Buffer
  28745. * @param buffer defines the buffer to use
  28746. * @returns the current mesh
  28747. */
  28748. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28749. /**
  28750. * Update a specific associated vertex buffer
  28751. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28752. * - VertexBuffer.PositionKind
  28753. * - VertexBuffer.UVKind
  28754. * - VertexBuffer.UV2Kind
  28755. * - VertexBuffer.UV3Kind
  28756. * - VertexBuffer.UV4Kind
  28757. * - VertexBuffer.UV5Kind
  28758. * - VertexBuffer.UV6Kind
  28759. * - VertexBuffer.ColorKind
  28760. * - VertexBuffer.MatricesIndicesKind
  28761. * - VertexBuffer.MatricesIndicesExtraKind
  28762. * - VertexBuffer.MatricesWeightsKind
  28763. * - VertexBuffer.MatricesWeightsExtraKind
  28764. * @param data defines the data source
  28765. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28766. * @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)
  28767. * @returns the current mesh
  28768. */
  28769. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28770. /**
  28771. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28772. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28773. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28774. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28775. * @returns the current mesh
  28776. */
  28777. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28778. /**
  28779. * Creates a un-shared specific occurence of the geometry for the mesh.
  28780. * @returns the current mesh
  28781. */
  28782. makeGeometryUnique(): Mesh;
  28783. /**
  28784. * Set the index buffer of this mesh
  28785. * @param indices defines the source data
  28786. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28787. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28788. * @returns the current mesh
  28789. */
  28790. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28791. /**
  28792. * Update the current index buffer
  28793. * @param indices defines the source data
  28794. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28795. * @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)
  28796. * @returns the current mesh
  28797. */
  28798. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28799. /**
  28800. * Invert the geometry to move from a right handed system to a left handed one.
  28801. * @returns the current mesh
  28802. */
  28803. toLeftHanded(): Mesh;
  28804. /** @hidden */
  28805. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28806. /** @hidden */
  28807. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28808. /**
  28809. * Registers for this mesh a javascript function called just before the rendering process
  28810. * @param func defines the function to call before rendering this mesh
  28811. * @returns the current mesh
  28812. */
  28813. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28814. /**
  28815. * Disposes a previously registered javascript function called before the rendering
  28816. * @param func defines the function to remove
  28817. * @returns the current mesh
  28818. */
  28819. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28820. /**
  28821. * Registers for this mesh a javascript function called just after the rendering is complete
  28822. * @param func defines the function to call after rendering this mesh
  28823. * @returns the current mesh
  28824. */
  28825. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28826. /**
  28827. * Disposes a previously registered javascript function called after the rendering.
  28828. * @param func defines the function to remove
  28829. * @returns the current mesh
  28830. */
  28831. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28832. /** @hidden */
  28833. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28834. /** @hidden */
  28835. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28836. /** @hidden */
  28837. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28838. /** @hidden */
  28839. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28840. /** @hidden */
  28841. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28842. /** @hidden */
  28843. _rebuild(): void;
  28844. /** @hidden */
  28845. _freeze(): void;
  28846. /** @hidden */
  28847. _unFreeze(): void;
  28848. /**
  28849. * 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
  28850. * @param subMesh defines the subMesh to render
  28851. * @param enableAlphaMode defines if alpha mode can be changed
  28852. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28853. * @returns the current mesh
  28854. */
  28855. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28856. private _onBeforeDraw;
  28857. /**
  28858. * Renormalize the mesh and patch it up if there are no weights
  28859. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28860. * However in the case of zero weights then we set just a single influence to 1.
  28861. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28862. */
  28863. cleanMatrixWeights(): void;
  28864. private normalizeSkinFourWeights;
  28865. private normalizeSkinWeightsAndExtra;
  28866. /**
  28867. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28868. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28869. * the user know there was an issue with importing the mesh
  28870. * @returns a validation object with skinned, valid and report string
  28871. */
  28872. validateSkinning(): {
  28873. skinned: boolean;
  28874. valid: boolean;
  28875. report: string;
  28876. };
  28877. /** @hidden */
  28878. _checkDelayState(): Mesh;
  28879. private _queueLoad;
  28880. /**
  28881. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28882. * A mesh is in the frustum if its bounding box intersects the frustum
  28883. * @param frustumPlanes defines the frustum to test
  28884. * @returns true if the mesh is in the frustum planes
  28885. */
  28886. isInFrustum(frustumPlanes: Plane[]): boolean;
  28887. /**
  28888. * Sets the mesh material by the material or multiMaterial `id` property
  28889. * @param id is a string identifying the material or the multiMaterial
  28890. * @returns the current mesh
  28891. */
  28892. setMaterialByID(id: string): Mesh;
  28893. /**
  28894. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28895. * @returns an array of IAnimatable
  28896. */
  28897. getAnimatables(): IAnimatable[];
  28898. /**
  28899. * Modifies the mesh geometry according to the passed transformation matrix.
  28900. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28901. * The mesh normals are modified using the same transformation.
  28902. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28903. * @param transform defines the transform matrix to use
  28904. * @see https://doc.babylonjs.com/resources/baking_transformations
  28905. * @returns the current mesh
  28906. */
  28907. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28908. /**
  28909. * Modifies the mesh geometry according to its own current World Matrix.
  28910. * The mesh World Matrix is then reset.
  28911. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28912. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28913. * @see https://doc.babylonjs.com/resources/baking_transformations
  28914. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28915. * @returns the current mesh
  28916. */
  28917. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28918. /** @hidden */
  28919. get _positions(): Nullable<Vector3[]>;
  28920. /** @hidden */
  28921. _resetPointsArrayCache(): Mesh;
  28922. /** @hidden */
  28923. _generatePointsArray(): boolean;
  28924. /**
  28925. * Returns a new Mesh object generated from the current mesh properties.
  28926. * This method must not get confused with createInstance()
  28927. * @param name is a string, the name given to the new mesh
  28928. * @param newParent can be any Node object (default `null`)
  28929. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28930. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28931. * @returns a new mesh
  28932. */
  28933. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28934. /**
  28935. * Releases resources associated with this mesh.
  28936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28938. */
  28939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28940. /** @hidden */
  28941. _disposeInstanceSpecificData(): void;
  28942. /** @hidden */
  28943. _disposeThinInstanceSpecificData(): void;
  28944. /**
  28945. * Modifies the mesh geometry according to a displacement map.
  28946. * 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.
  28947. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28948. * @param url is a string, the URL from the image file is to be downloaded.
  28949. * @param minHeight is the lower limit of the displacement.
  28950. * @param maxHeight is the upper limit of the displacement.
  28951. * @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.
  28952. * @param uvOffset is an optional vector2 used to offset UV.
  28953. * @param uvScale is an optional vector2 used to scale UV.
  28954. * @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.
  28955. * @returns the Mesh.
  28956. */
  28957. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28958. /**
  28959. * Modifies the mesh geometry according to a displacementMap buffer.
  28960. * 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.
  28961. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28962. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28963. * @param heightMapWidth is the width of the buffer image.
  28964. * @param heightMapHeight is the height of the buffer image.
  28965. * @param minHeight is the lower limit of the displacement.
  28966. * @param maxHeight is the upper limit of the displacement.
  28967. * @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.
  28968. * @param uvOffset is an optional vector2 used to offset UV.
  28969. * @param uvScale is an optional vector2 used to scale UV.
  28970. * @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.
  28971. * @returns the Mesh.
  28972. */
  28973. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28974. /**
  28975. * Modify the mesh to get a flat shading rendering.
  28976. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28977. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28978. * @returns current mesh
  28979. */
  28980. convertToFlatShadedMesh(): Mesh;
  28981. /**
  28982. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28983. * In other words, more vertices, no more indices and a single bigger VBO.
  28984. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28985. * @returns current mesh
  28986. */
  28987. convertToUnIndexedMesh(): Mesh;
  28988. /**
  28989. * Inverses facet orientations.
  28990. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28991. * @param flipNormals will also inverts the normals
  28992. * @returns current mesh
  28993. */
  28994. flipFaces(flipNormals?: boolean): Mesh;
  28995. /**
  28996. * Increase the number of facets and hence vertices in a mesh
  28997. * Vertex normals are interpolated from existing vertex normals
  28998. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28999. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29000. */
  29001. increaseVertices(numberPerEdge: number): void;
  29002. /**
  29003. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29004. * This will undo any application of covertToFlatShadedMesh
  29005. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29006. */
  29007. forceSharedVertices(): void;
  29008. /** @hidden */
  29009. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29010. /** @hidden */
  29011. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29012. /**
  29013. * Creates a new InstancedMesh object from the mesh model.
  29014. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29015. * @param name defines the name of the new instance
  29016. * @returns a new InstancedMesh
  29017. */
  29018. createInstance(name: string): InstancedMesh;
  29019. /**
  29020. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29021. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29022. * @returns the current mesh
  29023. */
  29024. synchronizeInstances(): Mesh;
  29025. /**
  29026. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29027. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29028. * This should be used together with the simplification to avoid disappearing triangles.
  29029. * @param successCallback an optional success callback to be called after the optimization finished.
  29030. * @returns the current mesh
  29031. */
  29032. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29033. /**
  29034. * Serialize current mesh
  29035. * @param serializationObject defines the object which will receive the serialization data
  29036. */
  29037. serialize(serializationObject: any): void;
  29038. /** @hidden */
  29039. _syncGeometryWithMorphTargetManager(): void;
  29040. /** @hidden */
  29041. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29042. /**
  29043. * Returns a new Mesh object parsed from the source provided.
  29044. * @param parsedMesh is the source
  29045. * @param scene defines the hosting scene
  29046. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29047. * @returns a new Mesh
  29048. */
  29049. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29050. /**
  29051. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29053. * @param name defines the name of the mesh to create
  29054. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29055. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29056. * @param closePath creates a seam between the first and the last points of each path of the path array
  29057. * @param offset is taken in account only if the `pathArray` is containing a single path
  29058. * @param scene defines the hosting scene
  29059. * @param updatable defines if the mesh must be flagged as updatable
  29060. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29061. * @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)
  29062. * @returns a new Mesh
  29063. */
  29064. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29065. /**
  29066. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29067. * @param name defines the name of the mesh to create
  29068. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29069. * @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
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @returns a new Mesh
  29074. */
  29075. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29076. /**
  29077. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29078. * @param name defines the name of the mesh to create
  29079. * @param size sets the size (float) of each box side (default 1)
  29080. * @param scene defines the hosting scene
  29081. * @param updatable defines if the mesh must be flagged as updatable
  29082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29083. * @returns a new Mesh
  29084. */
  29085. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29086. /**
  29087. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29088. * @param name defines the name of the mesh to create
  29089. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29090. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @returns a new Mesh
  29095. */
  29096. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29097. /**
  29098. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29099. * @param name defines the name of the mesh to create
  29100. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29101. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29102. * @param scene defines the hosting scene
  29103. * @returns a new Mesh
  29104. */
  29105. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29106. /**
  29107. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29108. * @param name defines the name of the mesh to create
  29109. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29110. * @param diameterTop set the top cap diameter (floats, default 1)
  29111. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29112. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29113. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29114. * @param scene defines the hosting scene
  29115. * @param updatable defines if the mesh must be flagged as updatable
  29116. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29117. * @returns a new Mesh
  29118. */
  29119. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29120. /**
  29121. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29122. * @param name defines the name of the mesh to create
  29123. * @param diameter sets the diameter size (float) of the torus (default 1)
  29124. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29125. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29126. * @param scene defines the hosting scene
  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. * @returns a new Mesh
  29130. */
  29131. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29132. /**
  29133. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29134. * @param name defines the name of the mesh to create
  29135. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29136. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29137. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29138. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29139. * @param p the number of windings on X axis (positive integers, default 2)
  29140. * @param q the number of windings on Y axis (positive integers, default 3)
  29141. * @param scene defines the hosting scene
  29142. * @param updatable defines if the mesh must be flagged as updatable
  29143. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29144. * @returns a new Mesh
  29145. */
  29146. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29147. /**
  29148. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29149. * @param name defines the name of the mesh to create
  29150. * @param points is an array successive Vector3
  29151. * @param scene defines the hosting scene
  29152. * @param updatable defines if the mesh must be flagged as updatable
  29153. * @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).
  29154. * @returns a new Mesh
  29155. */
  29156. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29157. /**
  29158. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29159. * @param name defines the name of the mesh to create
  29160. * @param points is an array successive Vector3
  29161. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29162. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29163. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29164. * @param scene defines the hosting scene
  29165. * @param updatable defines if the mesh must be flagged as updatable
  29166. * @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)
  29167. * @returns a new Mesh
  29168. */
  29169. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29170. /**
  29171. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29172. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29173. * 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.
  29174. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29175. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29176. * Remember you can only change the shape positions, not their number when updating a polygon.
  29177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29178. * @param name defines the name of the mesh to create
  29179. * @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
  29180. * @param scene defines the hosting scene
  29181. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29182. * @param updatable defines if the mesh must be flagged as updatable
  29183. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29184. * @param earcutInjection can be used to inject your own earcut reference
  29185. * @returns a new Mesh
  29186. */
  29187. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29188. /**
  29189. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29191. * @param name defines the name of the mesh to create
  29192. * @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
  29193. * @param depth defines the height of extrusion
  29194. * @param scene defines the hosting scene
  29195. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29196. * @param updatable defines if the mesh must be flagged as updatable
  29197. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29198. * @param earcutInjection can be used to inject your own earcut reference
  29199. * @returns a new Mesh
  29200. */
  29201. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29202. /**
  29203. * Creates an extruded shape mesh.
  29204. * 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
  29205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29207. * @param name defines the name of the mesh to create
  29208. * @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
  29209. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29210. * @param scale is the value to scale the shape
  29211. * @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
  29212. * @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
  29213. * @param scene defines the hosting scene
  29214. * @param updatable defines if the mesh must be flagged as updatable
  29215. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29216. * @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)
  29217. * @returns a new Mesh
  29218. */
  29219. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29220. /**
  29221. * Creates an custom extruded shape mesh.
  29222. * The custom extrusion is a parametric shape.
  29223. * It has no predefined shape. Its final shape will depend on the input parameters.
  29224. * Please consider using the same method from the MeshBuilder class instead
  29225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29226. * @param name defines the name of the mesh to create
  29227. * @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
  29228. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29229. * @param scaleFunction is a custom Javascript function called on each path point
  29230. * @param rotationFunction is a custom Javascript function called on each path point
  29231. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29232. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29233. * @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
  29234. * @param scene defines the hosting scene
  29235. * @param updatable defines if the mesh must be flagged as updatable
  29236. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29237. * @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)
  29238. * @returns a new Mesh
  29239. */
  29240. 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;
  29241. /**
  29242. * Creates lathe mesh.
  29243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29244. * Please consider using the same method from the MeshBuilder class instead
  29245. * @param name defines the name of the mesh to create
  29246. * @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
  29247. * @param radius is the radius value of the lathe
  29248. * @param tessellation is the side number of the lathe.
  29249. * @param scene defines the hosting scene
  29250. * @param updatable defines if the mesh must be flagged as updatable
  29251. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29252. * @returns a new Mesh
  29253. */
  29254. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29255. /**
  29256. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29257. * @param name defines the name of the mesh to create
  29258. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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. * @returns a new Mesh
  29263. */
  29264. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29265. /**
  29266. * Creates a ground mesh.
  29267. * Please consider using the same method from the MeshBuilder class instead
  29268. * @param name defines the name of the mesh to create
  29269. * @param width set the width of the ground
  29270. * @param height set the height of the ground
  29271. * @param subdivisions sets the number of subdivisions per side
  29272. * @param scene defines the hosting scene
  29273. * @param updatable defines if the mesh must be flagged as updatable
  29274. * @returns a new Mesh
  29275. */
  29276. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29277. /**
  29278. * Creates a tiled ground mesh.
  29279. * Please consider using the same method from the MeshBuilder class instead
  29280. * @param name defines the name of the mesh to create
  29281. * @param xmin set the ground minimum X coordinate
  29282. * @param zmin set the ground minimum Y coordinate
  29283. * @param xmax set the ground maximum X coordinate
  29284. * @param zmax set the ground maximum Z coordinate
  29285. * @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
  29286. * @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
  29287. * @param scene defines the hosting scene
  29288. * @param updatable defines if the mesh must be flagged as updatable
  29289. * @returns a new Mesh
  29290. */
  29291. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29292. w: number;
  29293. h: number;
  29294. }, precision: {
  29295. w: number;
  29296. h: number;
  29297. }, scene: Scene, updatable?: boolean): Mesh;
  29298. /**
  29299. * Creates a ground mesh from a height map.
  29300. * Please consider using the same method from the MeshBuilder class instead
  29301. * @see https://doc.babylonjs.com/babylon101/height_map
  29302. * @param name defines the name of the mesh to create
  29303. * @param url sets the URL of the height map image resource
  29304. * @param width set the ground width size
  29305. * @param height set the ground height size
  29306. * @param subdivisions sets the number of subdivision per side
  29307. * @param minHeight is the minimum altitude on the ground
  29308. * @param maxHeight is the maximum altitude on the ground
  29309. * @param scene defines the hosting scene
  29310. * @param updatable defines if the mesh must be flagged as updatable
  29311. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29312. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29313. * @returns a new Mesh
  29314. */
  29315. 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;
  29316. /**
  29317. * Creates a tube mesh.
  29318. * The tube is a parametric shape.
  29319. * It has no predefined shape. Its final shape will depend on the input parameters.
  29320. * Please consider using the same method from the MeshBuilder class instead
  29321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29322. * @param name defines the name of the mesh to create
  29323. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29324. * @param radius sets the tube radius size
  29325. * @param tessellation is the number of sides on the tubular surface
  29326. * @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
  29327. * @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
  29328. * @param scene defines the hosting scene
  29329. * @param updatable defines if the mesh must be flagged as updatable
  29330. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29331. * @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)
  29332. * @returns a new Mesh
  29333. */
  29334. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29335. (i: number, distance: number): number;
  29336. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29337. /**
  29338. * Creates a polyhedron mesh.
  29339. * Please consider using the same method from the MeshBuilder class instead.
  29340. * * 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
  29341. * * The parameter `size` (positive float, default 1) sets the polygon size
  29342. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29343. * * 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`
  29344. * * 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
  29345. * * 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)`)
  29346. * * 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
  29347. * * 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
  29348. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29349. * * 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
  29350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29351. * @param name defines the name of the mesh to create
  29352. * @param options defines the options used to create the mesh
  29353. * @param scene defines the hosting scene
  29354. * @returns a new Mesh
  29355. */
  29356. static CreatePolyhedron(name: string, options: {
  29357. type?: number;
  29358. size?: number;
  29359. sizeX?: number;
  29360. sizeY?: number;
  29361. sizeZ?: number;
  29362. custom?: any;
  29363. faceUV?: Vector4[];
  29364. faceColors?: Color4[];
  29365. updatable?: boolean;
  29366. sideOrientation?: number;
  29367. }, scene: Scene): Mesh;
  29368. /**
  29369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29371. * * 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`)
  29372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29373. * * 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
  29374. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29375. * * 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
  29376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29377. * @param name defines the name of the mesh
  29378. * @param options defines the options used to create the mesh
  29379. * @param scene defines the hosting scene
  29380. * @returns a new Mesh
  29381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29382. */
  29383. static CreateIcoSphere(name: string, options: {
  29384. radius?: number;
  29385. flat?: boolean;
  29386. subdivisions?: number;
  29387. sideOrientation?: number;
  29388. updatable?: boolean;
  29389. }, scene: Scene): Mesh;
  29390. /**
  29391. * Creates a decal mesh.
  29392. * Please consider using the same method from the MeshBuilder class instead.
  29393. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29394. * @param name defines the name of the mesh
  29395. * @param sourceMesh defines the mesh receiving the decal
  29396. * @param position sets the position of the decal in world coordinates
  29397. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29398. * @param size sets the decal scaling
  29399. * @param angle sets the angle to rotate the decal
  29400. * @returns a new Mesh
  29401. */
  29402. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29403. /** Creates a Capsule Mesh
  29404. * @param name defines the name of the mesh.
  29405. * @param options the constructors options used to shape the mesh.
  29406. * @param scene defines the scene the mesh is scoped to.
  29407. * @returns the capsule mesh
  29408. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29409. */
  29410. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29411. /**
  29412. * Prepare internal position array for software CPU skinning
  29413. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29414. */
  29415. setPositionsForCPUSkinning(): Float32Array;
  29416. /**
  29417. * Prepare internal normal array for software CPU skinning
  29418. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29419. */
  29420. setNormalsForCPUSkinning(): Float32Array;
  29421. /**
  29422. * Updates the vertex buffer by applying transformation from the bones
  29423. * @param skeleton defines the skeleton to apply to current mesh
  29424. * @returns the current mesh
  29425. */
  29426. applySkeleton(skeleton: Skeleton): Mesh;
  29427. /**
  29428. * 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
  29429. * @param meshes defines the list of meshes to scan
  29430. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29431. */
  29432. static MinMax(meshes: AbstractMesh[]): {
  29433. min: Vector3;
  29434. max: Vector3;
  29435. };
  29436. /**
  29437. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29438. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29439. * @returns a vector3
  29440. */
  29441. static Center(meshesOrMinMaxVector: {
  29442. min: Vector3;
  29443. max: Vector3;
  29444. } | AbstractMesh[]): Vector3;
  29445. /**
  29446. * Merge the array of meshes into a single mesh for performance reasons.
  29447. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29448. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29449. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29450. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29451. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29452. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29453. * @returns a new mesh
  29454. */
  29455. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29456. /** @hidden */
  29457. addInstance(instance: InstancedMesh): void;
  29458. /** @hidden */
  29459. removeInstance(instance: InstancedMesh): void;
  29460. }
  29461. }
  29462. declare module BABYLON {
  29463. /**
  29464. * This is the base class of all the camera used in the application.
  29465. * @see https://doc.babylonjs.com/features/cameras
  29466. */
  29467. export class Camera extends Node {
  29468. /** @hidden */
  29469. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29470. /**
  29471. * This is the default projection mode used by the cameras.
  29472. * It helps recreating a feeling of perspective and better appreciate depth.
  29473. * This is the best way to simulate real life cameras.
  29474. */
  29475. static readonly PERSPECTIVE_CAMERA: number;
  29476. /**
  29477. * This helps creating camera with an orthographic mode.
  29478. * 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.
  29479. */
  29480. static readonly ORTHOGRAPHIC_CAMERA: number;
  29481. /**
  29482. * This is the default FOV mode for perspective cameras.
  29483. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29484. */
  29485. static readonly FOVMODE_VERTICAL_FIXED: number;
  29486. /**
  29487. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29488. */
  29489. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29490. /**
  29491. * This specifies ther is no need for a camera rig.
  29492. * Basically only one eye is rendered corresponding to the camera.
  29493. */
  29494. static readonly RIG_MODE_NONE: number;
  29495. /**
  29496. * Simulates a camera Rig with one blue eye and one red eye.
  29497. * This can be use with 3d blue and red glasses.
  29498. */
  29499. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29500. /**
  29501. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29502. */
  29503. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29504. /**
  29505. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29506. */
  29507. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29508. /**
  29509. * Defines that both eyes of the camera will be rendered over under each other.
  29510. */
  29511. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29512. /**
  29513. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29514. */
  29515. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29516. /**
  29517. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29518. */
  29519. static readonly RIG_MODE_VR: number;
  29520. /**
  29521. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29522. */
  29523. static readonly RIG_MODE_WEBVR: number;
  29524. /**
  29525. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29526. */
  29527. static readonly RIG_MODE_CUSTOM: number;
  29528. /**
  29529. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29530. */
  29531. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29532. /**
  29533. * Define the input manager associated with the camera.
  29534. */
  29535. inputs: CameraInputsManager<Camera>;
  29536. /** @hidden */
  29537. _position: Vector3;
  29538. /**
  29539. * Define the current local position of the camera in the scene
  29540. */
  29541. get position(): Vector3;
  29542. set position(newPosition: Vector3);
  29543. protected _upVector: Vector3;
  29544. /**
  29545. * The vector the camera should consider as up.
  29546. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29547. */
  29548. set upVector(vec: Vector3);
  29549. get upVector(): Vector3;
  29550. /**
  29551. * Define the current limit on the left side for an orthographic camera
  29552. * In scene unit
  29553. */
  29554. orthoLeft: Nullable<number>;
  29555. /**
  29556. * Define the current limit on the right side for an orthographic camera
  29557. * In scene unit
  29558. */
  29559. orthoRight: Nullable<number>;
  29560. /**
  29561. * Define the current limit on the bottom side for an orthographic camera
  29562. * In scene unit
  29563. */
  29564. orthoBottom: Nullable<number>;
  29565. /**
  29566. * Define the current limit on the top side for an orthographic camera
  29567. * In scene unit
  29568. */
  29569. orthoTop: Nullable<number>;
  29570. /**
  29571. * Field Of View is set in Radians. (default is 0.8)
  29572. */
  29573. fov: number;
  29574. /**
  29575. * Define the minimum distance the camera can see from.
  29576. * This is important to note that the depth buffer are not infinite and the closer it starts
  29577. * the more your scene might encounter depth fighting issue.
  29578. */
  29579. minZ: number;
  29580. /**
  29581. * Define the maximum distance the camera can see to.
  29582. * This is important to note that the depth buffer are not infinite and the further it end
  29583. * the more your scene might encounter depth fighting issue.
  29584. */
  29585. maxZ: number;
  29586. /**
  29587. * Define the default inertia of the camera.
  29588. * This helps giving a smooth feeling to the camera movement.
  29589. */
  29590. inertia: number;
  29591. /**
  29592. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29593. */
  29594. mode: number;
  29595. /**
  29596. * Define whether the camera is intermediate.
  29597. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29598. */
  29599. isIntermediate: boolean;
  29600. /**
  29601. * Define the viewport of the camera.
  29602. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29603. */
  29604. viewport: Viewport;
  29605. /**
  29606. * Restricts the camera to viewing objects with the same layerMask.
  29607. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29608. */
  29609. layerMask: number;
  29610. /**
  29611. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29612. */
  29613. fovMode: number;
  29614. /**
  29615. * Rig mode of the camera.
  29616. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29617. * This is normally controlled byt the camera themselves as internal use.
  29618. */
  29619. cameraRigMode: number;
  29620. /**
  29621. * Defines the distance between both "eyes" in case of a RIG
  29622. */
  29623. interaxialDistance: number;
  29624. /**
  29625. * Defines if stereoscopic rendering is done side by side or over under.
  29626. */
  29627. isStereoscopicSideBySide: boolean;
  29628. /**
  29629. * 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
  29630. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29631. * else in the scene. (Eg. security camera)
  29632. *
  29633. * 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)
  29634. */
  29635. customRenderTargets: RenderTargetTexture[];
  29636. /**
  29637. * When set, the camera will render to this render target instead of the default canvas
  29638. *
  29639. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29640. */
  29641. outputRenderTarget: Nullable<RenderTargetTexture>;
  29642. /**
  29643. * Observable triggered when the camera view matrix has changed.
  29644. */
  29645. onViewMatrixChangedObservable: Observable<Camera>;
  29646. /**
  29647. * Observable triggered when the camera Projection matrix has changed.
  29648. */
  29649. onProjectionMatrixChangedObservable: Observable<Camera>;
  29650. /**
  29651. * Observable triggered when the inputs have been processed.
  29652. */
  29653. onAfterCheckInputsObservable: Observable<Camera>;
  29654. /**
  29655. * Observable triggered when reset has been called and applied to the camera.
  29656. */
  29657. onRestoreStateObservable: Observable<Camera>;
  29658. /**
  29659. * Is this camera a part of a rig system?
  29660. */
  29661. isRigCamera: boolean;
  29662. /**
  29663. * If isRigCamera set to true this will be set with the parent camera.
  29664. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29665. */
  29666. rigParent?: Camera;
  29667. /** @hidden */
  29668. _cameraRigParams: any;
  29669. /** @hidden */
  29670. _rigCameras: Camera[];
  29671. /** @hidden */
  29672. _rigPostProcess: Nullable<PostProcess>;
  29673. protected _webvrViewMatrix: Matrix;
  29674. /** @hidden */
  29675. _skipRendering: boolean;
  29676. /** @hidden */
  29677. _projectionMatrix: Matrix;
  29678. /** @hidden */
  29679. _postProcesses: Nullable<PostProcess>[];
  29680. /** @hidden */
  29681. _activeMeshes: SmartArray<AbstractMesh>;
  29682. protected _globalPosition: Vector3;
  29683. /** @hidden */
  29684. _computedViewMatrix: Matrix;
  29685. private _doNotComputeProjectionMatrix;
  29686. private _transformMatrix;
  29687. private _frustumPlanes;
  29688. private _refreshFrustumPlanes;
  29689. private _storedFov;
  29690. private _stateStored;
  29691. /**
  29692. * Instantiates a new camera object.
  29693. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29694. * @see https://doc.babylonjs.com/features/cameras
  29695. * @param name Defines the name of the camera in the scene
  29696. * @param position Defines the position of the camera
  29697. * @param scene Defines the scene the camera belongs too
  29698. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29699. */
  29700. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29701. /**
  29702. * Store current camera state (fov, position, etc..)
  29703. * @returns the camera
  29704. */
  29705. storeState(): Camera;
  29706. /**
  29707. * Restores the camera state values if it has been stored. You must call storeState() first
  29708. */
  29709. protected _restoreStateValues(): boolean;
  29710. /**
  29711. * Restored camera state. You must call storeState() first.
  29712. * @returns true if restored and false otherwise
  29713. */
  29714. restoreState(): boolean;
  29715. /**
  29716. * Gets the class name of the camera.
  29717. * @returns the class name
  29718. */
  29719. getClassName(): string;
  29720. /** @hidden */
  29721. readonly _isCamera: boolean;
  29722. /**
  29723. * Gets a string representation of the camera useful for debug purpose.
  29724. * @param fullDetails Defines that a more verboe level of logging is required
  29725. * @returns the string representation
  29726. */
  29727. toString(fullDetails?: boolean): string;
  29728. /**
  29729. * Gets the current world space position of the camera.
  29730. */
  29731. get globalPosition(): Vector3;
  29732. /**
  29733. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29734. * @returns the active meshe list
  29735. */
  29736. getActiveMeshes(): SmartArray<AbstractMesh>;
  29737. /**
  29738. * Check whether a mesh is part of the current active mesh list of the camera
  29739. * @param mesh Defines the mesh to check
  29740. * @returns true if active, false otherwise
  29741. */
  29742. isActiveMesh(mesh: Mesh): boolean;
  29743. /**
  29744. * Is this camera ready to be used/rendered
  29745. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29746. * @return true if the camera is ready
  29747. */
  29748. isReady(completeCheck?: boolean): boolean;
  29749. /** @hidden */
  29750. _initCache(): void;
  29751. /** @hidden */
  29752. _updateCache(ignoreParentClass?: boolean): void;
  29753. /** @hidden */
  29754. _isSynchronized(): boolean;
  29755. /** @hidden */
  29756. _isSynchronizedViewMatrix(): boolean;
  29757. /** @hidden */
  29758. _isSynchronizedProjectionMatrix(): boolean;
  29759. /**
  29760. * Attach the input controls to a specific dom element to get the input from.
  29761. * @param element Defines the element the controls should be listened from
  29762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29763. */
  29764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29765. /**
  29766. * Detach the current controls from the specified dom element.
  29767. * @param element Defines the element to stop listening the inputs from
  29768. */
  29769. detachControl(element: HTMLElement): void;
  29770. /**
  29771. * Update the camera state according to the different inputs gathered during the frame.
  29772. */
  29773. update(): void;
  29774. /** @hidden */
  29775. _checkInputs(): void;
  29776. /** @hidden */
  29777. get rigCameras(): Camera[];
  29778. /**
  29779. * Gets the post process used by the rig cameras
  29780. */
  29781. get rigPostProcess(): Nullable<PostProcess>;
  29782. /**
  29783. * Internal, gets the first post proces.
  29784. * @returns the first post process to be run on this camera.
  29785. */
  29786. _getFirstPostProcess(): Nullable<PostProcess>;
  29787. private _cascadePostProcessesToRigCams;
  29788. /**
  29789. * Attach a post process to the camera.
  29790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29791. * @param postProcess The post process to attach to the camera
  29792. * @param insertAt The position of the post process in case several of them are in use in the scene
  29793. * @returns the position the post process has been inserted at
  29794. */
  29795. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29796. /**
  29797. * Detach a post process to the camera.
  29798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29799. * @param postProcess The post process to detach from the camera
  29800. */
  29801. detachPostProcess(postProcess: PostProcess): void;
  29802. /**
  29803. * Gets the current world matrix of the camera
  29804. */
  29805. getWorldMatrix(): Matrix;
  29806. /** @hidden */
  29807. _getViewMatrix(): Matrix;
  29808. /**
  29809. * Gets the current view matrix of the camera.
  29810. * @param force forces the camera to recompute the matrix without looking at the cached state
  29811. * @returns the view matrix
  29812. */
  29813. getViewMatrix(force?: boolean): Matrix;
  29814. /**
  29815. * Freeze the projection matrix.
  29816. * It will prevent the cache check of the camera projection compute and can speed up perf
  29817. * if no parameter of the camera are meant to change
  29818. * @param projection Defines manually a projection if necessary
  29819. */
  29820. freezeProjectionMatrix(projection?: Matrix): void;
  29821. /**
  29822. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29823. */
  29824. unfreezeProjectionMatrix(): void;
  29825. /**
  29826. * Gets the current projection matrix of the camera.
  29827. * @param force forces the camera to recompute the matrix without looking at the cached state
  29828. * @returns the projection matrix
  29829. */
  29830. getProjectionMatrix(force?: boolean): Matrix;
  29831. /**
  29832. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29833. * @returns a Matrix
  29834. */
  29835. getTransformationMatrix(): Matrix;
  29836. private _updateFrustumPlanes;
  29837. /**
  29838. * Checks if a cullable object (mesh...) is in the camera frustum
  29839. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29840. * @param target The object to check
  29841. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29842. * @returns true if the object is in frustum otherwise false
  29843. */
  29844. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29845. /**
  29846. * Checks if a cullable object (mesh...) is in the camera frustum
  29847. * Unlike isInFrustum this cheks the full bounding box
  29848. * @param target The object to check
  29849. * @returns true if the object is in frustum otherwise false
  29850. */
  29851. isCompletelyInFrustum(target: ICullable): boolean;
  29852. /**
  29853. * Gets a ray in the forward direction from the camera.
  29854. * @param length Defines the length of the ray to create
  29855. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29856. * @param origin Defines the start point of the ray which defaults to the camera position
  29857. * @returns the forward ray
  29858. */
  29859. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29860. /**
  29861. * Gets a ray in the forward direction from the camera.
  29862. * @param refRay the ray to (re)use when setting the values
  29863. * @param length Defines the length of the ray to create
  29864. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29865. * @param origin Defines the start point of the ray which defaults to the camera position
  29866. * @returns the forward ray
  29867. */
  29868. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29869. /**
  29870. * Releases resources associated with this node.
  29871. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29872. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29873. */
  29874. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29875. /** @hidden */
  29876. _isLeftCamera: boolean;
  29877. /**
  29878. * Gets the left camera of a rig setup in case of Rigged Camera
  29879. */
  29880. get isLeftCamera(): boolean;
  29881. /** @hidden */
  29882. _isRightCamera: boolean;
  29883. /**
  29884. * Gets the right camera of a rig setup in case of Rigged Camera
  29885. */
  29886. get isRightCamera(): boolean;
  29887. /**
  29888. * Gets the left camera of a rig setup in case of Rigged Camera
  29889. */
  29890. get leftCamera(): Nullable<FreeCamera>;
  29891. /**
  29892. * Gets the right camera of a rig setup in case of Rigged Camera
  29893. */
  29894. get rightCamera(): Nullable<FreeCamera>;
  29895. /**
  29896. * Gets the left camera target of a rig setup in case of Rigged Camera
  29897. * @returns the target position
  29898. */
  29899. getLeftTarget(): Nullable<Vector3>;
  29900. /**
  29901. * Gets the right camera target of a rig setup in case of Rigged Camera
  29902. * @returns the target position
  29903. */
  29904. getRightTarget(): Nullable<Vector3>;
  29905. /**
  29906. * @hidden
  29907. */
  29908. setCameraRigMode(mode: number, rigParams: any): void;
  29909. /** @hidden */
  29910. static _setStereoscopicRigMode(camera: Camera): void;
  29911. /** @hidden */
  29912. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29913. /** @hidden */
  29914. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29915. /** @hidden */
  29916. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29917. /** @hidden */
  29918. _getVRProjectionMatrix(): Matrix;
  29919. protected _updateCameraRotationMatrix(): void;
  29920. protected _updateWebVRCameraRotationMatrix(): void;
  29921. /**
  29922. * This function MUST be overwritten by the different WebVR cameras available.
  29923. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29924. * @hidden
  29925. */
  29926. _getWebVRProjectionMatrix(): Matrix;
  29927. /**
  29928. * This function MUST be overwritten by the different WebVR cameras available.
  29929. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29930. * @hidden
  29931. */
  29932. _getWebVRViewMatrix(): Matrix;
  29933. /** @hidden */
  29934. setCameraRigParameter(name: string, value: any): void;
  29935. /**
  29936. * needs to be overridden by children so sub has required properties to be copied
  29937. * @hidden
  29938. */
  29939. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29940. /**
  29941. * May need to be overridden by children
  29942. * @hidden
  29943. */
  29944. _updateRigCameras(): void;
  29945. /** @hidden */
  29946. _setupInputs(): void;
  29947. /**
  29948. * Serialiaze the camera setup to a json represention
  29949. * @returns the JSON representation
  29950. */
  29951. serialize(): any;
  29952. /**
  29953. * Clones the current camera.
  29954. * @param name The cloned camera name
  29955. * @returns the cloned camera
  29956. */
  29957. clone(name: string): Camera;
  29958. /**
  29959. * Gets the direction of the camera relative to a given local axis.
  29960. * @param localAxis Defines the reference axis to provide a relative direction.
  29961. * @return the direction
  29962. */
  29963. getDirection(localAxis: Vector3): Vector3;
  29964. /**
  29965. * Returns the current camera absolute rotation
  29966. */
  29967. get absoluteRotation(): Quaternion;
  29968. /**
  29969. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29970. * @param localAxis Defines the reference axis to provide a relative direction.
  29971. * @param result Defines the vector to store the result in
  29972. */
  29973. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29974. /**
  29975. * Gets a camera constructor for a given camera type
  29976. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29977. * @param name The name of the camera the result will be able to instantiate
  29978. * @param scene The scene the result will construct the camera in
  29979. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29980. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29981. * @returns a factory method to construc the camera
  29982. */
  29983. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29984. /**
  29985. * Compute the world matrix of the camera.
  29986. * @returns the camera world matrix
  29987. */
  29988. computeWorldMatrix(): Matrix;
  29989. /**
  29990. * Parse a JSON and creates the camera from the parsed information
  29991. * @param parsedCamera The JSON to parse
  29992. * @param scene The scene to instantiate the camera in
  29993. * @returns the newly constructed camera
  29994. */
  29995. static Parse(parsedCamera: any, scene: Scene): Camera;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Class containing static functions to help procedurally build meshes
  30001. */
  30002. export class DiscBuilder {
  30003. /**
  30004. * Creates a plane polygonal mesh. By default, this is a disc
  30005. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30006. * * 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
  30007. * * 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
  30008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30009. * * 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
  30010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30011. * @param name defines the name of the mesh
  30012. * @param options defines the options used to create the mesh
  30013. * @param scene defines the hosting scene
  30014. * @returns the plane polygonal mesh
  30015. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30016. */
  30017. static CreateDisc(name: string, options: {
  30018. radius?: number;
  30019. tessellation?: number;
  30020. arc?: number;
  30021. updatable?: boolean;
  30022. sideOrientation?: number;
  30023. frontUVs?: Vector4;
  30024. backUVs?: Vector4;
  30025. }, scene?: Nullable<Scene>): Mesh;
  30026. }
  30027. }
  30028. declare module BABYLON {
  30029. /**
  30030. * Options to be used when creating a FresnelParameters.
  30031. */
  30032. export type IFresnelParametersCreationOptions = {
  30033. /**
  30034. * Define the color used on edges (grazing angle)
  30035. */
  30036. leftColor?: Color3;
  30037. /**
  30038. * Define the color used on center
  30039. */
  30040. rightColor?: Color3;
  30041. /**
  30042. * Define bias applied to computed fresnel term
  30043. */
  30044. bias?: number;
  30045. /**
  30046. * Defined the power exponent applied to fresnel term
  30047. */
  30048. power?: number;
  30049. /**
  30050. * Define if the fresnel effect is enable or not.
  30051. */
  30052. isEnabled?: boolean;
  30053. };
  30054. /**
  30055. * Serialized format for FresnelParameters.
  30056. */
  30057. export type IFresnelParametersSerialized = {
  30058. /**
  30059. * Define the color used on edges (grazing angle) [as an array]
  30060. */
  30061. leftColor: number[];
  30062. /**
  30063. * Define the color used on center [as an array]
  30064. */
  30065. rightColor: number[];
  30066. /**
  30067. * Define bias applied to computed fresnel term
  30068. */
  30069. bias: number;
  30070. /**
  30071. * Defined the power exponent applied to fresnel term
  30072. */
  30073. power?: number;
  30074. /**
  30075. * Define if the fresnel effect is enable or not.
  30076. */
  30077. isEnabled: boolean;
  30078. };
  30079. /**
  30080. * This represents all the required information to add a fresnel effect on a material:
  30081. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30082. */
  30083. export class FresnelParameters {
  30084. private _isEnabled;
  30085. /**
  30086. * Define if the fresnel effect is enable or not.
  30087. */
  30088. get isEnabled(): boolean;
  30089. set isEnabled(value: boolean);
  30090. /**
  30091. * Define the color used on edges (grazing angle)
  30092. */
  30093. leftColor: Color3;
  30094. /**
  30095. * Define the color used on center
  30096. */
  30097. rightColor: Color3;
  30098. /**
  30099. * Define bias applied to computed fresnel term
  30100. */
  30101. bias: number;
  30102. /**
  30103. * Defined the power exponent applied to fresnel term
  30104. */
  30105. power: number;
  30106. /**
  30107. * Creates a new FresnelParameters object.
  30108. *
  30109. * @param options provide your own settings to optionally to override defaults
  30110. */
  30111. constructor(options?: IFresnelParametersCreationOptions);
  30112. /**
  30113. * Clones the current fresnel and its valuues
  30114. * @returns a clone fresnel configuration
  30115. */
  30116. clone(): FresnelParameters;
  30117. /**
  30118. * Determines equality between FresnelParameters objects
  30119. * @param otherFresnelParameters defines the second operand
  30120. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30121. */
  30122. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30123. /**
  30124. * Serializes the current fresnel parameters to a JSON representation.
  30125. * @return the JSON serialization
  30126. */
  30127. serialize(): IFresnelParametersSerialized;
  30128. /**
  30129. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30130. * @param parsedFresnelParameters Define the JSON representation
  30131. * @returns the parsed parameters
  30132. */
  30133. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30134. }
  30135. }
  30136. declare module BABYLON {
  30137. /**
  30138. * This groups all the flags used to control the materials channel.
  30139. */
  30140. export class MaterialFlags {
  30141. private static _DiffuseTextureEnabled;
  30142. /**
  30143. * Are diffuse textures enabled in the application.
  30144. */
  30145. static get DiffuseTextureEnabled(): boolean;
  30146. static set DiffuseTextureEnabled(value: boolean);
  30147. private static _DetailTextureEnabled;
  30148. /**
  30149. * Are detail textures enabled in the application.
  30150. */
  30151. static get DetailTextureEnabled(): boolean;
  30152. static set DetailTextureEnabled(value: boolean);
  30153. private static _AmbientTextureEnabled;
  30154. /**
  30155. * Are ambient textures enabled in the application.
  30156. */
  30157. static get AmbientTextureEnabled(): boolean;
  30158. static set AmbientTextureEnabled(value: boolean);
  30159. private static _OpacityTextureEnabled;
  30160. /**
  30161. * Are opacity textures enabled in the application.
  30162. */
  30163. static get OpacityTextureEnabled(): boolean;
  30164. static set OpacityTextureEnabled(value: boolean);
  30165. private static _ReflectionTextureEnabled;
  30166. /**
  30167. * Are reflection textures enabled in the application.
  30168. */
  30169. static get ReflectionTextureEnabled(): boolean;
  30170. static set ReflectionTextureEnabled(value: boolean);
  30171. private static _EmissiveTextureEnabled;
  30172. /**
  30173. * Are emissive textures enabled in the application.
  30174. */
  30175. static get EmissiveTextureEnabled(): boolean;
  30176. static set EmissiveTextureEnabled(value: boolean);
  30177. private static _SpecularTextureEnabled;
  30178. /**
  30179. * Are specular textures enabled in the application.
  30180. */
  30181. static get SpecularTextureEnabled(): boolean;
  30182. static set SpecularTextureEnabled(value: boolean);
  30183. private static _BumpTextureEnabled;
  30184. /**
  30185. * Are bump textures enabled in the application.
  30186. */
  30187. static get BumpTextureEnabled(): boolean;
  30188. static set BumpTextureEnabled(value: boolean);
  30189. private static _LightmapTextureEnabled;
  30190. /**
  30191. * Are lightmap textures enabled in the application.
  30192. */
  30193. static get LightmapTextureEnabled(): boolean;
  30194. static set LightmapTextureEnabled(value: boolean);
  30195. private static _RefractionTextureEnabled;
  30196. /**
  30197. * Are refraction textures enabled in the application.
  30198. */
  30199. static get RefractionTextureEnabled(): boolean;
  30200. static set RefractionTextureEnabled(value: boolean);
  30201. private static _ColorGradingTextureEnabled;
  30202. /**
  30203. * Are color grading textures enabled in the application.
  30204. */
  30205. static get ColorGradingTextureEnabled(): boolean;
  30206. static set ColorGradingTextureEnabled(value: boolean);
  30207. private static _FresnelEnabled;
  30208. /**
  30209. * Are fresnels enabled in the application.
  30210. */
  30211. static get FresnelEnabled(): boolean;
  30212. static set FresnelEnabled(value: boolean);
  30213. private static _ClearCoatTextureEnabled;
  30214. /**
  30215. * Are clear coat textures enabled in the application.
  30216. */
  30217. static get ClearCoatTextureEnabled(): boolean;
  30218. static set ClearCoatTextureEnabled(value: boolean);
  30219. private static _ClearCoatBumpTextureEnabled;
  30220. /**
  30221. * Are clear coat bump textures enabled in the application.
  30222. */
  30223. static get ClearCoatBumpTextureEnabled(): boolean;
  30224. static set ClearCoatBumpTextureEnabled(value: boolean);
  30225. private static _ClearCoatTintTextureEnabled;
  30226. /**
  30227. * Are clear coat tint textures enabled in the application.
  30228. */
  30229. static get ClearCoatTintTextureEnabled(): boolean;
  30230. static set ClearCoatTintTextureEnabled(value: boolean);
  30231. private static _SheenTextureEnabled;
  30232. /**
  30233. * Are sheen textures enabled in the application.
  30234. */
  30235. static get SheenTextureEnabled(): boolean;
  30236. static set SheenTextureEnabled(value: boolean);
  30237. private static _AnisotropicTextureEnabled;
  30238. /**
  30239. * Are anisotropic textures enabled in the application.
  30240. */
  30241. static get AnisotropicTextureEnabled(): boolean;
  30242. static set AnisotropicTextureEnabled(value: boolean);
  30243. private static _ThicknessTextureEnabled;
  30244. /**
  30245. * Are thickness textures enabled in the application.
  30246. */
  30247. static get ThicknessTextureEnabled(): boolean;
  30248. static set ThicknessTextureEnabled(value: boolean);
  30249. }
  30250. }
  30251. declare module BABYLON {
  30252. /** @hidden */
  30253. export var defaultFragmentDeclaration: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module BABYLON {
  30259. /** @hidden */
  30260. export var defaultUboDeclaration: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module BABYLON {
  30266. /** @hidden */
  30267. export var prePassDeclaration: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module BABYLON {
  30273. /** @hidden */
  30274. export var lightFragmentDeclaration: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module BABYLON {
  30280. /** @hidden */
  30281. export var lightUboDeclaration: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module BABYLON {
  30287. /** @hidden */
  30288. export var lightsFragmentFunctions: {
  30289. name: string;
  30290. shader: string;
  30291. };
  30292. }
  30293. declare module BABYLON {
  30294. /** @hidden */
  30295. export var shadowsFragmentFunctions: {
  30296. name: string;
  30297. shader: string;
  30298. };
  30299. }
  30300. declare module BABYLON {
  30301. /** @hidden */
  30302. export var fresnelFunction: {
  30303. name: string;
  30304. shader: string;
  30305. };
  30306. }
  30307. declare module BABYLON {
  30308. /** @hidden */
  30309. export var bumpFragmentMainFunctions: {
  30310. name: string;
  30311. shader: string;
  30312. };
  30313. }
  30314. declare module BABYLON {
  30315. /** @hidden */
  30316. export var bumpFragmentFunctions: {
  30317. name: string;
  30318. shader: string;
  30319. };
  30320. }
  30321. declare module BABYLON {
  30322. /** @hidden */
  30323. export var logDepthDeclaration: {
  30324. name: string;
  30325. shader: string;
  30326. };
  30327. }
  30328. declare module BABYLON {
  30329. /** @hidden */
  30330. export var bumpFragment: {
  30331. name: string;
  30332. shader: string;
  30333. };
  30334. }
  30335. declare module BABYLON {
  30336. /** @hidden */
  30337. export var depthPrePass: {
  30338. name: string;
  30339. shader: string;
  30340. };
  30341. }
  30342. declare module BABYLON {
  30343. /** @hidden */
  30344. export var lightFragment: {
  30345. name: string;
  30346. shader: string;
  30347. };
  30348. }
  30349. declare module BABYLON {
  30350. /** @hidden */
  30351. export var logDepthFragment: {
  30352. name: string;
  30353. shader: string;
  30354. };
  30355. }
  30356. declare module BABYLON {
  30357. /** @hidden */
  30358. export var defaultPixelShader: {
  30359. name: string;
  30360. shader: string;
  30361. };
  30362. }
  30363. declare module BABYLON {
  30364. /** @hidden */
  30365. export var defaultVertexDeclaration: {
  30366. name: string;
  30367. shader: string;
  30368. };
  30369. }
  30370. declare module BABYLON {
  30371. /** @hidden */
  30372. export var bumpVertexDeclaration: {
  30373. name: string;
  30374. shader: string;
  30375. };
  30376. }
  30377. declare module BABYLON {
  30378. /** @hidden */
  30379. export var bumpVertex: {
  30380. name: string;
  30381. shader: string;
  30382. };
  30383. }
  30384. declare module BABYLON {
  30385. /** @hidden */
  30386. export var fogVertex: {
  30387. name: string;
  30388. shader: string;
  30389. };
  30390. }
  30391. declare module BABYLON {
  30392. /** @hidden */
  30393. export var shadowsVertex: {
  30394. name: string;
  30395. shader: string;
  30396. };
  30397. }
  30398. declare module BABYLON {
  30399. /** @hidden */
  30400. export var pointCloudVertex: {
  30401. name: string;
  30402. shader: string;
  30403. };
  30404. }
  30405. declare module BABYLON {
  30406. /** @hidden */
  30407. export var logDepthVertex: {
  30408. name: string;
  30409. shader: string;
  30410. };
  30411. }
  30412. declare module BABYLON {
  30413. /** @hidden */
  30414. export var defaultVertexShader: {
  30415. name: string;
  30416. shader: string;
  30417. };
  30418. }
  30419. declare module BABYLON {
  30420. /**
  30421. * @hidden
  30422. */
  30423. export interface IMaterialDetailMapDefines {
  30424. DETAIL: boolean;
  30425. DETAILDIRECTUV: number;
  30426. DETAIL_NORMALBLENDMETHOD: number;
  30427. /** @hidden */
  30428. _areTexturesDirty: boolean;
  30429. }
  30430. /**
  30431. * Define the code related to the detail map parameters of a material
  30432. *
  30433. * Inspired from:
  30434. * 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
  30435. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30436. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30437. */
  30438. export class DetailMapConfiguration {
  30439. private _texture;
  30440. /**
  30441. * The detail texture of the material.
  30442. */
  30443. texture: Nullable<BaseTexture>;
  30444. /**
  30445. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30446. * Bigger values mean stronger blending
  30447. */
  30448. diffuseBlendLevel: number;
  30449. /**
  30450. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30451. * Bigger values mean stronger blending. Only used with PBR materials
  30452. */
  30453. roughnessBlendLevel: number;
  30454. /**
  30455. * Defines how strong the bump effect from the detail map is
  30456. * Bigger values mean stronger effect
  30457. */
  30458. bumpLevel: number;
  30459. private _normalBlendMethod;
  30460. /**
  30461. * The method used to blend the bump and detail normals together
  30462. */
  30463. normalBlendMethod: number;
  30464. private _isEnabled;
  30465. /**
  30466. * Enable or disable the detail map on this material
  30467. */
  30468. isEnabled: boolean;
  30469. /** @hidden */
  30470. private _internalMarkAllSubMeshesAsTexturesDirty;
  30471. /** @hidden */
  30472. _markAllSubMeshesAsTexturesDirty(): void;
  30473. /**
  30474. * Instantiate a new detail map
  30475. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30476. */
  30477. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30478. /**
  30479. * Gets whether the submesh is ready to be used or not.
  30480. * @param defines the list of "defines" to update.
  30481. * @param scene defines the scene the material belongs to.
  30482. * @returns - boolean indicating that the submesh is ready or not.
  30483. */
  30484. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30485. /**
  30486. * Update the defines for detail map usage
  30487. * @param defines the list of "defines" to update.
  30488. * @param scene defines the scene the material belongs to.
  30489. */
  30490. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30491. /**
  30492. * Binds the material data.
  30493. * @param uniformBuffer defines the Uniform buffer to fill in.
  30494. * @param scene defines the scene the material belongs to.
  30495. * @param isFrozen defines whether the material is frozen or not.
  30496. */
  30497. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30498. /**
  30499. * Checks to see if a texture is used in the material.
  30500. * @param texture - Base texture to use.
  30501. * @returns - Boolean specifying if a texture is used in the material.
  30502. */
  30503. hasTexture(texture: BaseTexture): boolean;
  30504. /**
  30505. * Returns an array of the actively used textures.
  30506. * @param activeTextures Array of BaseTextures
  30507. */
  30508. getActiveTextures(activeTextures: BaseTexture[]): void;
  30509. /**
  30510. * Returns the animatable textures.
  30511. * @param animatables Array of animatable textures.
  30512. */
  30513. getAnimatables(animatables: IAnimatable[]): void;
  30514. /**
  30515. * Disposes the resources of the material.
  30516. * @param forceDisposeTextures - Forces the disposal of all textures.
  30517. */
  30518. dispose(forceDisposeTextures?: boolean): void;
  30519. /**
  30520. * Get the current class name useful for serialization or dynamic coding.
  30521. * @returns "DetailMap"
  30522. */
  30523. getClassName(): string;
  30524. /**
  30525. * Add the required uniforms to the current list.
  30526. * @param uniforms defines the current uniform list.
  30527. */
  30528. static AddUniforms(uniforms: string[]): void;
  30529. /**
  30530. * Add the required samplers to the current list.
  30531. * @param samplers defines the current sampler list.
  30532. */
  30533. static AddSamplers(samplers: string[]): void;
  30534. /**
  30535. * Add the required uniforms to the current buffer.
  30536. * @param uniformBuffer defines the current uniform buffer.
  30537. */
  30538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30539. /**
  30540. * Makes a duplicate of the current instance into another one.
  30541. * @param detailMap define the instance where to copy the info
  30542. */
  30543. copyTo(detailMap: DetailMapConfiguration): void;
  30544. /**
  30545. * Serializes this detail map instance
  30546. * @returns - An object with the serialized instance.
  30547. */
  30548. serialize(): any;
  30549. /**
  30550. * Parses a detail map setting from a serialized object.
  30551. * @param source - Serialized object.
  30552. * @param scene Defines the scene we are parsing for
  30553. * @param rootUrl Defines the rootUrl to load from
  30554. */
  30555. parse(source: any, scene: Scene, rootUrl: string): void;
  30556. }
  30557. }
  30558. declare module BABYLON {
  30559. /** @hidden */
  30560. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30561. MAINUV1: boolean;
  30562. MAINUV2: boolean;
  30563. DIFFUSE: boolean;
  30564. DIFFUSEDIRECTUV: number;
  30565. DETAIL: boolean;
  30566. DETAILDIRECTUV: number;
  30567. DETAIL_NORMALBLENDMETHOD: number;
  30568. AMBIENT: boolean;
  30569. AMBIENTDIRECTUV: number;
  30570. OPACITY: boolean;
  30571. OPACITYDIRECTUV: number;
  30572. OPACITYRGB: boolean;
  30573. REFLECTION: boolean;
  30574. EMISSIVE: boolean;
  30575. EMISSIVEDIRECTUV: number;
  30576. SPECULAR: boolean;
  30577. SPECULARDIRECTUV: number;
  30578. BUMP: boolean;
  30579. BUMPDIRECTUV: number;
  30580. PARALLAX: boolean;
  30581. PARALLAXOCCLUSION: boolean;
  30582. SPECULAROVERALPHA: boolean;
  30583. CLIPPLANE: boolean;
  30584. CLIPPLANE2: boolean;
  30585. CLIPPLANE3: boolean;
  30586. CLIPPLANE4: boolean;
  30587. CLIPPLANE5: boolean;
  30588. CLIPPLANE6: boolean;
  30589. ALPHATEST: boolean;
  30590. DEPTHPREPASS: boolean;
  30591. ALPHAFROMDIFFUSE: boolean;
  30592. POINTSIZE: boolean;
  30593. FOG: boolean;
  30594. SPECULARTERM: boolean;
  30595. DIFFUSEFRESNEL: boolean;
  30596. OPACITYFRESNEL: boolean;
  30597. REFLECTIONFRESNEL: boolean;
  30598. REFRACTIONFRESNEL: boolean;
  30599. EMISSIVEFRESNEL: boolean;
  30600. FRESNEL: boolean;
  30601. NORMAL: boolean;
  30602. UV1: boolean;
  30603. UV2: boolean;
  30604. VERTEXCOLOR: boolean;
  30605. VERTEXALPHA: boolean;
  30606. NUM_BONE_INFLUENCERS: number;
  30607. BonesPerMesh: number;
  30608. BONETEXTURE: boolean;
  30609. INSTANCES: boolean;
  30610. THIN_INSTANCES: boolean;
  30611. GLOSSINESS: boolean;
  30612. ROUGHNESS: boolean;
  30613. EMISSIVEASILLUMINATION: boolean;
  30614. LINKEMISSIVEWITHDIFFUSE: boolean;
  30615. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30616. LIGHTMAP: boolean;
  30617. LIGHTMAPDIRECTUV: number;
  30618. OBJECTSPACE_NORMALMAP: boolean;
  30619. USELIGHTMAPASSHADOWMAP: boolean;
  30620. REFLECTIONMAP_3D: boolean;
  30621. REFLECTIONMAP_SPHERICAL: boolean;
  30622. REFLECTIONMAP_PLANAR: boolean;
  30623. REFLECTIONMAP_CUBIC: boolean;
  30624. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30625. REFLECTIONMAP_PROJECTION: boolean;
  30626. REFLECTIONMAP_SKYBOX: boolean;
  30627. REFLECTIONMAP_EXPLICIT: boolean;
  30628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30631. INVERTCUBICMAP: boolean;
  30632. LOGARITHMICDEPTH: boolean;
  30633. REFRACTION: boolean;
  30634. REFRACTIONMAP_3D: boolean;
  30635. REFLECTIONOVERALPHA: boolean;
  30636. TWOSIDEDLIGHTING: boolean;
  30637. SHADOWFLOAT: boolean;
  30638. MORPHTARGETS: boolean;
  30639. MORPHTARGETS_NORMAL: boolean;
  30640. MORPHTARGETS_TANGENT: boolean;
  30641. MORPHTARGETS_UV: boolean;
  30642. NUM_MORPH_INFLUENCERS: number;
  30643. NONUNIFORMSCALING: boolean;
  30644. PREMULTIPLYALPHA: boolean;
  30645. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30646. ALPHABLEND: boolean;
  30647. PREPASS: boolean;
  30648. SCENE_MRT_COUNT: number;
  30649. RGBDLIGHTMAP: boolean;
  30650. RGBDREFLECTION: boolean;
  30651. RGBDREFRACTION: boolean;
  30652. IMAGEPROCESSING: boolean;
  30653. VIGNETTE: boolean;
  30654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30655. VIGNETTEBLENDMODEOPAQUE: boolean;
  30656. TONEMAPPING: boolean;
  30657. TONEMAPPING_ACES: boolean;
  30658. CONTRAST: boolean;
  30659. COLORCURVES: boolean;
  30660. COLORGRADING: boolean;
  30661. COLORGRADING3D: boolean;
  30662. SAMPLER3DGREENDEPTH: boolean;
  30663. SAMPLER3DBGRMAP: boolean;
  30664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30665. MULTIVIEW: boolean;
  30666. /**
  30667. * If the reflection texture on this material is in linear color space
  30668. * @hidden
  30669. */
  30670. IS_REFLECTION_LINEAR: boolean;
  30671. /**
  30672. * If the refraction texture on this material is in linear color space
  30673. * @hidden
  30674. */
  30675. IS_REFRACTION_LINEAR: boolean;
  30676. EXPOSURE: boolean;
  30677. constructor();
  30678. setReflectionMode(modeToEnable: string): void;
  30679. }
  30680. /**
  30681. * This is the default material used in Babylon. It is the best trade off between quality
  30682. * and performances.
  30683. * @see https://doc.babylonjs.com/babylon101/materials
  30684. */
  30685. export class StandardMaterial extends PushMaterial {
  30686. private _diffuseTexture;
  30687. /**
  30688. * The basic texture of the material as viewed under a light.
  30689. */
  30690. diffuseTexture: Nullable<BaseTexture>;
  30691. private _ambientTexture;
  30692. /**
  30693. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30694. */
  30695. ambientTexture: Nullable<BaseTexture>;
  30696. private _opacityTexture;
  30697. /**
  30698. * Define the transparency of the material from a texture.
  30699. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30700. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30701. */
  30702. opacityTexture: Nullable<BaseTexture>;
  30703. private _reflectionTexture;
  30704. /**
  30705. * Define the texture used to display the reflection.
  30706. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30707. */
  30708. reflectionTexture: Nullable<BaseTexture>;
  30709. private _emissiveTexture;
  30710. /**
  30711. * Define texture of the material as if self lit.
  30712. * This will be mixed in the final result even in the absence of light.
  30713. */
  30714. emissiveTexture: Nullable<BaseTexture>;
  30715. private _specularTexture;
  30716. /**
  30717. * Define how the color and intensity of the highlight given by the light in the material.
  30718. */
  30719. specularTexture: Nullable<BaseTexture>;
  30720. private _bumpTexture;
  30721. /**
  30722. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30723. * 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.
  30724. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30725. */
  30726. bumpTexture: Nullable<BaseTexture>;
  30727. private _lightmapTexture;
  30728. /**
  30729. * Complex lighting can be computationally expensive to compute at runtime.
  30730. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30731. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30732. */
  30733. lightmapTexture: Nullable<BaseTexture>;
  30734. private _refractionTexture;
  30735. /**
  30736. * Define the texture used to display the refraction.
  30737. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30738. */
  30739. refractionTexture: Nullable<BaseTexture>;
  30740. /**
  30741. * The color of the material lit by the environmental background lighting.
  30742. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30743. */
  30744. ambientColor: Color3;
  30745. /**
  30746. * The basic color of the material as viewed under a light.
  30747. */
  30748. diffuseColor: Color3;
  30749. /**
  30750. * Define how the color and intensity of the highlight given by the light in the material.
  30751. */
  30752. specularColor: Color3;
  30753. /**
  30754. * Define the color of the material as if self lit.
  30755. * This will be mixed in the final result even in the absence of light.
  30756. */
  30757. emissiveColor: Color3;
  30758. /**
  30759. * Defines how sharp are the highlights in the material.
  30760. * The bigger the value the sharper giving a more glossy feeling to the result.
  30761. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30762. */
  30763. specularPower: number;
  30764. private _useAlphaFromDiffuseTexture;
  30765. /**
  30766. * Does the transparency come from the diffuse texture alpha channel.
  30767. */
  30768. useAlphaFromDiffuseTexture: boolean;
  30769. private _useEmissiveAsIllumination;
  30770. /**
  30771. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30772. */
  30773. useEmissiveAsIllumination: boolean;
  30774. private _linkEmissiveWithDiffuse;
  30775. /**
  30776. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30777. * the emissive level when the final color is close to one.
  30778. */
  30779. linkEmissiveWithDiffuse: boolean;
  30780. private _useSpecularOverAlpha;
  30781. /**
  30782. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30783. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30784. */
  30785. useSpecularOverAlpha: boolean;
  30786. private _useReflectionOverAlpha;
  30787. /**
  30788. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30789. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30790. */
  30791. useReflectionOverAlpha: boolean;
  30792. private _disableLighting;
  30793. /**
  30794. * Does lights from the scene impacts this material.
  30795. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30796. */
  30797. disableLighting: boolean;
  30798. private _useObjectSpaceNormalMap;
  30799. /**
  30800. * Allows using an object space normal map (instead of tangent space).
  30801. */
  30802. useObjectSpaceNormalMap: boolean;
  30803. private _useParallax;
  30804. /**
  30805. * Is parallax enabled or not.
  30806. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30807. */
  30808. useParallax: boolean;
  30809. private _useParallaxOcclusion;
  30810. /**
  30811. * Is parallax occlusion enabled or not.
  30812. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30813. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30814. */
  30815. useParallaxOcclusion: boolean;
  30816. /**
  30817. * 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.
  30818. */
  30819. parallaxScaleBias: number;
  30820. private _roughness;
  30821. /**
  30822. * Helps to define how blurry the reflections should appears in the material.
  30823. */
  30824. roughness: number;
  30825. /**
  30826. * In case of refraction, define the value of the index of refraction.
  30827. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30828. */
  30829. indexOfRefraction: number;
  30830. /**
  30831. * Invert the refraction texture alongside the y axis.
  30832. * It can be useful with procedural textures or probe for instance.
  30833. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30834. */
  30835. invertRefractionY: boolean;
  30836. /**
  30837. * Defines the alpha limits in alpha test mode.
  30838. */
  30839. alphaCutOff: number;
  30840. private _useLightmapAsShadowmap;
  30841. /**
  30842. * In case of light mapping, define whether the map contains light or shadow informations.
  30843. */
  30844. useLightmapAsShadowmap: boolean;
  30845. private _diffuseFresnelParameters;
  30846. /**
  30847. * Define the diffuse fresnel parameters of the material.
  30848. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30849. */
  30850. diffuseFresnelParameters: FresnelParameters;
  30851. private _opacityFresnelParameters;
  30852. /**
  30853. * Define the opacity fresnel parameters of the material.
  30854. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30855. */
  30856. opacityFresnelParameters: FresnelParameters;
  30857. private _reflectionFresnelParameters;
  30858. /**
  30859. * Define the reflection fresnel parameters of the material.
  30860. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30861. */
  30862. reflectionFresnelParameters: FresnelParameters;
  30863. private _refractionFresnelParameters;
  30864. /**
  30865. * Define the refraction fresnel parameters of the material.
  30866. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30867. */
  30868. refractionFresnelParameters: FresnelParameters;
  30869. private _emissiveFresnelParameters;
  30870. /**
  30871. * Define the emissive fresnel parameters of the material.
  30872. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30873. */
  30874. emissiveFresnelParameters: FresnelParameters;
  30875. private _useReflectionFresnelFromSpecular;
  30876. /**
  30877. * If true automatically deducts the fresnels values from the material specularity.
  30878. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30879. */
  30880. useReflectionFresnelFromSpecular: boolean;
  30881. private _useGlossinessFromSpecularMapAlpha;
  30882. /**
  30883. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30884. */
  30885. useGlossinessFromSpecularMapAlpha: boolean;
  30886. private _maxSimultaneousLights;
  30887. /**
  30888. * Defines the maximum number of lights that can be used in the material
  30889. */
  30890. maxSimultaneousLights: number;
  30891. private _invertNormalMapX;
  30892. /**
  30893. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30894. */
  30895. invertNormalMapX: boolean;
  30896. private _invertNormalMapY;
  30897. /**
  30898. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30899. */
  30900. invertNormalMapY: boolean;
  30901. private _twoSidedLighting;
  30902. /**
  30903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30904. */
  30905. twoSidedLighting: boolean;
  30906. /**
  30907. * Default configuration related to image processing available in the standard Material.
  30908. */
  30909. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30910. /**
  30911. * Gets the image processing configuration used either in this material.
  30912. */
  30913. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30914. /**
  30915. * Sets the Default image processing configuration used either in the this material.
  30916. *
  30917. * If sets to null, the scene one is in use.
  30918. */
  30919. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30920. /**
  30921. * Keep track of the image processing observer to allow dispose and replace.
  30922. */
  30923. private _imageProcessingObserver;
  30924. /**
  30925. * Attaches a new image processing configuration to the Standard Material.
  30926. * @param configuration
  30927. */
  30928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30929. /**
  30930. * Gets wether the color curves effect is enabled.
  30931. */
  30932. get cameraColorCurvesEnabled(): boolean;
  30933. /**
  30934. * Sets wether the color curves effect is enabled.
  30935. */
  30936. set cameraColorCurvesEnabled(value: boolean);
  30937. /**
  30938. * Gets wether the color grading effect is enabled.
  30939. */
  30940. get cameraColorGradingEnabled(): boolean;
  30941. /**
  30942. * Gets wether the color grading effect is enabled.
  30943. */
  30944. set cameraColorGradingEnabled(value: boolean);
  30945. /**
  30946. * Gets wether tonemapping is enabled or not.
  30947. */
  30948. get cameraToneMappingEnabled(): boolean;
  30949. /**
  30950. * Sets wether tonemapping is enabled or not
  30951. */
  30952. set cameraToneMappingEnabled(value: boolean);
  30953. /**
  30954. * The camera exposure used on this material.
  30955. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30956. * This corresponds to a photographic exposure.
  30957. */
  30958. get cameraExposure(): number;
  30959. /**
  30960. * The camera exposure used on this material.
  30961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30962. * This corresponds to a photographic exposure.
  30963. */
  30964. set cameraExposure(value: number);
  30965. /**
  30966. * Gets The camera contrast used on this material.
  30967. */
  30968. get cameraContrast(): number;
  30969. /**
  30970. * Sets The camera contrast used on this material.
  30971. */
  30972. set cameraContrast(value: number);
  30973. /**
  30974. * Gets the Color Grading 2D Lookup Texture.
  30975. */
  30976. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30977. /**
  30978. * Sets the Color Grading 2D Lookup Texture.
  30979. */
  30980. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30981. /**
  30982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30984. * 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;
  30985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30986. */
  30987. get cameraColorCurves(): Nullable<ColorCurves>;
  30988. /**
  30989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30991. * 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;
  30992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30993. */
  30994. set cameraColorCurves(value: Nullable<ColorCurves>);
  30995. /**
  30996. * Can this material render to several textures at once
  30997. */
  30998. get canRenderToMRT(): boolean;
  30999. /**
  31000. * Defines the detail map parameters for the material.
  31001. */
  31002. readonly detailMap: DetailMapConfiguration;
  31003. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31004. protected _worldViewProjectionMatrix: Matrix;
  31005. protected _globalAmbientColor: Color3;
  31006. protected _useLogarithmicDepth: boolean;
  31007. protected _rebuildInParallel: boolean;
  31008. /**
  31009. * Instantiates a new standard material.
  31010. * This is the default material used in Babylon. It is the best trade off between quality
  31011. * and performances.
  31012. * @see https://doc.babylonjs.com/babylon101/materials
  31013. * @param name Define the name of the material in the scene
  31014. * @param scene Define the scene the material belong to
  31015. */
  31016. constructor(name: string, scene: Scene);
  31017. /**
  31018. * Gets a boolean indicating that current material needs to register RTT
  31019. */
  31020. get hasRenderTargetTextures(): boolean;
  31021. /**
  31022. * Gets the current class name of the material e.g. "StandardMaterial"
  31023. * Mainly use in serialization.
  31024. * @returns the class name
  31025. */
  31026. getClassName(): string;
  31027. /**
  31028. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31029. * You can try switching to logarithmic depth.
  31030. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31031. */
  31032. get useLogarithmicDepth(): boolean;
  31033. set useLogarithmicDepth(value: boolean);
  31034. /**
  31035. * Specifies if the material will require alpha blending
  31036. * @returns a boolean specifying if alpha blending is needed
  31037. */
  31038. needAlphaBlending(): boolean;
  31039. /**
  31040. * Specifies if this material should be rendered in alpha test mode
  31041. * @returns a boolean specifying if an alpha test is needed.
  31042. */
  31043. needAlphaTesting(): boolean;
  31044. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31045. /**
  31046. * Get the texture used for alpha test purpose.
  31047. * @returns the diffuse texture in case of the standard material.
  31048. */
  31049. getAlphaTestTexture(): Nullable<BaseTexture>;
  31050. /**
  31051. * Get if the submesh is ready to be used and all its information available.
  31052. * Child classes can use it to update shaders
  31053. * @param mesh defines the mesh to check
  31054. * @param subMesh defines which submesh to check
  31055. * @param useInstances specifies that instances should be used
  31056. * @returns a boolean indicating that the submesh is ready or not
  31057. */
  31058. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31059. /**
  31060. * Builds the material UBO layouts.
  31061. * Used internally during the effect preparation.
  31062. */
  31063. buildUniformLayout(): void;
  31064. /**
  31065. * Unbinds the material from the mesh
  31066. */
  31067. unbind(): void;
  31068. /**
  31069. * Binds the submesh to this material by preparing the effect and shader to draw
  31070. * @param world defines the world transformation matrix
  31071. * @param mesh defines the mesh containing the submesh
  31072. * @param subMesh defines the submesh to bind the material to
  31073. */
  31074. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31075. /**
  31076. * Get the list of animatables in the material.
  31077. * @returns the list of animatables object used in the material
  31078. */
  31079. getAnimatables(): IAnimatable[];
  31080. /**
  31081. * Gets the active textures from the material
  31082. * @returns an array of textures
  31083. */
  31084. getActiveTextures(): BaseTexture[];
  31085. /**
  31086. * Specifies if the material uses a texture
  31087. * @param texture defines the texture to check against the material
  31088. * @returns a boolean specifying if the material uses the texture
  31089. */
  31090. hasTexture(texture: BaseTexture): boolean;
  31091. /**
  31092. * Disposes the material
  31093. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31094. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31095. */
  31096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31097. /**
  31098. * Makes a duplicate of the material, and gives it a new name
  31099. * @param name defines the new name for the duplicated material
  31100. * @returns the cloned material
  31101. */
  31102. clone(name: string): StandardMaterial;
  31103. /**
  31104. * Serializes this material in a JSON representation
  31105. * @returns the serialized material object
  31106. */
  31107. serialize(): any;
  31108. /**
  31109. * Creates a standard material from parsed material data
  31110. * @param source defines the JSON representation of the material
  31111. * @param scene defines the hosting scene
  31112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31113. * @returns a new standard material
  31114. */
  31115. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31116. /**
  31117. * Are diffuse textures enabled in the application.
  31118. */
  31119. static get DiffuseTextureEnabled(): boolean;
  31120. static set DiffuseTextureEnabled(value: boolean);
  31121. /**
  31122. * Are detail textures enabled in the application.
  31123. */
  31124. static get DetailTextureEnabled(): boolean;
  31125. static set DetailTextureEnabled(value: boolean);
  31126. /**
  31127. * Are ambient textures enabled in the application.
  31128. */
  31129. static get AmbientTextureEnabled(): boolean;
  31130. static set AmbientTextureEnabled(value: boolean);
  31131. /**
  31132. * Are opacity textures enabled in the application.
  31133. */
  31134. static get OpacityTextureEnabled(): boolean;
  31135. static set OpacityTextureEnabled(value: boolean);
  31136. /**
  31137. * Are reflection textures enabled in the application.
  31138. */
  31139. static get ReflectionTextureEnabled(): boolean;
  31140. static set ReflectionTextureEnabled(value: boolean);
  31141. /**
  31142. * Are emissive textures enabled in the application.
  31143. */
  31144. static get EmissiveTextureEnabled(): boolean;
  31145. static set EmissiveTextureEnabled(value: boolean);
  31146. /**
  31147. * Are specular textures enabled in the application.
  31148. */
  31149. static get SpecularTextureEnabled(): boolean;
  31150. static set SpecularTextureEnabled(value: boolean);
  31151. /**
  31152. * Are bump textures enabled in the application.
  31153. */
  31154. static get BumpTextureEnabled(): boolean;
  31155. static set BumpTextureEnabled(value: boolean);
  31156. /**
  31157. * Are lightmap textures enabled in the application.
  31158. */
  31159. static get LightmapTextureEnabled(): boolean;
  31160. static set LightmapTextureEnabled(value: boolean);
  31161. /**
  31162. * Are refraction textures enabled in the application.
  31163. */
  31164. static get RefractionTextureEnabled(): boolean;
  31165. static set RefractionTextureEnabled(value: boolean);
  31166. /**
  31167. * Are color grading textures enabled in the application.
  31168. */
  31169. static get ColorGradingTextureEnabled(): boolean;
  31170. static set ColorGradingTextureEnabled(value: boolean);
  31171. /**
  31172. * Are fresnels enabled in the application.
  31173. */
  31174. static get FresnelEnabled(): boolean;
  31175. static set FresnelEnabled(value: boolean);
  31176. }
  31177. }
  31178. declare module BABYLON {
  31179. /**
  31180. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31181. *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.
  31182. * The SPS is also a particle system. It provides some methods to manage the particles.
  31183. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31184. *
  31185. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31186. */
  31187. export class SolidParticleSystem implements IDisposable {
  31188. /**
  31189. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31190. * Example : var p = SPS.particles[i];
  31191. */
  31192. particles: SolidParticle[];
  31193. /**
  31194. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31195. */
  31196. nbParticles: number;
  31197. /**
  31198. * If the particles must ever face the camera (default false). Useful for planar particles.
  31199. */
  31200. billboard: boolean;
  31201. /**
  31202. * Recompute normals when adding a shape
  31203. */
  31204. recomputeNormals: boolean;
  31205. /**
  31206. * This a counter ofr your own usage. It's not set by any SPS functions.
  31207. */
  31208. counter: number;
  31209. /**
  31210. * The SPS name. This name is also given to the underlying mesh.
  31211. */
  31212. name: string;
  31213. /**
  31214. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31215. */
  31216. mesh: Mesh;
  31217. /**
  31218. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31219. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31220. */
  31221. vars: any;
  31222. /**
  31223. * This array is populated when the SPS is set as 'pickable'.
  31224. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31225. * Each element of this array is an object `{idx: int, faceId: int}`.
  31226. * `idx` is the picked particle index in the `SPS.particles` array
  31227. * `faceId` is the picked face index counted within this particle.
  31228. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31229. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31230. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31231. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31232. */
  31233. pickedParticles: {
  31234. idx: number;
  31235. faceId: number;
  31236. }[];
  31237. /**
  31238. * This array is populated when the SPS is set as 'pickable'
  31239. * Each key of this array is a submesh index.
  31240. * Each element of this array is a second array defined like this :
  31241. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31242. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31243. * `idx` is the picked particle index in the `SPS.particles` array
  31244. * `faceId` is the picked face index counted within this particle.
  31245. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31246. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31247. */
  31248. pickedBySubMesh: {
  31249. idx: number;
  31250. faceId: number;
  31251. }[][];
  31252. /**
  31253. * This array is populated when `enableDepthSort` is set to true.
  31254. * Each element of this array is an instance of the class DepthSortedParticle.
  31255. */
  31256. depthSortedParticles: DepthSortedParticle[];
  31257. /**
  31258. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31259. * @hidden
  31260. */
  31261. _bSphereOnly: boolean;
  31262. /**
  31263. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31264. * @hidden
  31265. */
  31266. _bSphereRadiusFactor: number;
  31267. private _scene;
  31268. private _positions;
  31269. private _indices;
  31270. private _normals;
  31271. private _colors;
  31272. private _uvs;
  31273. private _indices32;
  31274. private _positions32;
  31275. private _normals32;
  31276. private _fixedNormal32;
  31277. private _colors32;
  31278. private _uvs32;
  31279. private _index;
  31280. private _updatable;
  31281. private _pickable;
  31282. private _isVisibilityBoxLocked;
  31283. private _alwaysVisible;
  31284. private _depthSort;
  31285. private _expandable;
  31286. private _shapeCounter;
  31287. private _copy;
  31288. private _color;
  31289. private _computeParticleColor;
  31290. private _computeParticleTexture;
  31291. private _computeParticleRotation;
  31292. private _computeParticleVertex;
  31293. private _computeBoundingBox;
  31294. private _depthSortParticles;
  31295. private _camera;
  31296. private _mustUnrotateFixedNormals;
  31297. private _particlesIntersect;
  31298. private _needs32Bits;
  31299. private _isNotBuilt;
  31300. private _lastParticleId;
  31301. private _idxOfId;
  31302. private _multimaterialEnabled;
  31303. private _useModelMaterial;
  31304. private _indicesByMaterial;
  31305. private _materialIndexes;
  31306. private _depthSortFunction;
  31307. private _materialSortFunction;
  31308. private _materials;
  31309. private _multimaterial;
  31310. private _materialIndexesById;
  31311. private _defaultMaterial;
  31312. private _autoUpdateSubMeshes;
  31313. private _tmpVertex;
  31314. /**
  31315. * Creates a SPS (Solid Particle System) object.
  31316. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31317. * @param scene (Scene) is the scene in which the SPS is added.
  31318. * @param options defines the options of the sps e.g.
  31319. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31320. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31321. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31322. * * 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.
  31323. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31324. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31325. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31326. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31327. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31328. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31329. */
  31330. constructor(name: string, scene: Scene, options?: {
  31331. updatable?: boolean;
  31332. isPickable?: boolean;
  31333. enableDepthSort?: boolean;
  31334. particleIntersection?: boolean;
  31335. boundingSphereOnly?: boolean;
  31336. bSphereRadiusFactor?: number;
  31337. expandable?: boolean;
  31338. useModelMaterial?: boolean;
  31339. enableMultiMaterial?: boolean;
  31340. });
  31341. /**
  31342. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31343. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31344. * @returns the created mesh
  31345. */
  31346. buildMesh(): Mesh;
  31347. /**
  31348. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31349. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31350. * Thus the particles generated from `digest()` have their property `position` set yet.
  31351. * @param mesh ( Mesh ) is the mesh to be digested
  31352. * @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
  31353. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31354. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31355. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31356. * @returns the current SPS
  31357. */
  31358. digest(mesh: Mesh, options?: {
  31359. facetNb?: number;
  31360. number?: number;
  31361. delta?: number;
  31362. storage?: [];
  31363. }): SolidParticleSystem;
  31364. /**
  31365. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31366. * @hidden
  31367. */
  31368. private _unrotateFixedNormals;
  31369. /**
  31370. * Resets the temporary working copy particle
  31371. * @hidden
  31372. */
  31373. private _resetCopy;
  31374. /**
  31375. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31376. * @param p the current index in the positions array to be updated
  31377. * @param ind the current index in the indices array
  31378. * @param shape a Vector3 array, the shape geometry
  31379. * @param positions the positions array to be updated
  31380. * @param meshInd the shape indices array
  31381. * @param indices the indices array to be updated
  31382. * @param meshUV the shape uv array
  31383. * @param uvs the uv array to be updated
  31384. * @param meshCol the shape color array
  31385. * @param colors the color array to be updated
  31386. * @param meshNor the shape normals array
  31387. * @param normals the normals array to be updated
  31388. * @param idx the particle index
  31389. * @param idxInShape the particle index in its shape
  31390. * @param options the addShape() method passed options
  31391. * @model the particle model
  31392. * @hidden
  31393. */
  31394. private _meshBuilder;
  31395. /**
  31396. * Returns a shape Vector3 array from positions float array
  31397. * @param positions float array
  31398. * @returns a vector3 array
  31399. * @hidden
  31400. */
  31401. private _posToShape;
  31402. /**
  31403. * Returns a shapeUV array from a float uvs (array deep copy)
  31404. * @param uvs as a float array
  31405. * @returns a shapeUV array
  31406. * @hidden
  31407. */
  31408. private _uvsToShapeUV;
  31409. /**
  31410. * Adds a new particle object in the particles array
  31411. * @param idx particle index in particles array
  31412. * @param id particle id
  31413. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31414. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31415. * @param model particle ModelShape object
  31416. * @param shapeId model shape identifier
  31417. * @param idxInShape index of the particle in the current model
  31418. * @param bInfo model bounding info object
  31419. * @param storage target storage array, if any
  31420. * @hidden
  31421. */
  31422. private _addParticle;
  31423. /**
  31424. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31425. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31426. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31427. * @param nb (positive integer) the number of particles to be created from this model
  31428. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31429. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31430. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31431. * @returns the number of shapes in the system
  31432. */
  31433. addShape(mesh: Mesh, nb: number, options?: {
  31434. positionFunction?: any;
  31435. vertexFunction?: any;
  31436. storage?: [];
  31437. }): number;
  31438. /**
  31439. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31440. * @hidden
  31441. */
  31442. private _rebuildParticle;
  31443. /**
  31444. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31445. * @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.
  31446. * @returns the SPS.
  31447. */
  31448. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31449. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31450. * Returns an array with the removed particles.
  31451. * 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.
  31452. * The SPS can't be empty so at least one particle needs to remain in place.
  31453. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31454. * @param start index of the first particle to remove
  31455. * @param end index of the last particle to remove (included)
  31456. * @returns an array populated with the removed particles
  31457. */
  31458. removeParticles(start: number, end: number): SolidParticle[];
  31459. /**
  31460. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31461. * @param solidParticleArray an array populated with Solid Particles objects
  31462. * @returns the SPS
  31463. */
  31464. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31465. /**
  31466. * Creates a new particle and modifies the SPS mesh geometry :
  31467. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31468. * - calls _addParticle() to populate the particle array
  31469. * factorized code from addShape() and insertParticlesFromArray()
  31470. * @param idx particle index in the particles array
  31471. * @param i particle index in its shape
  31472. * @param modelShape particle ModelShape object
  31473. * @param shape shape vertex array
  31474. * @param meshInd shape indices array
  31475. * @param meshUV shape uv array
  31476. * @param meshCol shape color array
  31477. * @param meshNor shape normals array
  31478. * @param bbInfo shape bounding info
  31479. * @param storage target particle storage
  31480. * @options addShape() passed options
  31481. * @hidden
  31482. */
  31483. private _insertNewParticle;
  31484. /**
  31485. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31486. * This method calls `updateParticle()` for each particle of the SPS.
  31487. * For an animated SPS, it is usually called within the render loop.
  31488. * 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.
  31489. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31490. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31491. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31492. * @returns the SPS.
  31493. */
  31494. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31495. /**
  31496. * Disposes the SPS.
  31497. */
  31498. dispose(): void;
  31499. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31500. * idx is the particle index in the SPS
  31501. * faceId is the picked face index counted within this particle.
  31502. * Returns null if the pickInfo can't identify a picked particle.
  31503. * @param pickingInfo (PickingInfo object)
  31504. * @returns {idx: number, faceId: number} or null
  31505. */
  31506. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31507. idx: number;
  31508. faceId: number;
  31509. }>;
  31510. /**
  31511. * Returns a SolidParticle object from its identifier : particle.id
  31512. * @param id (integer) the particle Id
  31513. * @returns the searched particle or null if not found in the SPS.
  31514. */
  31515. getParticleById(id: number): Nullable<SolidParticle>;
  31516. /**
  31517. * Returns a new array populated with the particles having the passed shapeId.
  31518. * @param shapeId (integer) the shape identifier
  31519. * @returns a new solid particle array
  31520. */
  31521. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31522. /**
  31523. * Populates the passed array "ref" with the particles having the passed shapeId.
  31524. * @param shapeId the shape identifier
  31525. * @returns the SPS
  31526. * @param ref
  31527. */
  31528. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31529. /**
  31530. * Computes the required SubMeshes according the materials assigned to the particles.
  31531. * @returns the solid particle system.
  31532. * Does nothing if called before the SPS mesh is built.
  31533. */
  31534. computeSubMeshes(): SolidParticleSystem;
  31535. /**
  31536. * Sorts the solid particles by material when MultiMaterial is enabled.
  31537. * Updates the indices32 array.
  31538. * Updates the indicesByMaterial array.
  31539. * Updates the mesh indices array.
  31540. * @returns the SPS
  31541. * @hidden
  31542. */
  31543. private _sortParticlesByMaterial;
  31544. /**
  31545. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31546. * @hidden
  31547. */
  31548. private _setMaterialIndexesById;
  31549. /**
  31550. * Returns an array with unique values of Materials from the passed array
  31551. * @param array the material array to be checked and filtered
  31552. * @hidden
  31553. */
  31554. private _filterUniqueMaterialId;
  31555. /**
  31556. * Sets a new Standard Material as _defaultMaterial if not already set.
  31557. * @hidden
  31558. */
  31559. private _setDefaultMaterial;
  31560. /**
  31561. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31562. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31563. * @returns the SPS.
  31564. */
  31565. refreshVisibleSize(): SolidParticleSystem;
  31566. /**
  31567. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31568. * @param size the size (float) of the visibility box
  31569. * note : this doesn't lock the SPS mesh bounding box.
  31570. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31571. */
  31572. setVisibilityBox(size: number): void;
  31573. /**
  31574. * Gets whether the SPS as always visible or not
  31575. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31576. */
  31577. get isAlwaysVisible(): boolean;
  31578. /**
  31579. * Sets the SPS as always visible or not
  31580. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31581. */
  31582. set isAlwaysVisible(val: boolean);
  31583. /**
  31584. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31585. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31586. */
  31587. set isVisibilityBoxLocked(val: boolean);
  31588. /**
  31589. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31590. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31591. */
  31592. get isVisibilityBoxLocked(): boolean;
  31593. /**
  31594. * Tells to `setParticles()` to compute the particle rotations or not.
  31595. * Default value : true. The SPS is faster when it's set to false.
  31596. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31597. */
  31598. set computeParticleRotation(val: boolean);
  31599. /**
  31600. * Tells to `setParticles()` to compute the particle colors or not.
  31601. * Default value : true. The SPS is faster when it's set to false.
  31602. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31603. */
  31604. set computeParticleColor(val: boolean);
  31605. set computeParticleTexture(val: boolean);
  31606. /**
  31607. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31608. * Default value : false. The SPS is faster when it's set to false.
  31609. * Note : the particle custom vertex positions aren't stored values.
  31610. */
  31611. set computeParticleVertex(val: boolean);
  31612. /**
  31613. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31614. */
  31615. set computeBoundingBox(val: boolean);
  31616. /**
  31617. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31618. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31619. * Default : `true`
  31620. */
  31621. set depthSortParticles(val: boolean);
  31622. /**
  31623. * Gets if `setParticles()` computes the particle rotations or not.
  31624. * Default value : true. The SPS is faster when it's set to false.
  31625. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31626. */
  31627. get computeParticleRotation(): boolean;
  31628. /**
  31629. * Gets if `setParticles()` computes the particle colors or not.
  31630. * Default value : true. The SPS is faster when it's set to false.
  31631. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31632. */
  31633. get computeParticleColor(): boolean;
  31634. /**
  31635. * Gets if `setParticles()` computes the particle textures or not.
  31636. * Default value : true. The SPS is faster when it's set to false.
  31637. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31638. */
  31639. get computeParticleTexture(): boolean;
  31640. /**
  31641. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31642. * Default value : false. The SPS is faster when it's set to false.
  31643. * Note : the particle custom vertex positions aren't stored values.
  31644. */
  31645. get computeParticleVertex(): boolean;
  31646. /**
  31647. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31648. */
  31649. get computeBoundingBox(): boolean;
  31650. /**
  31651. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31652. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31653. * Default : `true`
  31654. */
  31655. get depthSortParticles(): boolean;
  31656. /**
  31657. * Gets if the SPS is created as expandable at construction time.
  31658. * Default : `false`
  31659. */
  31660. get expandable(): boolean;
  31661. /**
  31662. * Gets if the SPS supports the Multi Materials
  31663. */
  31664. get multimaterialEnabled(): boolean;
  31665. /**
  31666. * Gets if the SPS uses the model materials for its own multimaterial.
  31667. */
  31668. get useModelMaterial(): boolean;
  31669. /**
  31670. * The SPS used material array.
  31671. */
  31672. get materials(): Material[];
  31673. /**
  31674. * Sets the SPS MultiMaterial from the passed materials.
  31675. * Note : the passed array is internally copied and not used then by reference.
  31676. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31677. */
  31678. setMultiMaterial(materials: Material[]): void;
  31679. /**
  31680. * The SPS computed multimaterial object
  31681. */
  31682. get multimaterial(): MultiMaterial;
  31683. set multimaterial(mm: MultiMaterial);
  31684. /**
  31685. * If the subMeshes must be updated on the next call to setParticles()
  31686. */
  31687. get autoUpdateSubMeshes(): boolean;
  31688. set autoUpdateSubMeshes(val: boolean);
  31689. /**
  31690. * This function does nothing. It may be overwritten to set all the particle first values.
  31691. * The SPS doesn't call this function, you may have to call it by your own.
  31692. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31693. */
  31694. initParticles(): void;
  31695. /**
  31696. * This function does nothing. It may be overwritten to recycle a particle.
  31697. * The SPS doesn't call this function, you may have to call it by your own.
  31698. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31699. * @param particle The particle to recycle
  31700. * @returns the recycled particle
  31701. */
  31702. recycleParticle(particle: SolidParticle): SolidParticle;
  31703. /**
  31704. * Updates a particle : this function should be overwritten by the user.
  31705. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31706. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31707. * @example : just set a particle position or velocity and recycle conditions
  31708. * @param particle The particle to update
  31709. * @returns the updated particle
  31710. */
  31711. updateParticle(particle: SolidParticle): SolidParticle;
  31712. /**
  31713. * Updates a vertex of a particle : it can be overwritten by the user.
  31714. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31715. * @param particle the current particle
  31716. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31717. * @param pt the index of the current vertex in the particle shape
  31718. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31719. * @example : just set a vertex particle position or color
  31720. * @returns the sps
  31721. */
  31722. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31723. /**
  31724. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31725. * This does nothing and may be overwritten by the user.
  31726. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31727. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31728. * @param update the boolean update value actually passed to setParticles()
  31729. */
  31730. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31731. /**
  31732. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31733. * This will be passed three parameters.
  31734. * This does nothing and may be overwritten by the user.
  31735. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31736. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31737. * @param update the boolean update value actually passed to setParticles()
  31738. */
  31739. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31740. }
  31741. }
  31742. declare module BABYLON {
  31743. /**
  31744. * Represents one particle of a solid particle system.
  31745. */
  31746. export class SolidParticle {
  31747. /**
  31748. * particle global index
  31749. */
  31750. idx: number;
  31751. /**
  31752. * particle identifier
  31753. */
  31754. id: number;
  31755. /**
  31756. * The color of the particle
  31757. */
  31758. color: Nullable<Color4>;
  31759. /**
  31760. * The world space position of the particle.
  31761. */
  31762. position: Vector3;
  31763. /**
  31764. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31765. */
  31766. rotation: Vector3;
  31767. /**
  31768. * The world space rotation quaternion of the particle.
  31769. */
  31770. rotationQuaternion: Nullable<Quaternion>;
  31771. /**
  31772. * The scaling of the particle.
  31773. */
  31774. scaling: Vector3;
  31775. /**
  31776. * The uvs of the particle.
  31777. */
  31778. uvs: Vector4;
  31779. /**
  31780. * The current speed of the particle.
  31781. */
  31782. velocity: Vector3;
  31783. /**
  31784. * The pivot point in the particle local space.
  31785. */
  31786. pivot: Vector3;
  31787. /**
  31788. * Must the particle be translated from its pivot point in its local space ?
  31789. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31790. * Default : false
  31791. */
  31792. translateFromPivot: boolean;
  31793. /**
  31794. * Is the particle active or not ?
  31795. */
  31796. alive: boolean;
  31797. /**
  31798. * Is the particle visible or not ?
  31799. */
  31800. isVisible: boolean;
  31801. /**
  31802. * Index of this particle in the global "positions" array (Internal use)
  31803. * @hidden
  31804. */
  31805. _pos: number;
  31806. /**
  31807. * @hidden Index of this particle in the global "indices" array (Internal use)
  31808. */
  31809. _ind: number;
  31810. /**
  31811. * @hidden ModelShape of this particle (Internal use)
  31812. */
  31813. _model: ModelShape;
  31814. /**
  31815. * ModelShape id of this particle
  31816. */
  31817. shapeId: number;
  31818. /**
  31819. * Index of the particle in its shape id
  31820. */
  31821. idxInShape: number;
  31822. /**
  31823. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31824. */
  31825. _modelBoundingInfo: BoundingInfo;
  31826. /**
  31827. * @hidden Particle BoundingInfo object (Internal use)
  31828. */
  31829. _boundingInfo: BoundingInfo;
  31830. /**
  31831. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31832. */
  31833. _sps: SolidParticleSystem;
  31834. /**
  31835. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31836. */
  31837. _stillInvisible: boolean;
  31838. /**
  31839. * @hidden Last computed particle rotation matrix
  31840. */
  31841. _rotationMatrix: number[];
  31842. /**
  31843. * Parent particle Id, if any.
  31844. * Default null.
  31845. */
  31846. parentId: Nullable<number>;
  31847. /**
  31848. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31849. */
  31850. materialIndex: Nullable<number>;
  31851. /**
  31852. * Custom object or properties.
  31853. */
  31854. props: Nullable<any>;
  31855. /**
  31856. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31857. * The possible values are :
  31858. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31859. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31862. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31863. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31864. * */
  31865. cullingStrategy: number;
  31866. /**
  31867. * @hidden Internal global position in the SPS.
  31868. */
  31869. _globalPosition: Vector3;
  31870. /**
  31871. * Creates a Solid Particle object.
  31872. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31873. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31874. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31875. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31876. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31877. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31878. * @param shapeId (integer) is the model shape identifier in the SPS.
  31879. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31880. * @param sps defines the sps it is associated to
  31881. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31882. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31883. */
  31884. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31885. /**
  31886. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31887. * @param target the particle target
  31888. * @returns the current particle
  31889. */
  31890. copyToRef(target: SolidParticle): SolidParticle;
  31891. /**
  31892. * Legacy support, changed scale to scaling
  31893. */
  31894. get scale(): Vector3;
  31895. /**
  31896. * Legacy support, changed scale to scaling
  31897. */
  31898. set scale(scale: Vector3);
  31899. /**
  31900. * Legacy support, changed quaternion to rotationQuaternion
  31901. */
  31902. get quaternion(): Nullable<Quaternion>;
  31903. /**
  31904. * Legacy support, changed quaternion to rotationQuaternion
  31905. */
  31906. set quaternion(q: Nullable<Quaternion>);
  31907. /**
  31908. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31909. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31910. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31911. * @returns true if it intersects
  31912. */
  31913. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31914. /**
  31915. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31916. * A particle is in the frustum if its bounding box intersects the frustum
  31917. * @param frustumPlanes defines the frustum to test
  31918. * @returns true if the particle is in the frustum planes
  31919. */
  31920. isInFrustum(frustumPlanes: Plane[]): boolean;
  31921. /**
  31922. * get the rotation matrix of the particle
  31923. * @hidden
  31924. */
  31925. getRotationMatrix(m: Matrix): void;
  31926. }
  31927. /**
  31928. * Represents the shape of the model used by one particle of a solid particle system.
  31929. * SPS internal tool, don't use it manually.
  31930. */
  31931. export class ModelShape {
  31932. /**
  31933. * The shape id
  31934. * @hidden
  31935. */
  31936. shapeID: number;
  31937. /**
  31938. * flat array of model positions (internal use)
  31939. * @hidden
  31940. */
  31941. _shape: Vector3[];
  31942. /**
  31943. * flat array of model UVs (internal use)
  31944. * @hidden
  31945. */
  31946. _shapeUV: number[];
  31947. /**
  31948. * color array of the model
  31949. * @hidden
  31950. */
  31951. _shapeColors: number[];
  31952. /**
  31953. * indices array of the model
  31954. * @hidden
  31955. */
  31956. _indices: number[];
  31957. /**
  31958. * normals array of the model
  31959. * @hidden
  31960. */
  31961. _normals: number[];
  31962. /**
  31963. * length of the shape in the model indices array (internal use)
  31964. * @hidden
  31965. */
  31966. _indicesLength: number;
  31967. /**
  31968. * Custom position function (internal use)
  31969. * @hidden
  31970. */
  31971. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31972. /**
  31973. * Custom vertex function (internal use)
  31974. * @hidden
  31975. */
  31976. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31977. /**
  31978. * Model material (internal use)
  31979. * @hidden
  31980. */
  31981. _material: Nullable<Material>;
  31982. /**
  31983. * 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.
  31984. * SPS internal tool, don't use it manually.
  31985. * @hidden
  31986. */
  31987. 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>);
  31988. }
  31989. /**
  31990. * Represents a Depth Sorted Particle in the solid particle system.
  31991. * @hidden
  31992. */
  31993. export class DepthSortedParticle {
  31994. /**
  31995. * Particle index
  31996. */
  31997. idx: number;
  31998. /**
  31999. * Index of the particle in the "indices" array
  32000. */
  32001. ind: number;
  32002. /**
  32003. * Length of the particle shape in the "indices" array
  32004. */
  32005. indicesLength: number;
  32006. /**
  32007. * Squared distance from the particle to the camera
  32008. */
  32009. sqDistance: number;
  32010. /**
  32011. * Material index when used with MultiMaterials
  32012. */
  32013. materialIndex: number;
  32014. /**
  32015. * Creates a new sorted particle
  32016. * @param materialIndex
  32017. */
  32018. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32019. }
  32020. /**
  32021. * Represents a solid particle vertex
  32022. */
  32023. export class SolidParticleVertex {
  32024. /**
  32025. * Vertex position
  32026. */
  32027. position: Vector3;
  32028. /**
  32029. * Vertex color
  32030. */
  32031. color: Color4;
  32032. /**
  32033. * Vertex UV
  32034. */
  32035. uv: Vector2;
  32036. /**
  32037. * Creates a new solid particle vertex
  32038. */
  32039. constructor();
  32040. /** Vertex x coordinate */
  32041. get x(): number;
  32042. set x(val: number);
  32043. /** Vertex y coordinate */
  32044. get y(): number;
  32045. set y(val: number);
  32046. /** Vertex z coordinate */
  32047. get z(): number;
  32048. set z(val: number);
  32049. }
  32050. }
  32051. declare module BABYLON {
  32052. /**
  32053. * @hidden
  32054. */
  32055. export class _MeshCollisionData {
  32056. _checkCollisions: boolean;
  32057. _collisionMask: number;
  32058. _collisionGroup: number;
  32059. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32060. _collider: Nullable<Collider>;
  32061. _oldPositionForCollisions: Vector3;
  32062. _diffPositionForCollisions: Vector3;
  32063. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32064. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32065. _collisionResponse: boolean;
  32066. }
  32067. }
  32068. declare module BABYLON {
  32069. /** @hidden */
  32070. class _FacetDataStorage {
  32071. facetPositions: Vector3[];
  32072. facetNormals: Vector3[];
  32073. facetPartitioning: number[][];
  32074. facetNb: number;
  32075. partitioningSubdivisions: number;
  32076. partitioningBBoxRatio: number;
  32077. facetDataEnabled: boolean;
  32078. facetParameters: any;
  32079. bbSize: Vector3;
  32080. subDiv: {
  32081. max: number;
  32082. X: number;
  32083. Y: number;
  32084. Z: number;
  32085. };
  32086. facetDepthSort: boolean;
  32087. facetDepthSortEnabled: boolean;
  32088. depthSortedIndices: IndicesArray;
  32089. depthSortedFacets: {
  32090. ind: number;
  32091. sqDistance: number;
  32092. }[];
  32093. facetDepthSortFunction: (f1: {
  32094. ind: number;
  32095. sqDistance: number;
  32096. }, f2: {
  32097. ind: number;
  32098. sqDistance: number;
  32099. }) => number;
  32100. facetDepthSortFrom: Vector3;
  32101. facetDepthSortOrigin: Vector3;
  32102. invertedMatrix: Matrix;
  32103. }
  32104. /**
  32105. * @hidden
  32106. **/
  32107. class _InternalAbstractMeshDataInfo {
  32108. _hasVertexAlpha: boolean;
  32109. _useVertexColors: boolean;
  32110. _numBoneInfluencers: number;
  32111. _applyFog: boolean;
  32112. _receiveShadows: boolean;
  32113. _facetData: _FacetDataStorage;
  32114. _visibility: number;
  32115. _skeleton: Nullable<Skeleton>;
  32116. _layerMask: number;
  32117. _computeBonesUsingShaders: boolean;
  32118. _isActive: boolean;
  32119. _onlyForInstances: boolean;
  32120. _isActiveIntermediate: boolean;
  32121. _onlyForInstancesIntermediate: boolean;
  32122. _actAsRegularMesh: boolean;
  32123. }
  32124. /**
  32125. * Class used to store all common mesh properties
  32126. */
  32127. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32128. /** No occlusion */
  32129. static OCCLUSION_TYPE_NONE: number;
  32130. /** Occlusion set to optimisitic */
  32131. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32132. /** Occlusion set to strict */
  32133. static OCCLUSION_TYPE_STRICT: number;
  32134. /** Use an accurante occlusion algorithm */
  32135. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32136. /** Use a conservative occlusion algorithm */
  32137. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32138. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32139. * Test order :
  32140. * Is the bounding sphere outside the frustum ?
  32141. * If not, are the bounding box vertices outside the frustum ?
  32142. * It not, then the cullable object is in the frustum.
  32143. */
  32144. static readonly CULLINGSTRATEGY_STANDARD: number;
  32145. /** Culling strategy : Bounding Sphere Only.
  32146. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32147. * It's also less accurate than the standard because some not visible objects can still be selected.
  32148. * Test : is the bounding sphere outside the frustum ?
  32149. * If not, then the cullable object is in the frustum.
  32150. */
  32151. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32152. /** Culling strategy : Optimistic Inclusion.
  32153. * This in an inclusion test first, then the standard exclusion test.
  32154. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32155. * 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.
  32156. * Anyway, it's as accurate as the standard strategy.
  32157. * Test :
  32158. * Is the cullable object bounding sphere center in the frustum ?
  32159. * If not, apply the default culling strategy.
  32160. */
  32161. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32162. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32163. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32164. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32165. * 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.
  32166. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32167. * Test :
  32168. * Is the cullable object bounding sphere center in the frustum ?
  32169. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32170. */
  32171. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32172. /**
  32173. * No billboard
  32174. */
  32175. static get BILLBOARDMODE_NONE(): number;
  32176. /** Billboard on X axis */
  32177. static get BILLBOARDMODE_X(): number;
  32178. /** Billboard on Y axis */
  32179. static get BILLBOARDMODE_Y(): number;
  32180. /** Billboard on Z axis */
  32181. static get BILLBOARDMODE_Z(): number;
  32182. /** Billboard on all axes */
  32183. static get BILLBOARDMODE_ALL(): number;
  32184. /** Billboard on using position instead of orientation */
  32185. static get BILLBOARDMODE_USE_POSITION(): number;
  32186. /** @hidden */
  32187. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32188. /**
  32189. * The culling strategy to use to check whether the mesh must be rendered or not.
  32190. * This value can be changed at any time and will be used on the next render mesh selection.
  32191. * The possible values are :
  32192. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32193. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32194. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32195. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32196. * Please read each static variable documentation to get details about the culling process.
  32197. * */
  32198. cullingStrategy: number;
  32199. /**
  32200. * Gets the number of facets in the mesh
  32201. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32202. */
  32203. get facetNb(): number;
  32204. /**
  32205. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32207. */
  32208. get partitioningSubdivisions(): number;
  32209. set partitioningSubdivisions(nb: number);
  32210. /**
  32211. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32212. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32214. */
  32215. get partitioningBBoxRatio(): number;
  32216. set partitioningBBoxRatio(ratio: number);
  32217. /**
  32218. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32219. * Works only for updatable meshes.
  32220. * Doesn't work with multi-materials
  32221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32222. */
  32223. get mustDepthSortFacets(): boolean;
  32224. set mustDepthSortFacets(sort: boolean);
  32225. /**
  32226. * The location (Vector3) where the facet depth sort must be computed from.
  32227. * By default, the active camera position.
  32228. * Used only when facet depth sort is enabled
  32229. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32230. */
  32231. get facetDepthSortFrom(): Vector3;
  32232. set facetDepthSortFrom(location: Vector3);
  32233. /**
  32234. * gets a boolean indicating if facetData is enabled
  32235. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32236. */
  32237. get isFacetDataEnabled(): boolean;
  32238. /** @hidden */
  32239. _updateNonUniformScalingState(value: boolean): boolean;
  32240. /**
  32241. * An event triggered when this mesh collides with another one
  32242. */
  32243. onCollideObservable: Observable<AbstractMesh>;
  32244. /** Set a function to call when this mesh collides with another one */
  32245. set onCollide(callback: () => void);
  32246. /**
  32247. * An event triggered when the collision's position changes
  32248. */
  32249. onCollisionPositionChangeObservable: Observable<Vector3>;
  32250. /** Set a function to call when the collision's position changes */
  32251. set onCollisionPositionChange(callback: () => void);
  32252. /**
  32253. * An event triggered when material is changed
  32254. */
  32255. onMaterialChangedObservable: Observable<AbstractMesh>;
  32256. /**
  32257. * Gets or sets the orientation for POV movement & rotation
  32258. */
  32259. definedFacingForward: boolean;
  32260. /** @hidden */
  32261. _occlusionQuery: Nullable<WebGLQuery>;
  32262. /** @hidden */
  32263. _renderingGroup: Nullable<RenderingGroup>;
  32264. /**
  32265. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32266. */
  32267. get visibility(): number;
  32268. /**
  32269. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32270. */
  32271. set visibility(value: number);
  32272. /** Gets or sets the alpha index used to sort transparent meshes
  32273. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32274. */
  32275. alphaIndex: number;
  32276. /**
  32277. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32278. */
  32279. isVisible: boolean;
  32280. /**
  32281. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32282. */
  32283. isPickable: boolean;
  32284. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32285. showSubMeshesBoundingBox: boolean;
  32286. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32287. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32288. */
  32289. isBlocker: boolean;
  32290. /**
  32291. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32292. */
  32293. enablePointerMoveEvents: boolean;
  32294. private _renderingGroupId;
  32295. /**
  32296. * Specifies the rendering group id for this mesh (0 by default)
  32297. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32298. */
  32299. get renderingGroupId(): number;
  32300. set renderingGroupId(value: number);
  32301. private _material;
  32302. /** Gets or sets current material */
  32303. get material(): Nullable<Material>;
  32304. set material(value: Nullable<Material>);
  32305. /**
  32306. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32307. * @see https://doc.babylonjs.com/babylon101/shadows
  32308. */
  32309. get receiveShadows(): boolean;
  32310. set receiveShadows(value: boolean);
  32311. /** Defines color to use when rendering outline */
  32312. outlineColor: Color3;
  32313. /** Define width to use when rendering outline */
  32314. outlineWidth: number;
  32315. /** Defines color to use when rendering overlay */
  32316. overlayColor: Color3;
  32317. /** Defines alpha to use when rendering overlay */
  32318. overlayAlpha: number;
  32319. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32320. get hasVertexAlpha(): boolean;
  32321. set hasVertexAlpha(value: boolean);
  32322. /** 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) */
  32323. get useVertexColors(): boolean;
  32324. set useVertexColors(value: boolean);
  32325. /**
  32326. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32327. */
  32328. get computeBonesUsingShaders(): boolean;
  32329. set computeBonesUsingShaders(value: boolean);
  32330. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32331. get numBoneInfluencers(): number;
  32332. set numBoneInfluencers(value: number);
  32333. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32334. get applyFog(): boolean;
  32335. set applyFog(value: boolean);
  32336. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32337. useOctreeForRenderingSelection: boolean;
  32338. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32339. useOctreeForPicking: boolean;
  32340. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32341. useOctreeForCollisions: boolean;
  32342. /**
  32343. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32344. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32345. */
  32346. get layerMask(): number;
  32347. set layerMask(value: number);
  32348. /**
  32349. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32350. */
  32351. alwaysSelectAsActiveMesh: boolean;
  32352. /**
  32353. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32354. */
  32355. doNotSyncBoundingInfo: boolean;
  32356. /**
  32357. * Gets or sets the current action manager
  32358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32359. */
  32360. actionManager: Nullable<AbstractActionManager>;
  32361. private _meshCollisionData;
  32362. /**
  32363. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32364. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32365. */
  32366. ellipsoid: Vector3;
  32367. /**
  32368. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32369. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32370. */
  32371. ellipsoidOffset: Vector3;
  32372. /**
  32373. * Gets or sets a collision mask used to mask collisions (default is -1).
  32374. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32375. */
  32376. get collisionMask(): number;
  32377. set collisionMask(mask: number);
  32378. /**
  32379. * Gets or sets a collision response flag (default is true).
  32380. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32381. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32382. * to respond to the collision.
  32383. */
  32384. get collisionResponse(): boolean;
  32385. set collisionResponse(response: boolean);
  32386. /**
  32387. * Gets or sets the current collision group mask (-1 by default).
  32388. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32389. */
  32390. get collisionGroup(): number;
  32391. set collisionGroup(mask: number);
  32392. /**
  32393. * Gets or sets current surrounding meshes (null by default).
  32394. *
  32395. * By default collision detection is tested against every mesh in the scene.
  32396. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32397. * meshes will be tested for the collision.
  32398. *
  32399. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32400. */
  32401. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32402. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32403. /**
  32404. * Defines edge width used when edgesRenderer is enabled
  32405. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32406. */
  32407. edgesWidth: number;
  32408. /**
  32409. * Defines edge color used when edgesRenderer is enabled
  32410. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32411. */
  32412. edgesColor: Color4;
  32413. /** @hidden */
  32414. _edgesRenderer: Nullable<IEdgesRenderer>;
  32415. /** @hidden */
  32416. _masterMesh: Nullable<AbstractMesh>;
  32417. /** @hidden */
  32418. _boundingInfo: Nullable<BoundingInfo>;
  32419. /** @hidden */
  32420. _renderId: number;
  32421. /**
  32422. * Gets or sets the list of subMeshes
  32423. * @see https://doc.babylonjs.com/how_to/multi_materials
  32424. */
  32425. subMeshes: SubMesh[];
  32426. /** @hidden */
  32427. _intersectionsInProgress: AbstractMesh[];
  32428. /** @hidden */
  32429. _unIndexed: boolean;
  32430. /** @hidden */
  32431. _lightSources: Light[];
  32432. /** Gets the list of lights affecting that mesh */
  32433. get lightSources(): Light[];
  32434. /** @hidden */
  32435. get _positions(): Nullable<Vector3[]>;
  32436. /** @hidden */
  32437. _waitingData: {
  32438. lods: Nullable<any>;
  32439. actions: Nullable<any>;
  32440. freezeWorldMatrix: Nullable<boolean>;
  32441. };
  32442. /** @hidden */
  32443. _bonesTransformMatrices: Nullable<Float32Array>;
  32444. /** @hidden */
  32445. _transformMatrixTexture: Nullable<RawTexture>;
  32446. /**
  32447. * Gets or sets a skeleton to apply skining transformations
  32448. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32449. */
  32450. set skeleton(value: Nullable<Skeleton>);
  32451. get skeleton(): Nullable<Skeleton>;
  32452. /**
  32453. * An event triggered when the mesh is rebuilt.
  32454. */
  32455. onRebuildObservable: Observable<AbstractMesh>;
  32456. /**
  32457. * Creates a new AbstractMesh
  32458. * @param name defines the name of the mesh
  32459. * @param scene defines the hosting scene
  32460. */
  32461. constructor(name: string, scene?: Nullable<Scene>);
  32462. /**
  32463. * Returns the string "AbstractMesh"
  32464. * @returns "AbstractMesh"
  32465. */
  32466. getClassName(): string;
  32467. /**
  32468. * Gets a string representation of the current mesh
  32469. * @param fullDetails defines a boolean indicating if full details must be included
  32470. * @returns a string representation of the current mesh
  32471. */
  32472. toString(fullDetails?: boolean): string;
  32473. /**
  32474. * @hidden
  32475. */
  32476. protected _getEffectiveParent(): Nullable<Node>;
  32477. /** @hidden */
  32478. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32479. /** @hidden */
  32480. _rebuild(): void;
  32481. /** @hidden */
  32482. _resyncLightSources(): void;
  32483. /** @hidden */
  32484. _resyncLightSource(light: Light): void;
  32485. /** @hidden */
  32486. _unBindEffect(): void;
  32487. /** @hidden */
  32488. _removeLightSource(light: Light, dispose: boolean): void;
  32489. private _markSubMeshesAsDirty;
  32490. /** @hidden */
  32491. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32492. /** @hidden */
  32493. _markSubMeshesAsAttributesDirty(): void;
  32494. /** @hidden */
  32495. _markSubMeshesAsMiscDirty(): void;
  32496. /**
  32497. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32498. */
  32499. get scaling(): Vector3;
  32500. set scaling(newScaling: Vector3);
  32501. /**
  32502. * Returns true if the mesh is blocked. Implemented by child classes
  32503. */
  32504. get isBlocked(): boolean;
  32505. /**
  32506. * Returns the mesh itself by default. Implemented by child classes
  32507. * @param camera defines the camera to use to pick the right LOD level
  32508. * @returns the currentAbstractMesh
  32509. */
  32510. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32511. /**
  32512. * Returns 0 by default. Implemented by child classes
  32513. * @returns an integer
  32514. */
  32515. getTotalVertices(): number;
  32516. /**
  32517. * Returns a positive integer : the total number of indices in this mesh geometry.
  32518. * @returns the numner of indices or zero if the mesh has no geometry.
  32519. */
  32520. getTotalIndices(): number;
  32521. /**
  32522. * Returns null by default. Implemented by child classes
  32523. * @returns null
  32524. */
  32525. getIndices(): Nullable<IndicesArray>;
  32526. /**
  32527. * Returns the array of the requested vertex data kind. Implemented by child classes
  32528. * @param kind defines the vertex data kind to use
  32529. * @returns null
  32530. */
  32531. getVerticesData(kind: string): Nullable<FloatArray>;
  32532. /**
  32533. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32534. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32535. * Note that a new underlying VertexBuffer object is created each call.
  32536. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32537. * @param kind defines vertex data kind:
  32538. * * VertexBuffer.PositionKind
  32539. * * VertexBuffer.UVKind
  32540. * * VertexBuffer.UV2Kind
  32541. * * VertexBuffer.UV3Kind
  32542. * * VertexBuffer.UV4Kind
  32543. * * VertexBuffer.UV5Kind
  32544. * * VertexBuffer.UV6Kind
  32545. * * VertexBuffer.ColorKind
  32546. * * VertexBuffer.MatricesIndicesKind
  32547. * * VertexBuffer.MatricesIndicesExtraKind
  32548. * * VertexBuffer.MatricesWeightsKind
  32549. * * VertexBuffer.MatricesWeightsExtraKind
  32550. * @param data defines the data source
  32551. * @param updatable defines if the data must be flagged as updatable (or static)
  32552. * @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
  32553. * @returns the current mesh
  32554. */
  32555. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32556. /**
  32557. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32558. * If the mesh has no geometry, it is simply returned as it is.
  32559. * @param kind defines vertex data kind:
  32560. * * VertexBuffer.PositionKind
  32561. * * VertexBuffer.UVKind
  32562. * * VertexBuffer.UV2Kind
  32563. * * VertexBuffer.UV3Kind
  32564. * * VertexBuffer.UV4Kind
  32565. * * VertexBuffer.UV5Kind
  32566. * * VertexBuffer.UV6Kind
  32567. * * VertexBuffer.ColorKind
  32568. * * VertexBuffer.MatricesIndicesKind
  32569. * * VertexBuffer.MatricesIndicesExtraKind
  32570. * * VertexBuffer.MatricesWeightsKind
  32571. * * VertexBuffer.MatricesWeightsExtraKind
  32572. * @param data defines the data source
  32573. * @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
  32574. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32575. * @returns the current mesh
  32576. */
  32577. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32578. /**
  32579. * Sets the mesh indices,
  32580. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32581. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32582. * @param totalVertices Defines the total number of vertices
  32583. * @returns the current mesh
  32584. */
  32585. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32586. /**
  32587. * Gets a boolean indicating if specific vertex data is present
  32588. * @param kind defines the vertex data kind to use
  32589. * @returns true is data kind is present
  32590. */
  32591. isVerticesDataPresent(kind: string): boolean;
  32592. /**
  32593. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32594. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32595. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32596. * @returns a BoundingInfo
  32597. */
  32598. getBoundingInfo(): BoundingInfo;
  32599. /**
  32600. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32601. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32602. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32603. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32604. * @returns the current mesh
  32605. */
  32606. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32607. /**
  32608. * Overwrite the current bounding info
  32609. * @param boundingInfo defines the new bounding info
  32610. * @returns the current mesh
  32611. */
  32612. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32613. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32614. get useBones(): boolean;
  32615. /** @hidden */
  32616. _preActivate(): void;
  32617. /** @hidden */
  32618. _preActivateForIntermediateRendering(renderId: number): void;
  32619. /** @hidden */
  32620. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32621. /** @hidden */
  32622. _postActivate(): void;
  32623. /** @hidden */
  32624. _freeze(): void;
  32625. /** @hidden */
  32626. _unFreeze(): void;
  32627. /**
  32628. * Gets the current world matrix
  32629. * @returns a Matrix
  32630. */
  32631. getWorldMatrix(): Matrix;
  32632. /** @hidden */
  32633. _getWorldMatrixDeterminant(): number;
  32634. /**
  32635. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32636. */
  32637. get isAnInstance(): boolean;
  32638. /**
  32639. * Gets a boolean indicating if this mesh has instances
  32640. */
  32641. get hasInstances(): boolean;
  32642. /**
  32643. * Gets a boolean indicating if this mesh has thin instances
  32644. */
  32645. get hasThinInstances(): boolean;
  32646. /**
  32647. * Perform relative position change from the point of view of behind the front of the mesh.
  32648. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32649. * Supports definition of mesh facing forward or backward
  32650. * @param amountRight defines the distance on the right axis
  32651. * @param amountUp defines the distance on the up axis
  32652. * @param amountForward defines the distance on the forward axis
  32653. * @returns the current mesh
  32654. */
  32655. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32656. /**
  32657. * Calculate relative position change from the point of view of behind the front of the mesh.
  32658. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32659. * Supports definition of mesh facing forward or backward
  32660. * @param amountRight defines the distance on the right axis
  32661. * @param amountUp defines the distance on the up axis
  32662. * @param amountForward defines the distance on the forward axis
  32663. * @returns the new displacement vector
  32664. */
  32665. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32666. /**
  32667. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32668. * Supports definition of mesh facing forward or backward
  32669. * @param flipBack defines the flip
  32670. * @param twirlClockwise defines the twirl
  32671. * @param tiltRight defines the tilt
  32672. * @returns the current mesh
  32673. */
  32674. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32675. /**
  32676. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32677. * Supports definition of mesh facing forward or backward.
  32678. * @param flipBack defines the flip
  32679. * @param twirlClockwise defines the twirl
  32680. * @param tiltRight defines the tilt
  32681. * @returns the new rotation vector
  32682. */
  32683. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32684. /**
  32685. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32686. * This means the mesh underlying bounding box and sphere are recomputed.
  32687. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32688. * @returns the current mesh
  32689. */
  32690. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32691. /** @hidden */
  32692. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32693. /** @hidden */
  32694. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32695. /** @hidden */
  32696. _updateBoundingInfo(): AbstractMesh;
  32697. /** @hidden */
  32698. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32699. /** @hidden */
  32700. protected _afterComputeWorldMatrix(): void;
  32701. /** @hidden */
  32702. get _effectiveMesh(): AbstractMesh;
  32703. /**
  32704. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32705. * A mesh is in the frustum if its bounding box intersects the frustum
  32706. * @param frustumPlanes defines the frustum to test
  32707. * @returns true if the mesh is in the frustum planes
  32708. */
  32709. isInFrustum(frustumPlanes: Plane[]): boolean;
  32710. /**
  32711. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32712. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32713. * @param frustumPlanes defines the frustum to test
  32714. * @returns true if the mesh is completely in the frustum planes
  32715. */
  32716. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32717. /**
  32718. * True if the mesh intersects another mesh or a SolidParticle object
  32719. * @param mesh defines a target mesh or SolidParticle to test
  32720. * @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)
  32721. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32722. * @returns true if there is an intersection
  32723. */
  32724. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32725. /**
  32726. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32727. * @param point defines the point to test
  32728. * @returns true if there is an intersection
  32729. */
  32730. intersectsPoint(point: Vector3): boolean;
  32731. /**
  32732. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32733. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32734. */
  32735. get checkCollisions(): boolean;
  32736. set checkCollisions(collisionEnabled: boolean);
  32737. /**
  32738. * Gets Collider object used to compute collisions (not physics)
  32739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32740. */
  32741. get collider(): Nullable<Collider>;
  32742. /**
  32743. * Move the mesh using collision engine
  32744. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32745. * @param displacement defines the requested displacement vector
  32746. * @returns the current mesh
  32747. */
  32748. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32749. private _onCollisionPositionChange;
  32750. /** @hidden */
  32751. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32752. /** @hidden */
  32753. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32754. /** @hidden */
  32755. _checkCollision(collider: Collider): AbstractMesh;
  32756. /** @hidden */
  32757. _generatePointsArray(): boolean;
  32758. /**
  32759. * Checks if the passed Ray intersects with the mesh
  32760. * @param ray defines the ray to use
  32761. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32762. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32763. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32764. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32765. * @returns the picking info
  32766. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32767. */
  32768. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32769. /**
  32770. * Clones the current mesh
  32771. * @param name defines the mesh name
  32772. * @param newParent defines the new mesh parent
  32773. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32774. * @returns the new mesh
  32775. */
  32776. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32777. /**
  32778. * Disposes all the submeshes of the current meshnp
  32779. * @returns the current mesh
  32780. */
  32781. releaseSubMeshes(): AbstractMesh;
  32782. /**
  32783. * Releases resources associated with this abstract mesh.
  32784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32786. */
  32787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32788. /**
  32789. * Adds the passed mesh as a child to the current mesh
  32790. * @param mesh defines the child mesh
  32791. * @returns the current mesh
  32792. */
  32793. addChild(mesh: AbstractMesh): AbstractMesh;
  32794. /**
  32795. * Removes the passed mesh from the current mesh children list
  32796. * @param mesh defines the child mesh
  32797. * @returns the current mesh
  32798. */
  32799. removeChild(mesh: AbstractMesh): AbstractMesh;
  32800. /** @hidden */
  32801. private _initFacetData;
  32802. /**
  32803. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32804. * This method can be called within the render loop.
  32805. * 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
  32806. * @returns the current mesh
  32807. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32808. */
  32809. updateFacetData(): AbstractMesh;
  32810. /**
  32811. * Returns the facetLocalNormals array.
  32812. * The normals are expressed in the mesh local spac
  32813. * @returns an array of Vector3
  32814. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32815. */
  32816. getFacetLocalNormals(): Vector3[];
  32817. /**
  32818. * Returns the facetLocalPositions array.
  32819. * The facet positions are expressed in the mesh local space
  32820. * @returns an array of Vector3
  32821. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32822. */
  32823. getFacetLocalPositions(): Vector3[];
  32824. /**
  32825. * Returns the facetLocalPartioning array
  32826. * @returns an array of array of numbers
  32827. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32828. */
  32829. getFacetLocalPartitioning(): number[][];
  32830. /**
  32831. * Returns the i-th facet position in the world system.
  32832. * This method allocates a new Vector3 per call
  32833. * @param i defines the facet index
  32834. * @returns a new Vector3
  32835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32836. */
  32837. getFacetPosition(i: number): Vector3;
  32838. /**
  32839. * Sets the reference Vector3 with the i-th facet position in the world system
  32840. * @param i defines the facet index
  32841. * @param ref defines the target vector
  32842. * @returns the current mesh
  32843. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32844. */
  32845. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32846. /**
  32847. * Returns the i-th facet normal in the world system.
  32848. * This method allocates a new Vector3 per call
  32849. * @param i defines the facet index
  32850. * @returns a new Vector3
  32851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32852. */
  32853. getFacetNormal(i: number): Vector3;
  32854. /**
  32855. * Sets the reference Vector3 with the i-th facet normal in the world system
  32856. * @param i defines the facet index
  32857. * @param ref defines the target vector
  32858. * @returns the current mesh
  32859. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32860. */
  32861. getFacetNormalToRef(i: number, ref: Vector3): this;
  32862. /**
  32863. * 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)
  32864. * @param x defines x coordinate
  32865. * @param y defines y coordinate
  32866. * @param z defines z coordinate
  32867. * @returns the array of facet indexes
  32868. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32869. */
  32870. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32871. /**
  32872. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32873. * @param projected sets as the (x,y,z) world projection on the facet
  32874. * @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
  32875. * @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
  32876. * @param x defines x coordinate
  32877. * @param y defines y coordinate
  32878. * @param z defines z coordinate
  32879. * @returns the face index if found (or null instead)
  32880. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32881. */
  32882. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32883. /**
  32884. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32885. * @param projected sets as the (x,y,z) local projection on the facet
  32886. * @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
  32887. * @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
  32888. * @param x defines x coordinate
  32889. * @param y defines y coordinate
  32890. * @param z defines z coordinate
  32891. * @returns the face index if found (or null instead)
  32892. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32893. */
  32894. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32895. /**
  32896. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32897. * @returns the parameters
  32898. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32899. */
  32900. getFacetDataParameters(): any;
  32901. /**
  32902. * Disables the feature FacetData and frees the related memory
  32903. * @returns the current mesh
  32904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32905. */
  32906. disableFacetData(): AbstractMesh;
  32907. /**
  32908. * Updates the AbstractMesh indices array
  32909. * @param indices defines the data source
  32910. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32911. * @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)
  32912. * @returns the current mesh
  32913. */
  32914. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32915. /**
  32916. * Creates new normals data for the mesh
  32917. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32918. * @returns the current mesh
  32919. */
  32920. createNormals(updatable: boolean): AbstractMesh;
  32921. /**
  32922. * Align the mesh with a normal
  32923. * @param normal defines the normal to use
  32924. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32925. * @returns the current mesh
  32926. */
  32927. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32928. /** @hidden */
  32929. _checkOcclusionQuery(): boolean;
  32930. /**
  32931. * Disables the mesh edge rendering mode
  32932. * @returns the currentAbstractMesh
  32933. */
  32934. disableEdgesRendering(): AbstractMesh;
  32935. /**
  32936. * Enables the edge rendering mode on the mesh.
  32937. * This mode makes the mesh edges visible
  32938. * @param epsilon defines the maximal distance between two angles to detect a face
  32939. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32940. * @returns the currentAbstractMesh
  32941. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32942. */
  32943. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32944. /**
  32945. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32946. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32947. */
  32948. getConnectedParticleSystems(): IParticleSystem[];
  32949. }
  32950. }
  32951. declare module BABYLON {
  32952. /**
  32953. * Interface used to define ActionEvent
  32954. */
  32955. export interface IActionEvent {
  32956. /** The mesh or sprite that triggered the action */
  32957. source: any;
  32958. /** The X mouse cursor position at the time of the event */
  32959. pointerX: number;
  32960. /** The Y mouse cursor position at the time of the event */
  32961. pointerY: number;
  32962. /** The mesh that is currently pointed at (can be null) */
  32963. meshUnderPointer: Nullable<AbstractMesh>;
  32964. /** the original (browser) event that triggered the ActionEvent */
  32965. sourceEvent?: any;
  32966. /** additional data for the event */
  32967. additionalData?: any;
  32968. }
  32969. /**
  32970. * ActionEvent is the event being sent when an action is triggered.
  32971. */
  32972. export class ActionEvent implements IActionEvent {
  32973. /** The mesh or sprite that triggered the action */
  32974. source: any;
  32975. /** The X mouse cursor position at the time of the event */
  32976. pointerX: number;
  32977. /** The Y mouse cursor position at the time of the event */
  32978. pointerY: number;
  32979. /** The mesh that is currently pointed at (can be null) */
  32980. meshUnderPointer: Nullable<AbstractMesh>;
  32981. /** the original (browser) event that triggered the ActionEvent */
  32982. sourceEvent?: any;
  32983. /** additional data for the event */
  32984. additionalData?: any;
  32985. /**
  32986. * Creates a new ActionEvent
  32987. * @param source The mesh or sprite that triggered the action
  32988. * @param pointerX The X mouse cursor position at the time of the event
  32989. * @param pointerY The Y mouse cursor position at the time of the event
  32990. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32991. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32992. * @param additionalData additional data for the event
  32993. */
  32994. constructor(
  32995. /** The mesh or sprite that triggered the action */
  32996. source: any,
  32997. /** The X mouse cursor position at the time of the event */
  32998. pointerX: number,
  32999. /** The Y mouse cursor position at the time of the event */
  33000. pointerY: number,
  33001. /** The mesh that is currently pointed at (can be null) */
  33002. meshUnderPointer: Nullable<AbstractMesh>,
  33003. /** the original (browser) event that triggered the ActionEvent */
  33004. sourceEvent?: any,
  33005. /** additional data for the event */
  33006. additionalData?: any);
  33007. /**
  33008. * Helper function to auto-create an ActionEvent from a source mesh.
  33009. * @param source The source mesh that triggered the event
  33010. * @param evt The original (browser) event
  33011. * @param additionalData additional data for the event
  33012. * @returns the new ActionEvent
  33013. */
  33014. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33015. /**
  33016. * Helper function to auto-create an ActionEvent from a source sprite
  33017. * @param source The source sprite that triggered the event
  33018. * @param scene Scene associated with the sprite
  33019. * @param evt The original (browser) event
  33020. * @param additionalData additional data for the event
  33021. * @returns the new ActionEvent
  33022. */
  33023. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33024. /**
  33025. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33026. * @param scene the scene where the event occurred
  33027. * @param evt The original (browser) event
  33028. * @returns the new ActionEvent
  33029. */
  33030. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33031. /**
  33032. * Helper function to auto-create an ActionEvent from a primitive
  33033. * @param prim defines the target primitive
  33034. * @param pointerPos defines the pointer position
  33035. * @param evt The original (browser) event
  33036. * @param additionalData additional data for the event
  33037. * @returns the new ActionEvent
  33038. */
  33039. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33040. }
  33041. }
  33042. declare module BABYLON {
  33043. /**
  33044. * Abstract class used to decouple action Manager from scene and meshes.
  33045. * Do not instantiate.
  33046. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33047. */
  33048. export abstract class AbstractActionManager implements IDisposable {
  33049. /** Gets the list of active triggers */
  33050. static Triggers: {
  33051. [key: string]: number;
  33052. };
  33053. /** Gets the cursor to use when hovering items */
  33054. hoverCursor: string;
  33055. /** Gets the list of actions */
  33056. actions: IAction[];
  33057. /**
  33058. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33059. */
  33060. isRecursive: boolean;
  33061. /**
  33062. * Releases all associated resources
  33063. */
  33064. abstract dispose(): void;
  33065. /**
  33066. * Does this action manager has pointer triggers
  33067. */
  33068. abstract get hasPointerTriggers(): boolean;
  33069. /**
  33070. * Does this action manager has pick triggers
  33071. */
  33072. abstract get hasPickTriggers(): boolean;
  33073. /**
  33074. * Process a specific trigger
  33075. * @param trigger defines the trigger to process
  33076. * @param evt defines the event details to be processed
  33077. */
  33078. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33079. /**
  33080. * Does this action manager handles actions of any of the given triggers
  33081. * @param triggers defines the triggers to be tested
  33082. * @return a boolean indicating whether one (or more) of the triggers is handled
  33083. */
  33084. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33085. /**
  33086. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33087. * speed.
  33088. * @param triggerA defines the trigger to be tested
  33089. * @param triggerB defines the trigger to be tested
  33090. * @return a boolean indicating whether one (or more) of the triggers is handled
  33091. */
  33092. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33093. /**
  33094. * Does this action manager handles actions of a given trigger
  33095. * @param trigger defines the trigger to be tested
  33096. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33097. * @return whether the trigger is handled
  33098. */
  33099. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33100. /**
  33101. * Serialize this manager to a JSON object
  33102. * @param name defines the property name to store this manager
  33103. * @returns a JSON representation of this manager
  33104. */
  33105. abstract serialize(name: string): any;
  33106. /**
  33107. * Registers an action to this action manager
  33108. * @param action defines the action to be registered
  33109. * @return the action amended (prepared) after registration
  33110. */
  33111. abstract registerAction(action: IAction): Nullable<IAction>;
  33112. /**
  33113. * Unregisters an action to this action manager
  33114. * @param action defines the action to be unregistered
  33115. * @return a boolean indicating whether the action has been unregistered
  33116. */
  33117. abstract unregisterAction(action: IAction): Boolean;
  33118. /**
  33119. * Does exist one action manager with at least one trigger
  33120. **/
  33121. static get HasTriggers(): boolean;
  33122. /**
  33123. * Does exist one action manager with at least one pick trigger
  33124. **/
  33125. static get HasPickTriggers(): boolean;
  33126. /**
  33127. * Does exist one action manager that handles actions of a given trigger
  33128. * @param trigger defines the trigger to be tested
  33129. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33130. **/
  33131. static HasSpecificTrigger(trigger: number): boolean;
  33132. }
  33133. }
  33134. declare module BABYLON {
  33135. /**
  33136. * Defines how a node can be built from a string name.
  33137. */
  33138. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33139. /**
  33140. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33141. */
  33142. export class Node implements IBehaviorAware<Node> {
  33143. /** @hidden */
  33144. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33145. private static _NodeConstructors;
  33146. /**
  33147. * Add a new node constructor
  33148. * @param type defines the type name of the node to construct
  33149. * @param constructorFunc defines the constructor function
  33150. */
  33151. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33152. /**
  33153. * Returns a node constructor based on type name
  33154. * @param type defines the type name
  33155. * @param name defines the new node name
  33156. * @param scene defines the hosting scene
  33157. * @param options defines optional options to transmit to constructors
  33158. * @returns the new constructor or null
  33159. */
  33160. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33161. /**
  33162. * Gets or sets the name of the node
  33163. */
  33164. name: string;
  33165. /**
  33166. * Gets or sets the id of the node
  33167. */
  33168. id: string;
  33169. /**
  33170. * Gets or sets the unique id of the node
  33171. */
  33172. uniqueId: number;
  33173. /**
  33174. * Gets or sets a string used to store user defined state for the node
  33175. */
  33176. state: string;
  33177. /**
  33178. * Gets or sets an object used to store user defined information for the node
  33179. */
  33180. metadata: any;
  33181. /**
  33182. * For internal use only. Please do not use.
  33183. */
  33184. reservedDataStore: any;
  33185. /**
  33186. * List of inspectable custom properties (used by the Inspector)
  33187. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33188. */
  33189. inspectableCustomProperties: IInspectable[];
  33190. private _doNotSerialize;
  33191. /**
  33192. * Gets or sets a boolean used to define if the node must be serialized
  33193. */
  33194. get doNotSerialize(): boolean;
  33195. set doNotSerialize(value: boolean);
  33196. /** @hidden */
  33197. _isDisposed: boolean;
  33198. /**
  33199. * Gets a list of Animations associated with the node
  33200. */
  33201. animations: Animation[];
  33202. protected _ranges: {
  33203. [name: string]: Nullable<AnimationRange>;
  33204. };
  33205. /**
  33206. * Callback raised when the node is ready to be used
  33207. */
  33208. onReady: Nullable<(node: Node) => void>;
  33209. private _isEnabled;
  33210. private _isParentEnabled;
  33211. private _isReady;
  33212. /** @hidden */
  33213. _currentRenderId: number;
  33214. private _parentUpdateId;
  33215. /** @hidden */
  33216. _childUpdateId: number;
  33217. /** @hidden */
  33218. _waitingParentId: Nullable<string>;
  33219. /** @hidden */
  33220. _scene: Scene;
  33221. /** @hidden */
  33222. _cache: any;
  33223. private _parentNode;
  33224. private _children;
  33225. /** @hidden */
  33226. _worldMatrix: Matrix;
  33227. /** @hidden */
  33228. _worldMatrixDeterminant: number;
  33229. /** @hidden */
  33230. _worldMatrixDeterminantIsDirty: boolean;
  33231. /** @hidden */
  33232. private _sceneRootNodesIndex;
  33233. /**
  33234. * Gets a boolean indicating if the node has been disposed
  33235. * @returns true if the node was disposed
  33236. */
  33237. isDisposed(): boolean;
  33238. /**
  33239. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33240. * @see https://doc.babylonjs.com/how_to/parenting
  33241. */
  33242. set parent(parent: Nullable<Node>);
  33243. get parent(): Nullable<Node>;
  33244. /** @hidden */
  33245. _addToSceneRootNodes(): void;
  33246. /** @hidden */
  33247. _removeFromSceneRootNodes(): void;
  33248. private _animationPropertiesOverride;
  33249. /**
  33250. * Gets or sets the animation properties override
  33251. */
  33252. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33253. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33254. /**
  33255. * Gets a string identifying the name of the class
  33256. * @returns "Node" string
  33257. */
  33258. getClassName(): string;
  33259. /** @hidden */
  33260. readonly _isNode: boolean;
  33261. /**
  33262. * An event triggered when the mesh is disposed
  33263. */
  33264. onDisposeObservable: Observable<Node>;
  33265. private _onDisposeObserver;
  33266. /**
  33267. * Sets a callback that will be raised when the node will be disposed
  33268. */
  33269. set onDispose(callback: () => void);
  33270. /**
  33271. * Creates a new Node
  33272. * @param name the name and id to be given to this node
  33273. * @param scene the scene this node will be added to
  33274. */
  33275. constructor(name: string, scene?: Nullable<Scene>);
  33276. /**
  33277. * Gets the scene of the node
  33278. * @returns a scene
  33279. */
  33280. getScene(): Scene;
  33281. /**
  33282. * Gets the engine of the node
  33283. * @returns a Engine
  33284. */
  33285. getEngine(): Engine;
  33286. private _behaviors;
  33287. /**
  33288. * Attach a behavior to the node
  33289. * @see https://doc.babylonjs.com/features/behaviour
  33290. * @param behavior defines the behavior to attach
  33291. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33292. * @returns the current Node
  33293. */
  33294. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33295. /**
  33296. * Remove an attached behavior
  33297. * @see https://doc.babylonjs.com/features/behaviour
  33298. * @param behavior defines the behavior to attach
  33299. * @returns the current Node
  33300. */
  33301. removeBehavior(behavior: Behavior<Node>): Node;
  33302. /**
  33303. * Gets the list of attached behaviors
  33304. * @see https://doc.babylonjs.com/features/behaviour
  33305. */
  33306. get behaviors(): Behavior<Node>[];
  33307. /**
  33308. * Gets an attached behavior by name
  33309. * @param name defines the name of the behavior to look for
  33310. * @see https://doc.babylonjs.com/features/behaviour
  33311. * @returns null if behavior was not found else the requested behavior
  33312. */
  33313. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33314. /**
  33315. * Returns the latest update of the World matrix
  33316. * @returns a Matrix
  33317. */
  33318. getWorldMatrix(): Matrix;
  33319. /** @hidden */
  33320. _getWorldMatrixDeterminant(): number;
  33321. /**
  33322. * Returns directly the latest state of the mesh World matrix.
  33323. * A Matrix is returned.
  33324. */
  33325. get worldMatrixFromCache(): Matrix;
  33326. /** @hidden */
  33327. _initCache(): void;
  33328. /** @hidden */
  33329. updateCache(force?: boolean): void;
  33330. /** @hidden */
  33331. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33332. /** @hidden */
  33333. _updateCache(ignoreParentClass?: boolean): void;
  33334. /** @hidden */
  33335. _isSynchronized(): boolean;
  33336. /** @hidden */
  33337. _markSyncedWithParent(): void;
  33338. /** @hidden */
  33339. isSynchronizedWithParent(): boolean;
  33340. /** @hidden */
  33341. isSynchronized(): boolean;
  33342. /**
  33343. * Is this node ready to be used/rendered
  33344. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33345. * @return true if the node is ready
  33346. */
  33347. isReady(completeCheck?: boolean): boolean;
  33348. /**
  33349. * Is this node enabled?
  33350. * 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
  33351. * @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
  33352. * @return whether this node (and its parent) is enabled
  33353. */
  33354. isEnabled(checkAncestors?: boolean): boolean;
  33355. /** @hidden */
  33356. protected _syncParentEnabledState(): void;
  33357. /**
  33358. * Set the enabled state of this node
  33359. * @param value defines the new enabled state
  33360. */
  33361. setEnabled(value: boolean): void;
  33362. /**
  33363. * Is this node a descendant of the given node?
  33364. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33365. * @param ancestor defines the parent node to inspect
  33366. * @returns a boolean indicating if this node is a descendant of the given node
  33367. */
  33368. isDescendantOf(ancestor: Node): boolean;
  33369. /** @hidden */
  33370. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33371. /**
  33372. * Will return all nodes that have this node as ascendant
  33373. * @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
  33374. * @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
  33375. * @return all children nodes of all types
  33376. */
  33377. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33378. /**
  33379. * Get all child-meshes of this node
  33380. * @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)
  33381. * @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
  33382. * @returns an array of AbstractMesh
  33383. */
  33384. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33385. /**
  33386. * Get all direct children of this node
  33387. * @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
  33388. * @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)
  33389. * @returns an array of Node
  33390. */
  33391. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33392. /** @hidden */
  33393. _setReady(state: boolean): void;
  33394. /**
  33395. * Get an animation by name
  33396. * @param name defines the name of the animation to look for
  33397. * @returns null if not found else the requested animation
  33398. */
  33399. getAnimationByName(name: string): Nullable<Animation>;
  33400. /**
  33401. * Creates an animation range for this node
  33402. * @param name defines the name of the range
  33403. * @param from defines the starting key
  33404. * @param to defines the end key
  33405. */
  33406. createAnimationRange(name: string, from: number, to: number): void;
  33407. /**
  33408. * Delete a specific animation range
  33409. * @param name defines the name of the range to delete
  33410. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33411. */
  33412. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33413. /**
  33414. * Get an animation range by name
  33415. * @param name defines the name of the animation range to look for
  33416. * @returns null if not found else the requested animation range
  33417. */
  33418. getAnimationRange(name: string): Nullable<AnimationRange>;
  33419. /**
  33420. * Gets the list of all animation ranges defined on this node
  33421. * @returns an array
  33422. */
  33423. getAnimationRanges(): Nullable<AnimationRange>[];
  33424. /**
  33425. * Will start the animation sequence
  33426. * @param name defines the range frames for animation sequence
  33427. * @param loop defines if the animation should loop (false by default)
  33428. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33429. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33430. * @returns the object created for this animation. If range does not exist, it will return null
  33431. */
  33432. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33433. /**
  33434. * Serialize animation ranges into a JSON compatible object
  33435. * @returns serialization object
  33436. */
  33437. serializeAnimationRanges(): any;
  33438. /**
  33439. * Computes the world matrix of the node
  33440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33441. * @returns the world matrix
  33442. */
  33443. computeWorldMatrix(force?: boolean): Matrix;
  33444. /**
  33445. * Releases resources associated with this node.
  33446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33448. */
  33449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33450. /**
  33451. * Parse animation range data from a serialization object and store them into a given node
  33452. * @param node defines where to store the animation ranges
  33453. * @param parsedNode defines the serialization object to read data from
  33454. * @param scene defines the hosting scene
  33455. */
  33456. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33457. /**
  33458. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33459. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33460. * @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
  33461. * @returns the new bounding vectors
  33462. */
  33463. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33464. min: Vector3;
  33465. max: Vector3;
  33466. };
  33467. }
  33468. }
  33469. declare module BABYLON {
  33470. /**
  33471. * @hidden
  33472. */
  33473. export class _IAnimationState {
  33474. key: number;
  33475. repeatCount: number;
  33476. workValue?: any;
  33477. loopMode?: number;
  33478. offsetValue?: any;
  33479. highLimitValue?: any;
  33480. }
  33481. /**
  33482. * Class used to store any kind of animation
  33483. */
  33484. export class Animation {
  33485. /**Name of the animation */
  33486. name: string;
  33487. /**Property to animate */
  33488. targetProperty: string;
  33489. /**The frames per second of the animation */
  33490. framePerSecond: number;
  33491. /**The data type of the animation */
  33492. dataType: number;
  33493. /**The loop mode of the animation */
  33494. loopMode?: number | undefined;
  33495. /**Specifies if blending should be enabled */
  33496. enableBlending?: boolean | undefined;
  33497. /**
  33498. * Use matrix interpolation instead of using direct key value when animating matrices
  33499. */
  33500. static AllowMatricesInterpolation: boolean;
  33501. /**
  33502. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33503. */
  33504. static AllowMatrixDecomposeForInterpolation: boolean;
  33505. /** Define the Url to load snippets */
  33506. static SnippetUrl: string;
  33507. /** Snippet ID if the animation was created from the snippet server */
  33508. snippetId: string;
  33509. /**
  33510. * Stores the key frames of the animation
  33511. */
  33512. private _keys;
  33513. /**
  33514. * Stores the easing function of the animation
  33515. */
  33516. private _easingFunction;
  33517. /**
  33518. * @hidden Internal use only
  33519. */
  33520. _runtimeAnimations: RuntimeAnimation[];
  33521. /**
  33522. * The set of event that will be linked to this animation
  33523. */
  33524. private _events;
  33525. /**
  33526. * Stores an array of target property paths
  33527. */
  33528. targetPropertyPath: string[];
  33529. /**
  33530. * Stores the blending speed of the animation
  33531. */
  33532. blendingSpeed: number;
  33533. /**
  33534. * Stores the animation ranges for the animation
  33535. */
  33536. private _ranges;
  33537. /**
  33538. * @hidden Internal use
  33539. */
  33540. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33541. /**
  33542. * Sets up an animation
  33543. * @param property The property to animate
  33544. * @param animationType The animation type to apply
  33545. * @param framePerSecond The frames per second of the animation
  33546. * @param easingFunction The easing function used in the animation
  33547. * @returns The created animation
  33548. */
  33549. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33550. /**
  33551. * Create and start an animation on a node
  33552. * @param name defines the name of the global animation that will be run on all nodes
  33553. * @param node defines the root node where the animation will take place
  33554. * @param targetProperty defines property to animate
  33555. * @param framePerSecond defines the number of frame per second yo use
  33556. * @param totalFrame defines the number of frames in total
  33557. * @param from defines the initial value
  33558. * @param to defines the final value
  33559. * @param loopMode defines which loop mode you want to use (off by default)
  33560. * @param easingFunction defines the easing function to use (linear by default)
  33561. * @param onAnimationEnd defines the callback to call when animation end
  33562. * @returns the animatable created for this animation
  33563. */
  33564. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33565. /**
  33566. * Create and start an animation on a node and its descendants
  33567. * @param name defines the name of the global animation that will be run on all nodes
  33568. * @param node defines the root node where the animation will take place
  33569. * @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
  33570. * @param targetProperty defines property to animate
  33571. * @param framePerSecond defines the number of frame per second to use
  33572. * @param totalFrame defines the number of frames in total
  33573. * @param from defines the initial value
  33574. * @param to defines the final value
  33575. * @param loopMode defines which loop mode you want to use (off by default)
  33576. * @param easingFunction defines the easing function to use (linear by default)
  33577. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33578. * @returns the list of animatables created for all nodes
  33579. * @example https://www.babylonjs-playground.com/#MH0VLI
  33580. */
  33581. 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[]>;
  33582. /**
  33583. * Creates a new animation, merges it with the existing animations and starts it
  33584. * @param name Name of the animation
  33585. * @param node Node which contains the scene that begins the animations
  33586. * @param targetProperty Specifies which property to animate
  33587. * @param framePerSecond The frames per second of the animation
  33588. * @param totalFrame The total number of frames
  33589. * @param from The frame at the beginning of the animation
  33590. * @param to The frame at the end of the animation
  33591. * @param loopMode Specifies the loop mode of the animation
  33592. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33593. * @param onAnimationEnd Callback to run once the animation is complete
  33594. * @returns Nullable animation
  33595. */
  33596. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33597. /**
  33598. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33599. * @param sourceAnimation defines the Animation containing keyframes to convert
  33600. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33601. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33602. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33603. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33604. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33605. */
  33606. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33607. /**
  33608. * Transition property of an host to the target Value
  33609. * @param property The property to transition
  33610. * @param targetValue The target Value of the property
  33611. * @param host The object where the property to animate belongs
  33612. * @param scene Scene used to run the animation
  33613. * @param frameRate Framerate (in frame/s) to use
  33614. * @param transition The transition type we want to use
  33615. * @param duration The duration of the animation, in milliseconds
  33616. * @param onAnimationEnd Callback trigger at the end of the animation
  33617. * @returns Nullable animation
  33618. */
  33619. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33620. /**
  33621. * Return the array of runtime animations currently using this animation
  33622. */
  33623. get runtimeAnimations(): RuntimeAnimation[];
  33624. /**
  33625. * Specifies if any of the runtime animations are currently running
  33626. */
  33627. get hasRunningRuntimeAnimations(): boolean;
  33628. /**
  33629. * Initializes the animation
  33630. * @param name Name of the animation
  33631. * @param targetProperty Property to animate
  33632. * @param framePerSecond The frames per second of the animation
  33633. * @param dataType The data type of the animation
  33634. * @param loopMode The loop mode of the animation
  33635. * @param enableBlending Specifies if blending should be enabled
  33636. */
  33637. constructor(
  33638. /**Name of the animation */
  33639. name: string,
  33640. /**Property to animate */
  33641. targetProperty: string,
  33642. /**The frames per second of the animation */
  33643. framePerSecond: number,
  33644. /**The data type of the animation */
  33645. dataType: number,
  33646. /**The loop mode of the animation */
  33647. loopMode?: number | undefined,
  33648. /**Specifies if blending should be enabled */
  33649. enableBlending?: boolean | undefined);
  33650. /**
  33651. * Converts the animation to a string
  33652. * @param fullDetails support for multiple levels of logging within scene loading
  33653. * @returns String form of the animation
  33654. */
  33655. toString(fullDetails?: boolean): string;
  33656. /**
  33657. * Add an event to this animation
  33658. * @param event Event to add
  33659. */
  33660. addEvent(event: AnimationEvent): void;
  33661. /**
  33662. * Remove all events found at the given frame
  33663. * @param frame The frame to remove events from
  33664. */
  33665. removeEvents(frame: number): void;
  33666. /**
  33667. * Retrieves all the events from the animation
  33668. * @returns Events from the animation
  33669. */
  33670. getEvents(): AnimationEvent[];
  33671. /**
  33672. * Creates an animation range
  33673. * @param name Name of the animation range
  33674. * @param from Starting frame of the animation range
  33675. * @param to Ending frame of the animation
  33676. */
  33677. createRange(name: string, from: number, to: number): void;
  33678. /**
  33679. * Deletes an animation range by name
  33680. * @param name Name of the animation range to delete
  33681. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33682. */
  33683. deleteRange(name: string, deleteFrames?: boolean): void;
  33684. /**
  33685. * Gets the animation range by name, or null if not defined
  33686. * @param name Name of the animation range
  33687. * @returns Nullable animation range
  33688. */
  33689. getRange(name: string): Nullable<AnimationRange>;
  33690. /**
  33691. * Gets the key frames from the animation
  33692. * @returns The key frames of the animation
  33693. */
  33694. getKeys(): Array<IAnimationKey>;
  33695. /**
  33696. * Gets the highest frame rate of the animation
  33697. * @returns Highest frame rate of the animation
  33698. */
  33699. getHighestFrame(): number;
  33700. /**
  33701. * Gets the easing function of the animation
  33702. * @returns Easing function of the animation
  33703. */
  33704. getEasingFunction(): IEasingFunction;
  33705. /**
  33706. * Sets the easing function of the animation
  33707. * @param easingFunction A custom mathematical formula for animation
  33708. */
  33709. setEasingFunction(easingFunction: EasingFunction): void;
  33710. /**
  33711. * Interpolates a scalar linearly
  33712. * @param startValue Start value of the animation curve
  33713. * @param endValue End value of the animation curve
  33714. * @param gradient Scalar amount to interpolate
  33715. * @returns Interpolated scalar value
  33716. */
  33717. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33718. /**
  33719. * Interpolates a scalar cubically
  33720. * @param startValue Start value of the animation curve
  33721. * @param outTangent End tangent of the animation
  33722. * @param endValue End value of the animation curve
  33723. * @param inTangent Start tangent of the animation curve
  33724. * @param gradient Scalar amount to interpolate
  33725. * @returns Interpolated scalar value
  33726. */
  33727. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33728. /**
  33729. * Interpolates a quaternion using a spherical linear interpolation
  33730. * @param startValue Start value of the animation curve
  33731. * @param endValue End value of the animation curve
  33732. * @param gradient Scalar amount to interpolate
  33733. * @returns Interpolated quaternion value
  33734. */
  33735. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33736. /**
  33737. * Interpolates a quaternion cubically
  33738. * @param startValue Start value of the animation curve
  33739. * @param outTangent End tangent of the animation curve
  33740. * @param endValue End value of the animation curve
  33741. * @param inTangent Start tangent of the animation curve
  33742. * @param gradient Scalar amount to interpolate
  33743. * @returns Interpolated quaternion value
  33744. */
  33745. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33746. /**
  33747. * Interpolates a Vector3 linearl
  33748. * @param startValue Start value of the animation curve
  33749. * @param endValue End value of the animation curve
  33750. * @param gradient Scalar amount to interpolate
  33751. * @returns Interpolated scalar value
  33752. */
  33753. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33754. /**
  33755. * Interpolates a Vector3 cubically
  33756. * @param startValue Start value of the animation curve
  33757. * @param outTangent End tangent of the animation
  33758. * @param endValue End value of the animation curve
  33759. * @param inTangent Start tangent of the animation curve
  33760. * @param gradient Scalar amount to interpolate
  33761. * @returns InterpolatedVector3 value
  33762. */
  33763. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33764. /**
  33765. * Interpolates a Vector2 linearly
  33766. * @param startValue Start value of the animation curve
  33767. * @param endValue End value of the animation curve
  33768. * @param gradient Scalar amount to interpolate
  33769. * @returns Interpolated Vector2 value
  33770. */
  33771. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33772. /**
  33773. * Interpolates a Vector2 cubically
  33774. * @param startValue Start value of the animation curve
  33775. * @param outTangent End tangent of the animation
  33776. * @param endValue End value of the animation curve
  33777. * @param inTangent Start tangent of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated Vector2 value
  33780. */
  33781. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33782. /**
  33783. * Interpolates a size linearly
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated Size value
  33788. */
  33789. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33790. /**
  33791. * Interpolates a Color3 linearly
  33792. * @param startValue Start value of the animation curve
  33793. * @param endValue End value of the animation curve
  33794. * @param gradient Scalar amount to interpolate
  33795. * @returns Interpolated Color3 value
  33796. */
  33797. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33798. /**
  33799. * Interpolates a Color4 linearly
  33800. * @param startValue Start value of the animation curve
  33801. * @param endValue End value of the animation curve
  33802. * @param gradient Scalar amount to interpolate
  33803. * @returns Interpolated Color3 value
  33804. */
  33805. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33806. /**
  33807. * @hidden Internal use only
  33808. */
  33809. _getKeyValue(value: any): any;
  33810. /**
  33811. * @hidden Internal use only
  33812. */
  33813. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33814. /**
  33815. * Defines the function to use to interpolate matrices
  33816. * @param startValue defines the start matrix
  33817. * @param endValue defines the end matrix
  33818. * @param gradient defines the gradient between both matrices
  33819. * @param result defines an optional target matrix where to store the interpolation
  33820. * @returns the interpolated matrix
  33821. */
  33822. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33823. /**
  33824. * Makes a copy of the animation
  33825. * @returns Cloned animation
  33826. */
  33827. clone(): Animation;
  33828. /**
  33829. * Sets the key frames of the animation
  33830. * @param values The animation key frames to set
  33831. */
  33832. setKeys(values: Array<IAnimationKey>): void;
  33833. /**
  33834. * Serializes the animation to an object
  33835. * @returns Serialized object
  33836. */
  33837. serialize(): any;
  33838. /**
  33839. * Float animation type
  33840. */
  33841. static readonly ANIMATIONTYPE_FLOAT: number;
  33842. /**
  33843. * Vector3 animation type
  33844. */
  33845. static readonly ANIMATIONTYPE_VECTOR3: number;
  33846. /**
  33847. * Quaternion animation type
  33848. */
  33849. static readonly ANIMATIONTYPE_QUATERNION: number;
  33850. /**
  33851. * Matrix animation type
  33852. */
  33853. static readonly ANIMATIONTYPE_MATRIX: number;
  33854. /**
  33855. * Color3 animation type
  33856. */
  33857. static readonly ANIMATIONTYPE_COLOR3: number;
  33858. /**
  33859. * Color3 animation type
  33860. */
  33861. static readonly ANIMATIONTYPE_COLOR4: number;
  33862. /**
  33863. * Vector2 animation type
  33864. */
  33865. static readonly ANIMATIONTYPE_VECTOR2: number;
  33866. /**
  33867. * Size animation type
  33868. */
  33869. static readonly ANIMATIONTYPE_SIZE: number;
  33870. /**
  33871. * Relative Loop Mode
  33872. */
  33873. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33874. /**
  33875. * Cycle Loop Mode
  33876. */
  33877. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33878. /**
  33879. * Constant Loop Mode
  33880. */
  33881. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33882. /** @hidden */
  33883. static _UniversalLerp(left: any, right: any, amount: number): any;
  33884. /**
  33885. * Parses an animation object and creates an animation
  33886. * @param parsedAnimation Parsed animation object
  33887. * @returns Animation object
  33888. */
  33889. static Parse(parsedAnimation: any): Animation;
  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. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33898. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33899. * @param url defines the url to load from
  33900. * @returns a promise that will resolve to the new animation or an array of animations
  33901. */
  33902. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33903. /**
  33904. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33905. * @param snippetId defines the snippet to load
  33906. * @returns a promise that will resolve to the new animation or a new array of animations
  33907. */
  33908. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33909. }
  33910. }
  33911. declare module BABYLON {
  33912. /**
  33913. * Interface containing an array of animations
  33914. */
  33915. export interface IAnimatable {
  33916. /**
  33917. * Array of animations
  33918. */
  33919. animations: Nullable<Array<Animation>>;
  33920. }
  33921. }
  33922. declare module BABYLON {
  33923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33936. /**
  33937. * Decorator used to define property that can be serialized as reference to a camera
  33938. * @param sourceName defines the name of the property to decorate
  33939. */
  33940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33941. /**
  33942. * Class used to help serialization objects
  33943. */
  33944. export class SerializationHelper {
  33945. /** @hidden */
  33946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33947. /** @hidden */
  33948. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33949. /** @hidden */
  33950. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33951. /** @hidden */
  33952. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33953. /**
  33954. * Appends the serialized animations from the source animations
  33955. * @param source Source containing the animations
  33956. * @param destination Target to store the animations
  33957. */
  33958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33959. /**
  33960. * Static function used to serialized a specific entity
  33961. * @param entity defines the entity to serialize
  33962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33963. * @returns a JSON compatible object representing the serialization of the entity
  33964. */
  33965. static Serialize<T>(entity: T, serializationObject?: any): any;
  33966. /**
  33967. * Creates a new entity from a serialization data object
  33968. * @param creationFunction defines a function used to instanciated the new entity
  33969. * @param source defines the source serialization data
  33970. * @param scene defines the hosting scene
  33971. * @param rootUrl defines the root url for resources
  33972. * @returns a new entity
  33973. */
  33974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33975. /**
  33976. * Clones an object
  33977. * @param creationFunction defines the function used to instanciate the new object
  33978. * @param source defines the source object
  33979. * @returns the cloned object
  33980. */
  33981. static Clone<T>(creationFunction: () => T, source: T): T;
  33982. /**
  33983. * Instanciates a new object based on a source one (some data will be shared between both object)
  33984. * @param creationFunction defines the function used to instanciate the new object
  33985. * @param source defines the source object
  33986. * @returns the new object
  33987. */
  33988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33989. }
  33990. }
  33991. declare module BABYLON {
  33992. /**
  33993. * Base class of all the textures in babylon.
  33994. * It groups all the common properties the materials, post process, lights... might need
  33995. * in order to make a correct use of the texture.
  33996. */
  33997. export class BaseTexture implements IAnimatable {
  33998. /**
  33999. * Default anisotropic filtering level for the application.
  34000. * It is set to 4 as a good tradeoff between perf and quality.
  34001. */
  34002. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34003. /**
  34004. * Gets or sets the unique id of the texture
  34005. */
  34006. uniqueId: number;
  34007. /**
  34008. * Define the name of the texture.
  34009. */
  34010. name: string;
  34011. /**
  34012. * Gets or sets an object used to store user defined information.
  34013. */
  34014. metadata: any;
  34015. /**
  34016. * For internal use only. Please do not use.
  34017. */
  34018. reservedDataStore: any;
  34019. private _hasAlpha;
  34020. /**
  34021. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34022. */
  34023. set hasAlpha(value: boolean);
  34024. get hasAlpha(): boolean;
  34025. /**
  34026. * Defines if the alpha value should be determined via the rgb values.
  34027. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34028. */
  34029. getAlphaFromRGB: boolean;
  34030. /**
  34031. * Intensity or strength of the texture.
  34032. * It is commonly used by materials to fine tune the intensity of the texture
  34033. */
  34034. level: number;
  34035. /**
  34036. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34037. * This is part of the texture as textures usually maps to one uv set.
  34038. */
  34039. coordinatesIndex: number;
  34040. protected _coordinatesMode: number;
  34041. /**
  34042. * How a texture is mapped.
  34043. *
  34044. * | Value | Type | Description |
  34045. * | ----- | ----------------------------------- | ----------- |
  34046. * | 0 | EXPLICIT_MODE | |
  34047. * | 1 | SPHERICAL_MODE | |
  34048. * | 2 | PLANAR_MODE | |
  34049. * | 3 | CUBIC_MODE | |
  34050. * | 4 | PROJECTION_MODE | |
  34051. * | 5 | SKYBOX_MODE | |
  34052. * | 6 | INVCUBIC_MODE | |
  34053. * | 7 | EQUIRECTANGULAR_MODE | |
  34054. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34055. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34056. */
  34057. set coordinatesMode(value: number);
  34058. get coordinatesMode(): number;
  34059. private _wrapU;
  34060. /**
  34061. * | Value | Type | Description |
  34062. * | ----- | ------------------ | ----------- |
  34063. * | 0 | CLAMP_ADDRESSMODE | |
  34064. * | 1 | WRAP_ADDRESSMODE | |
  34065. * | 2 | MIRROR_ADDRESSMODE | |
  34066. */
  34067. get wrapU(): number;
  34068. set wrapU(value: number);
  34069. private _wrapV;
  34070. /**
  34071. * | Value | Type | Description |
  34072. * | ----- | ------------------ | ----------- |
  34073. * | 0 | CLAMP_ADDRESSMODE | |
  34074. * | 1 | WRAP_ADDRESSMODE | |
  34075. * | 2 | MIRROR_ADDRESSMODE | |
  34076. */
  34077. get wrapV(): number;
  34078. set wrapV(value: number);
  34079. /**
  34080. * | Value | Type | Description |
  34081. * | ----- | ------------------ | ----------- |
  34082. * | 0 | CLAMP_ADDRESSMODE | |
  34083. * | 1 | WRAP_ADDRESSMODE | |
  34084. * | 2 | MIRROR_ADDRESSMODE | |
  34085. */
  34086. wrapR: number;
  34087. /**
  34088. * With compliant hardware and browser (supporting anisotropic filtering)
  34089. * this defines the level of anisotropic filtering in the texture.
  34090. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34091. */
  34092. anisotropicFilteringLevel: number;
  34093. /**
  34094. * Define if the texture is a cube texture or if false a 2d texture.
  34095. */
  34096. get isCube(): boolean;
  34097. set isCube(value: boolean);
  34098. /**
  34099. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34100. */
  34101. get is3D(): boolean;
  34102. set is3D(value: boolean);
  34103. /**
  34104. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34105. */
  34106. get is2DArray(): boolean;
  34107. set is2DArray(value: boolean);
  34108. private _gammaSpace;
  34109. /**
  34110. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34111. * HDR texture are usually stored in linear space.
  34112. * This only impacts the PBR and Background materials
  34113. */
  34114. get gammaSpace(): boolean;
  34115. set gammaSpace(gamma: boolean);
  34116. /**
  34117. * Gets or sets whether or not the texture contains RGBD data.
  34118. */
  34119. get isRGBD(): boolean;
  34120. set isRGBD(value: boolean);
  34121. /**
  34122. * Is Z inverted in the texture (useful in a cube texture).
  34123. */
  34124. invertZ: boolean;
  34125. /**
  34126. * Are mip maps generated for this texture or not.
  34127. */
  34128. get noMipmap(): boolean;
  34129. /**
  34130. * @hidden
  34131. */
  34132. lodLevelInAlpha: boolean;
  34133. /**
  34134. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34135. */
  34136. get lodGenerationOffset(): number;
  34137. set lodGenerationOffset(value: number);
  34138. /**
  34139. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34140. */
  34141. get lodGenerationScale(): number;
  34142. set lodGenerationScale(value: number);
  34143. /**
  34144. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34145. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34146. * average roughness values.
  34147. */
  34148. get linearSpecularLOD(): boolean;
  34149. set linearSpecularLOD(value: boolean);
  34150. /**
  34151. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34152. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34153. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34154. */
  34155. get irradianceTexture(): Nullable<BaseTexture>;
  34156. set irradianceTexture(value: Nullable<BaseTexture>);
  34157. /**
  34158. * Define if the texture is a render target.
  34159. */
  34160. isRenderTarget: boolean;
  34161. /**
  34162. * Define the unique id of the texture in the scene.
  34163. */
  34164. get uid(): string;
  34165. /** @hidden */
  34166. _prefiltered: boolean;
  34167. /**
  34168. * Return a string representation of the texture.
  34169. * @returns the texture as a string
  34170. */
  34171. toString(): string;
  34172. /**
  34173. * Get the class name of the texture.
  34174. * @returns "BaseTexture"
  34175. */
  34176. getClassName(): string;
  34177. /**
  34178. * Define the list of animation attached to the texture.
  34179. */
  34180. animations: Animation[];
  34181. /**
  34182. * An event triggered when the texture is disposed.
  34183. */
  34184. onDisposeObservable: Observable<BaseTexture>;
  34185. private _onDisposeObserver;
  34186. /**
  34187. * Callback triggered when the texture has been disposed.
  34188. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34189. */
  34190. set onDispose(callback: () => void);
  34191. /**
  34192. * Define the current state of the loading sequence when in delayed load mode.
  34193. */
  34194. delayLoadState: number;
  34195. protected _scene: Nullable<Scene>;
  34196. protected _engine: Nullable<ThinEngine>;
  34197. /** @hidden */
  34198. _texture: Nullable<InternalTexture>;
  34199. private _uid;
  34200. /**
  34201. * Define if the texture is preventinga material to render or not.
  34202. * If not and the texture is not ready, the engine will use a default black texture instead.
  34203. */
  34204. get isBlocking(): boolean;
  34205. /**
  34206. * Instantiates a new BaseTexture.
  34207. * Base class of all the textures in babylon.
  34208. * It groups all the common properties the materials, post process, lights... might need
  34209. * in order to make a correct use of the texture.
  34210. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34211. */
  34212. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34213. /**
  34214. * Get the scene the texture belongs to.
  34215. * @returns the scene or null if undefined
  34216. */
  34217. getScene(): Nullable<Scene>;
  34218. /** @hidden */
  34219. protected _getEngine(): Nullable<ThinEngine>;
  34220. /**
  34221. * Get the texture transform matrix used to offset tile the texture for istance.
  34222. * @returns the transformation matrix
  34223. */
  34224. getTextureMatrix(): Matrix;
  34225. /**
  34226. * Get the texture reflection matrix used to rotate/transform the reflection.
  34227. * @returns the reflection matrix
  34228. */
  34229. getReflectionTextureMatrix(): Matrix;
  34230. /**
  34231. * Get the underlying lower level texture from Babylon.
  34232. * @returns the insternal texture
  34233. */
  34234. getInternalTexture(): Nullable<InternalTexture>;
  34235. /**
  34236. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34237. * @returns true if ready or not blocking
  34238. */
  34239. isReadyOrNotBlocking(): boolean;
  34240. /**
  34241. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34242. * @returns true if fully ready
  34243. */
  34244. isReady(): boolean;
  34245. private _cachedSize;
  34246. /**
  34247. * Get the size of the texture.
  34248. * @returns the texture size.
  34249. */
  34250. getSize(): ISize;
  34251. /**
  34252. * Get the base size of the texture.
  34253. * It can be different from the size if the texture has been resized for POT for instance
  34254. * @returns the base size
  34255. */
  34256. getBaseSize(): ISize;
  34257. /**
  34258. * Update the sampling mode of the texture.
  34259. * Default is Trilinear mode.
  34260. *
  34261. * | Value | Type | Description |
  34262. * | ----- | ------------------ | ----------- |
  34263. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34264. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34265. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34266. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34267. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34268. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34269. * | 7 | NEAREST_LINEAR | |
  34270. * | 8 | NEAREST_NEAREST | |
  34271. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34272. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34273. * | 11 | LINEAR_LINEAR | |
  34274. * | 12 | LINEAR_NEAREST | |
  34275. *
  34276. * > _mag_: magnification filter (close to the viewer)
  34277. * > _min_: minification filter (far from the viewer)
  34278. * > _mip_: filter used between mip map levels
  34279. *@param samplingMode Define the new sampling mode of the texture
  34280. */
  34281. updateSamplingMode(samplingMode: number): void;
  34282. /**
  34283. * Scales the texture if is `canRescale()`
  34284. * @param ratio the resize factor we want to use to rescale
  34285. */
  34286. scale(ratio: number): void;
  34287. /**
  34288. * Get if the texture can rescale.
  34289. */
  34290. get canRescale(): boolean;
  34291. /** @hidden */
  34292. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34293. /** @hidden */
  34294. _rebuild(): void;
  34295. /**
  34296. * Triggers the load sequence in delayed load mode.
  34297. */
  34298. delayLoad(): void;
  34299. /**
  34300. * Clones the texture.
  34301. * @returns the cloned texture
  34302. */
  34303. clone(): Nullable<BaseTexture>;
  34304. /**
  34305. * Get the texture underlying type (INT, FLOAT...)
  34306. */
  34307. get textureType(): number;
  34308. /**
  34309. * Get the texture underlying format (RGB, RGBA...)
  34310. */
  34311. get textureFormat(): number;
  34312. /**
  34313. * Indicates that textures need to be re-calculated for all materials
  34314. */
  34315. protected _markAllSubMeshesAsTexturesDirty(): void;
  34316. /**
  34317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34318. * This will returns an RGBA array buffer containing either in values (0-255) or
  34319. * float values (0-1) depending of the underlying buffer type.
  34320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34322. * @param buffer defines a user defined buffer to fill with data (can be null)
  34323. * @returns The Array buffer containing the pixels data.
  34324. */
  34325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34326. /**
  34327. * Release and destroy the underlying lower level texture aka internalTexture.
  34328. */
  34329. releaseInternalTexture(): void;
  34330. /** @hidden */
  34331. get _lodTextureHigh(): Nullable<BaseTexture>;
  34332. /** @hidden */
  34333. get _lodTextureMid(): Nullable<BaseTexture>;
  34334. /** @hidden */
  34335. get _lodTextureLow(): Nullable<BaseTexture>;
  34336. /**
  34337. * Dispose the texture and release its associated resources.
  34338. */
  34339. dispose(): void;
  34340. /**
  34341. * Serialize the texture into a JSON representation that can be parsed later on.
  34342. * @returns the JSON representation of the texture
  34343. */
  34344. serialize(): any;
  34345. /**
  34346. * Helper function to be called back once a list of texture contains only ready textures.
  34347. * @param textures Define the list of textures to wait for
  34348. * @param callback Define the callback triggered once the entire list will be ready
  34349. */
  34350. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34351. private static _isScene;
  34352. }
  34353. }
  34354. declare module BABYLON {
  34355. /**
  34356. * Options to be used when creating an effect.
  34357. */
  34358. export interface IEffectCreationOptions {
  34359. /**
  34360. * Atrributes that will be used in the shader.
  34361. */
  34362. attributes: string[];
  34363. /**
  34364. * Uniform varible names that will be set in the shader.
  34365. */
  34366. uniformsNames: string[];
  34367. /**
  34368. * Uniform buffer variable names that will be set in the shader.
  34369. */
  34370. uniformBuffersNames: string[];
  34371. /**
  34372. * Sampler texture variable names that will be set in the shader.
  34373. */
  34374. samplers: string[];
  34375. /**
  34376. * Define statements that will be set in the shader.
  34377. */
  34378. defines: any;
  34379. /**
  34380. * Possible fallbacks for this effect to improve performance when needed.
  34381. */
  34382. fallbacks: Nullable<IEffectFallbacks>;
  34383. /**
  34384. * Callback that will be called when the shader is compiled.
  34385. */
  34386. onCompiled: Nullable<(effect: Effect) => void>;
  34387. /**
  34388. * Callback that will be called if an error occurs during shader compilation.
  34389. */
  34390. onError: Nullable<(effect: Effect, errors: string) => void>;
  34391. /**
  34392. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34393. */
  34394. indexParameters?: any;
  34395. /**
  34396. * Max number of lights that can be used in the shader.
  34397. */
  34398. maxSimultaneousLights?: number;
  34399. /**
  34400. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34401. */
  34402. transformFeedbackVaryings?: Nullable<string[]>;
  34403. /**
  34404. * 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
  34405. */
  34406. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34407. /**
  34408. * Is this effect rendering to several color attachments ?
  34409. */
  34410. multiTarget?: boolean;
  34411. }
  34412. /**
  34413. * Effect containing vertex and fragment shader that can be executed on an object.
  34414. */
  34415. export class Effect implements IDisposable {
  34416. /**
  34417. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34418. */
  34419. static ShadersRepository: string;
  34420. /**
  34421. * Enable logging of the shader code when a compilation error occurs
  34422. */
  34423. static LogShaderCodeOnCompilationError: boolean;
  34424. /**
  34425. * Name of the effect.
  34426. */
  34427. name: any;
  34428. /**
  34429. * String container all the define statements that should be set on the shader.
  34430. */
  34431. defines: string;
  34432. /**
  34433. * Callback that will be called when the shader is compiled.
  34434. */
  34435. onCompiled: Nullable<(effect: Effect) => void>;
  34436. /**
  34437. * Callback that will be called if an error occurs during shader compilation.
  34438. */
  34439. onError: Nullable<(effect: Effect, errors: string) => void>;
  34440. /**
  34441. * Callback that will be called when effect is bound.
  34442. */
  34443. onBind: Nullable<(effect: Effect) => void>;
  34444. /**
  34445. * Unique ID of the effect.
  34446. */
  34447. uniqueId: number;
  34448. /**
  34449. * Observable that will be called when the shader is compiled.
  34450. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34451. */
  34452. onCompileObservable: Observable<Effect>;
  34453. /**
  34454. * Observable that will be called if an error occurs during shader compilation.
  34455. */
  34456. onErrorObservable: Observable<Effect>;
  34457. /** @hidden */
  34458. _onBindObservable: Nullable<Observable<Effect>>;
  34459. /**
  34460. * @hidden
  34461. * Specifies if the effect was previously ready
  34462. */
  34463. _wasPreviouslyReady: boolean;
  34464. /**
  34465. * Observable that will be called when effect is bound.
  34466. */
  34467. get onBindObservable(): Observable<Effect>;
  34468. /** @hidden */
  34469. _bonesComputationForcedToCPU: boolean;
  34470. /** @hidden */
  34471. _multiTarget: boolean;
  34472. private static _uniqueIdSeed;
  34473. private _engine;
  34474. private _uniformBuffersNames;
  34475. private _uniformBuffersNamesList;
  34476. private _uniformsNames;
  34477. private _samplerList;
  34478. private _samplers;
  34479. private _isReady;
  34480. private _compilationError;
  34481. private _allFallbacksProcessed;
  34482. private _attributesNames;
  34483. private _attributes;
  34484. private _attributeLocationByName;
  34485. private _uniforms;
  34486. /**
  34487. * Key for the effect.
  34488. * @hidden
  34489. */
  34490. _key: string;
  34491. private _indexParameters;
  34492. private _fallbacks;
  34493. private _vertexSourceCode;
  34494. private _fragmentSourceCode;
  34495. private _vertexSourceCodeOverride;
  34496. private _fragmentSourceCodeOverride;
  34497. private _transformFeedbackVaryings;
  34498. /**
  34499. * Compiled shader to webGL program.
  34500. * @hidden
  34501. */
  34502. _pipelineContext: Nullable<IPipelineContext>;
  34503. private _valueCache;
  34504. private static _baseCache;
  34505. /**
  34506. * Instantiates an effect.
  34507. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34508. * @param baseName Name of the effect.
  34509. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34510. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34511. * @param samplers List of sampler variables that will be passed to the shader.
  34512. * @param engine Engine to be used to render the effect
  34513. * @param defines Define statements to be added to the shader.
  34514. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34515. * @param onCompiled Callback that will be called when the shader is compiled.
  34516. * @param onError Callback that will be called if an error occurs during shader compilation.
  34517. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34518. */
  34519. 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);
  34520. private _useFinalCode;
  34521. /**
  34522. * Unique key for this effect
  34523. */
  34524. get key(): string;
  34525. /**
  34526. * If the effect has been compiled and prepared.
  34527. * @returns if the effect is compiled and prepared.
  34528. */
  34529. isReady(): boolean;
  34530. private _isReadyInternal;
  34531. /**
  34532. * The engine the effect was initialized with.
  34533. * @returns the engine.
  34534. */
  34535. getEngine(): Engine;
  34536. /**
  34537. * The pipeline context for this effect
  34538. * @returns the associated pipeline context
  34539. */
  34540. getPipelineContext(): Nullable<IPipelineContext>;
  34541. /**
  34542. * The set of names of attribute variables for the shader.
  34543. * @returns An array of attribute names.
  34544. */
  34545. getAttributesNames(): string[];
  34546. /**
  34547. * Returns the attribute at the given index.
  34548. * @param index The index of the attribute.
  34549. * @returns The location of the attribute.
  34550. */
  34551. getAttributeLocation(index: number): number;
  34552. /**
  34553. * Returns the attribute based on the name of the variable.
  34554. * @param name of the attribute to look up.
  34555. * @returns the attribute location.
  34556. */
  34557. getAttributeLocationByName(name: string): number;
  34558. /**
  34559. * The number of attributes.
  34560. * @returns the numnber of attributes.
  34561. */
  34562. getAttributesCount(): number;
  34563. /**
  34564. * Gets the index of a uniform variable.
  34565. * @param uniformName of the uniform to look up.
  34566. * @returns the index.
  34567. */
  34568. getUniformIndex(uniformName: string): number;
  34569. /**
  34570. * Returns the attribute based on the name of the variable.
  34571. * @param uniformName of the uniform to look up.
  34572. * @returns the location of the uniform.
  34573. */
  34574. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34575. /**
  34576. * Returns an array of sampler variable names
  34577. * @returns The array of sampler variable names.
  34578. */
  34579. getSamplers(): string[];
  34580. /**
  34581. * Returns an array of uniform variable names
  34582. * @returns The array of uniform variable names.
  34583. */
  34584. getUniformNames(): string[];
  34585. /**
  34586. * Returns an array of uniform buffer variable names
  34587. * @returns The array of uniform buffer variable names.
  34588. */
  34589. getUniformBuffersNames(): string[];
  34590. /**
  34591. * Returns the index parameters used to create the effect
  34592. * @returns The index parameters object
  34593. */
  34594. getIndexParameters(): any;
  34595. /**
  34596. * The error from the last compilation.
  34597. * @returns the error string.
  34598. */
  34599. getCompilationError(): string;
  34600. /**
  34601. * Gets a boolean indicating that all fallbacks were used during compilation
  34602. * @returns true if all fallbacks were used
  34603. */
  34604. allFallbacksProcessed(): boolean;
  34605. /**
  34606. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34607. * @param func The callback to be used.
  34608. */
  34609. executeWhenCompiled(func: (effect: Effect) => void): void;
  34610. private _checkIsReady;
  34611. private _loadShader;
  34612. /**
  34613. * Gets the vertex shader source code of this effect
  34614. */
  34615. get vertexSourceCode(): string;
  34616. /**
  34617. * Gets the fragment shader source code of this effect
  34618. */
  34619. get fragmentSourceCode(): string;
  34620. /**
  34621. * Recompiles the webGL program
  34622. * @param vertexSourceCode The source code for the vertex shader.
  34623. * @param fragmentSourceCode The source code for the fragment shader.
  34624. * @param onCompiled Callback called when completed.
  34625. * @param onError Callback called on error.
  34626. * @hidden
  34627. */
  34628. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34629. /**
  34630. * Prepares the effect
  34631. * @hidden
  34632. */
  34633. _prepareEffect(): void;
  34634. private _getShaderCodeAndErrorLine;
  34635. private _processCompilationErrors;
  34636. /**
  34637. * Checks if the effect is supported. (Must be called after compilation)
  34638. */
  34639. get isSupported(): boolean;
  34640. /**
  34641. * Binds a texture to the engine to be used as output of the shader.
  34642. * @param channel Name of the output variable.
  34643. * @param texture Texture to bind.
  34644. * @hidden
  34645. */
  34646. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34647. /**
  34648. * Sets a texture on the engine to be used in the shader.
  34649. * @param channel Name of the sampler variable.
  34650. * @param texture Texture to set.
  34651. */
  34652. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34653. /**
  34654. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34655. * @param channel Name of the sampler variable.
  34656. * @param texture Texture to set.
  34657. */
  34658. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34659. /**
  34660. * Sets an array of textures on the engine to be used in the shader.
  34661. * @param channel Name of the variable.
  34662. * @param textures Textures to set.
  34663. */
  34664. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34665. /**
  34666. * 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)
  34667. * @param channel Name of the sampler variable.
  34668. * @param postProcess Post process to get the input texture from.
  34669. */
  34670. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34671. /**
  34672. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34673. * 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)
  34674. * @param channel Name of the sampler variable.
  34675. * @param postProcess Post process to get the output texture from.
  34676. */
  34677. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34678. /** @hidden */
  34679. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34680. /** @hidden */
  34681. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34682. /** @hidden */
  34683. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34684. /** @hidden */
  34685. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34686. /**
  34687. * Binds a buffer to a uniform.
  34688. * @param buffer Buffer to bind.
  34689. * @param name Name of the uniform variable to bind to.
  34690. */
  34691. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34692. /**
  34693. * Binds block to a uniform.
  34694. * @param blockName Name of the block to bind.
  34695. * @param index Index to bind.
  34696. */
  34697. bindUniformBlock(blockName: string, index: number): void;
  34698. /**
  34699. * Sets an interger value on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param value Value to be set.
  34702. * @returns this effect.
  34703. */
  34704. setInt(uniformName: string, value: number): Effect;
  34705. /**
  34706. * Sets an int array on a uniform variable.
  34707. * @param uniformName Name of the variable.
  34708. * @param array array to be set.
  34709. * @returns this effect.
  34710. */
  34711. setIntArray(uniformName: string, array: Int32Array): Effect;
  34712. /**
  34713. * 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)
  34714. * @param uniformName Name of the variable.
  34715. * @param array array to be set.
  34716. * @returns this effect.
  34717. */
  34718. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34719. /**
  34720. * 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)
  34721. * @param uniformName Name of the variable.
  34722. * @param array array to be set.
  34723. * @returns this effect.
  34724. */
  34725. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34726. /**
  34727. * 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)
  34728. * @param uniformName Name of the variable.
  34729. * @param array array to be set.
  34730. * @returns this effect.
  34731. */
  34732. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34733. /**
  34734. * Sets an float array on a uniform variable.
  34735. * @param uniformName Name of the variable.
  34736. * @param array array to be set.
  34737. * @returns this effect.
  34738. */
  34739. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34740. /**
  34741. * 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)
  34742. * @param uniformName Name of the variable.
  34743. * @param array array to be set.
  34744. * @returns this effect.
  34745. */
  34746. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34747. /**
  34748. * 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)
  34749. * @param uniformName Name of the variable.
  34750. * @param array array to be set.
  34751. * @returns this effect.
  34752. */
  34753. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34754. /**
  34755. * 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)
  34756. * @param uniformName Name of the variable.
  34757. * @param array array to be set.
  34758. * @returns this effect.
  34759. */
  34760. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34761. /**
  34762. * Sets an array on a uniform variable.
  34763. * @param uniformName Name of the variable.
  34764. * @param array array to be set.
  34765. * @returns this effect.
  34766. */
  34767. setArray(uniformName: string, array: number[]): Effect;
  34768. /**
  34769. * 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)
  34770. * @param uniformName Name of the variable.
  34771. * @param array array to be set.
  34772. * @returns this effect.
  34773. */
  34774. setArray2(uniformName: string, array: number[]): Effect;
  34775. /**
  34776. * 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)
  34777. * @param uniformName Name of the variable.
  34778. * @param array array to be set.
  34779. * @returns this effect.
  34780. */
  34781. setArray3(uniformName: string, array: number[]): Effect;
  34782. /**
  34783. * 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)
  34784. * @param uniformName Name of the variable.
  34785. * @param array array to be set.
  34786. * @returns this effect.
  34787. */
  34788. setArray4(uniformName: string, array: number[]): Effect;
  34789. /**
  34790. * Sets matrices on a uniform variable.
  34791. * @param uniformName Name of the variable.
  34792. * @param matrices matrices to be set.
  34793. * @returns this effect.
  34794. */
  34795. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34796. /**
  34797. * Sets matrix on a uniform variable.
  34798. * @param uniformName Name of the variable.
  34799. * @param matrix matrix to be set.
  34800. * @returns this effect.
  34801. */
  34802. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34803. /**
  34804. * 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)
  34805. * @param uniformName Name of the variable.
  34806. * @param matrix matrix to be set.
  34807. * @returns this effect.
  34808. */
  34809. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34810. /**
  34811. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34812. * @param uniformName Name of the variable.
  34813. * @param matrix matrix to be set.
  34814. * @returns this effect.
  34815. */
  34816. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34817. /**
  34818. * Sets a float on a uniform variable.
  34819. * @param uniformName Name of the variable.
  34820. * @param value value to be set.
  34821. * @returns this effect.
  34822. */
  34823. setFloat(uniformName: string, value: number): Effect;
  34824. /**
  34825. * Sets a boolean on a uniform variable.
  34826. * @param uniformName Name of the variable.
  34827. * @param bool value to be set.
  34828. * @returns this effect.
  34829. */
  34830. setBool(uniformName: string, bool: boolean): Effect;
  34831. /**
  34832. * Sets a Vector2 on a uniform variable.
  34833. * @param uniformName Name of the variable.
  34834. * @param vector2 vector2 to be set.
  34835. * @returns this effect.
  34836. */
  34837. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34838. /**
  34839. * Sets a float2 on a uniform variable.
  34840. * @param uniformName Name of the variable.
  34841. * @param x First float in float2.
  34842. * @param y Second float in float2.
  34843. * @returns this effect.
  34844. */
  34845. setFloat2(uniformName: string, x: number, y: number): Effect;
  34846. /**
  34847. * Sets a Vector3 on a uniform variable.
  34848. * @param uniformName Name of the variable.
  34849. * @param vector3 Value to be set.
  34850. * @returns this effect.
  34851. */
  34852. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34853. /**
  34854. * Sets a float3 on a uniform variable.
  34855. * @param uniformName Name of the variable.
  34856. * @param x First float in float3.
  34857. * @param y Second float in float3.
  34858. * @param z Third float in float3.
  34859. * @returns this effect.
  34860. */
  34861. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34862. /**
  34863. * Sets a Vector4 on a uniform variable.
  34864. * @param uniformName Name of the variable.
  34865. * @param vector4 Value to be set.
  34866. * @returns this effect.
  34867. */
  34868. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34869. /**
  34870. * Sets a float4 on a uniform variable.
  34871. * @param uniformName Name of the variable.
  34872. * @param x First float in float4.
  34873. * @param y Second float in float4.
  34874. * @param z Third float in float4.
  34875. * @param w Fourth float in float4.
  34876. * @returns this effect.
  34877. */
  34878. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34879. /**
  34880. * Sets a Color3 on a uniform variable.
  34881. * @param uniformName Name of the variable.
  34882. * @param color3 Value to be set.
  34883. * @returns this effect.
  34884. */
  34885. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34886. /**
  34887. * Sets a Color4 on a uniform variable.
  34888. * @param uniformName Name of the variable.
  34889. * @param color3 Value to be set.
  34890. * @param alpha Alpha value to be set.
  34891. * @returns this effect.
  34892. */
  34893. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34894. /**
  34895. * Sets a Color4 on a uniform variable
  34896. * @param uniformName defines the name of the variable
  34897. * @param color4 defines the value to be set
  34898. * @returns this effect.
  34899. */
  34900. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34901. /** Release all associated resources */
  34902. dispose(): void;
  34903. /**
  34904. * This function will add a new shader to the shader store
  34905. * @param name the name of the shader
  34906. * @param pixelShader optional pixel shader content
  34907. * @param vertexShader optional vertex shader content
  34908. */
  34909. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34910. /**
  34911. * Store of each shader (The can be looked up using effect.key)
  34912. */
  34913. static ShadersStore: {
  34914. [key: string]: string;
  34915. };
  34916. /**
  34917. * Store of each included file for a shader (The can be looked up using effect.key)
  34918. */
  34919. static IncludesShadersStore: {
  34920. [key: string]: string;
  34921. };
  34922. /**
  34923. * Resets the cache of effects.
  34924. */
  34925. static ResetCache(): void;
  34926. }
  34927. }
  34928. declare module BABYLON {
  34929. /**
  34930. * Interface used to describe the capabilities of the engine relatively to the current browser
  34931. */
  34932. export interface EngineCapabilities {
  34933. /** Maximum textures units per fragment shader */
  34934. maxTexturesImageUnits: number;
  34935. /** Maximum texture units per vertex shader */
  34936. maxVertexTextureImageUnits: number;
  34937. /** Maximum textures units in the entire pipeline */
  34938. maxCombinedTexturesImageUnits: number;
  34939. /** Maximum texture size */
  34940. maxTextureSize: number;
  34941. /** Maximum texture samples */
  34942. maxSamples?: number;
  34943. /** Maximum cube texture size */
  34944. maxCubemapTextureSize: number;
  34945. /** Maximum render texture size */
  34946. maxRenderTextureSize: number;
  34947. /** Maximum number of vertex attributes */
  34948. maxVertexAttribs: number;
  34949. /** Maximum number of varyings */
  34950. maxVaryingVectors: number;
  34951. /** Maximum number of uniforms per vertex shader */
  34952. maxVertexUniformVectors: number;
  34953. /** Maximum number of uniforms per fragment shader */
  34954. maxFragmentUniformVectors: number;
  34955. /** Defines if standard derivates (dx/dy) are supported */
  34956. standardDerivatives: boolean;
  34957. /** Defines if s3tc texture compression is supported */
  34958. s3tc?: WEBGL_compressed_texture_s3tc;
  34959. /** Defines if pvrtc texture compression is supported */
  34960. pvrtc: any;
  34961. /** Defines if etc1 texture compression is supported */
  34962. etc1: any;
  34963. /** Defines if etc2 texture compression is supported */
  34964. etc2: any;
  34965. /** Defines if astc texture compression is supported */
  34966. astc: any;
  34967. /** Defines if bptc texture compression is supported */
  34968. bptc: any;
  34969. /** Defines if float textures are supported */
  34970. textureFloat: boolean;
  34971. /** Defines if vertex array objects are supported */
  34972. vertexArrayObject: boolean;
  34973. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34974. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34975. /** Gets the maximum level of anisotropy supported */
  34976. maxAnisotropy: number;
  34977. /** Defines if instancing is supported */
  34978. instancedArrays: boolean;
  34979. /** Defines if 32 bits indices are supported */
  34980. uintIndices: boolean;
  34981. /** Defines if high precision shaders are supported */
  34982. highPrecisionShaderSupported: boolean;
  34983. /** Defines if depth reading in the fragment shader is supported */
  34984. fragmentDepthSupported: boolean;
  34985. /** Defines if float texture linear filtering is supported*/
  34986. textureFloatLinearFiltering: boolean;
  34987. /** Defines if rendering to float textures is supported */
  34988. textureFloatRender: boolean;
  34989. /** Defines if half float textures are supported*/
  34990. textureHalfFloat: boolean;
  34991. /** Defines if half float texture linear filtering is supported*/
  34992. textureHalfFloatLinearFiltering: boolean;
  34993. /** Defines if rendering to half float textures is supported */
  34994. textureHalfFloatRender: boolean;
  34995. /** Defines if textureLOD shader command is supported */
  34996. textureLOD: boolean;
  34997. /** Defines if draw buffers extension is supported */
  34998. drawBuffersExtension: boolean;
  34999. /** Defines if depth textures are supported */
  35000. depthTextureExtension: boolean;
  35001. /** Defines if float color buffer are supported */
  35002. colorBufferFloat: boolean;
  35003. /** Gets disjoint timer query extension (null if not supported) */
  35004. timerQuery?: EXT_disjoint_timer_query;
  35005. /** Defines if timestamp can be used with timer query */
  35006. canUseTimestampForTimerQuery: boolean;
  35007. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35008. multiview?: any;
  35009. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35010. oculusMultiview?: any;
  35011. /** Function used to let the system compiles shaders in background */
  35012. parallelShaderCompile?: {
  35013. COMPLETION_STATUS_KHR: number;
  35014. };
  35015. /** Max number of texture samples for MSAA */
  35016. maxMSAASamples: number;
  35017. /** Defines if the blend min max extension is supported */
  35018. blendMinMax: boolean;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. /**
  35023. * @hidden
  35024. **/
  35025. export class DepthCullingState {
  35026. private _isDepthTestDirty;
  35027. private _isDepthMaskDirty;
  35028. private _isDepthFuncDirty;
  35029. private _isCullFaceDirty;
  35030. private _isCullDirty;
  35031. private _isZOffsetDirty;
  35032. private _isFrontFaceDirty;
  35033. private _depthTest;
  35034. private _depthMask;
  35035. private _depthFunc;
  35036. private _cull;
  35037. private _cullFace;
  35038. private _zOffset;
  35039. private _frontFace;
  35040. /**
  35041. * Initializes the state.
  35042. */
  35043. constructor();
  35044. get isDirty(): boolean;
  35045. get zOffset(): number;
  35046. set zOffset(value: number);
  35047. get cullFace(): Nullable<number>;
  35048. set cullFace(value: Nullable<number>);
  35049. get cull(): Nullable<boolean>;
  35050. set cull(value: Nullable<boolean>);
  35051. get depthFunc(): Nullable<number>;
  35052. set depthFunc(value: Nullable<number>);
  35053. get depthMask(): boolean;
  35054. set depthMask(value: boolean);
  35055. get depthTest(): boolean;
  35056. set depthTest(value: boolean);
  35057. get frontFace(): Nullable<number>;
  35058. set frontFace(value: Nullable<number>);
  35059. reset(): void;
  35060. apply(gl: WebGLRenderingContext): void;
  35061. }
  35062. }
  35063. declare module BABYLON {
  35064. /**
  35065. * @hidden
  35066. **/
  35067. export class StencilState {
  35068. /** 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 */
  35069. static readonly ALWAYS: number;
  35070. /** Passed to stencilOperation to specify that stencil value must be kept */
  35071. static readonly KEEP: number;
  35072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35073. static readonly REPLACE: number;
  35074. private _isStencilTestDirty;
  35075. private _isStencilMaskDirty;
  35076. private _isStencilFuncDirty;
  35077. private _isStencilOpDirty;
  35078. private _stencilTest;
  35079. private _stencilMask;
  35080. private _stencilFunc;
  35081. private _stencilFuncRef;
  35082. private _stencilFuncMask;
  35083. private _stencilOpStencilFail;
  35084. private _stencilOpDepthFail;
  35085. private _stencilOpStencilDepthPass;
  35086. get isDirty(): boolean;
  35087. get stencilFunc(): number;
  35088. set stencilFunc(value: number);
  35089. get stencilFuncRef(): number;
  35090. set stencilFuncRef(value: number);
  35091. get stencilFuncMask(): number;
  35092. set stencilFuncMask(value: number);
  35093. get stencilOpStencilFail(): number;
  35094. set stencilOpStencilFail(value: number);
  35095. get stencilOpDepthFail(): number;
  35096. set stencilOpDepthFail(value: number);
  35097. get stencilOpStencilDepthPass(): number;
  35098. set stencilOpStencilDepthPass(value: number);
  35099. get stencilMask(): number;
  35100. set stencilMask(value: number);
  35101. get stencilTest(): boolean;
  35102. set stencilTest(value: boolean);
  35103. constructor();
  35104. reset(): void;
  35105. apply(gl: WebGLRenderingContext): void;
  35106. }
  35107. }
  35108. declare module BABYLON {
  35109. /**
  35110. * @hidden
  35111. **/
  35112. export class AlphaState {
  35113. private _isAlphaBlendDirty;
  35114. private _isBlendFunctionParametersDirty;
  35115. private _isBlendEquationParametersDirty;
  35116. private _isBlendConstantsDirty;
  35117. private _alphaBlend;
  35118. private _blendFunctionParameters;
  35119. private _blendEquationParameters;
  35120. private _blendConstants;
  35121. /**
  35122. * Initializes the state.
  35123. */
  35124. constructor();
  35125. get isDirty(): boolean;
  35126. get alphaBlend(): boolean;
  35127. set alphaBlend(value: boolean);
  35128. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35129. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35130. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35131. reset(): void;
  35132. apply(gl: WebGLRenderingContext): void;
  35133. }
  35134. }
  35135. declare module BABYLON {
  35136. /** @hidden */
  35137. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35138. attributeProcessor(attribute: string): string;
  35139. varyingProcessor(varying: string, isFragment: boolean): string;
  35140. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35141. }
  35142. }
  35143. declare module BABYLON {
  35144. /**
  35145. * Interface for attribute information associated with buffer instanciation
  35146. */
  35147. export interface InstancingAttributeInfo {
  35148. /**
  35149. * Name of the GLSL attribute
  35150. * if attribute index is not specified, this is used to retrieve the index from the effect
  35151. */
  35152. attributeName: string;
  35153. /**
  35154. * Index/offset of the attribute in the vertex shader
  35155. * if not specified, this will be computes from the name.
  35156. */
  35157. index?: number;
  35158. /**
  35159. * size of the attribute, 1, 2, 3 or 4
  35160. */
  35161. attributeSize: number;
  35162. /**
  35163. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35164. */
  35165. offset: number;
  35166. /**
  35167. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35168. * default to 1
  35169. */
  35170. divisor?: number;
  35171. /**
  35172. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35173. * default is FLOAT
  35174. */
  35175. attributeType?: number;
  35176. /**
  35177. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35178. */
  35179. normalized?: boolean;
  35180. }
  35181. }
  35182. declare module BABYLON {
  35183. interface ThinEngine {
  35184. /**
  35185. * Update a video texture
  35186. * @param texture defines the texture to update
  35187. * @param video defines the video element to use
  35188. * @param invertY defines if data must be stored with Y axis inverted
  35189. */
  35190. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35191. }
  35192. }
  35193. declare module BABYLON {
  35194. interface ThinEngine {
  35195. /**
  35196. * Creates a dynamic texture
  35197. * @param width defines the width of the texture
  35198. * @param height defines the height of the texture
  35199. * @param generateMipMaps defines if the engine should generate the mip levels
  35200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35201. * @returns the dynamic texture inside an InternalTexture
  35202. */
  35203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35204. /**
  35205. * Update the content of a dynamic texture
  35206. * @param texture defines the texture to update
  35207. * @param canvas defines the canvas containing the source
  35208. * @param invertY defines if data must be stored with Y axis inverted
  35209. * @param premulAlpha defines if alpha is stored as premultiplied
  35210. * @param format defines the format of the data
  35211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35212. */
  35213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35214. }
  35215. }
  35216. declare module BABYLON {
  35217. /**
  35218. * Settings for finer control over video usage
  35219. */
  35220. export interface VideoTextureSettings {
  35221. /**
  35222. * Applies `autoplay` to video, if specified
  35223. */
  35224. autoPlay?: boolean;
  35225. /**
  35226. * Applies `loop` to video, if specified
  35227. */
  35228. loop?: boolean;
  35229. /**
  35230. * Automatically updates internal texture from video at every frame in the render loop
  35231. */
  35232. autoUpdateTexture: boolean;
  35233. /**
  35234. * Image src displayed during the video loading or until the user interacts with the video.
  35235. */
  35236. poster?: string;
  35237. }
  35238. /**
  35239. * If you want to display a video in your scene, this is the special texture for that.
  35240. * This special texture works similar to other textures, with the exception of a few parameters.
  35241. * @see https://doc.babylonjs.com/how_to/video_texture
  35242. */
  35243. export class VideoTexture extends Texture {
  35244. /**
  35245. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35246. */
  35247. readonly autoUpdateTexture: boolean;
  35248. /**
  35249. * The video instance used by the texture internally
  35250. */
  35251. readonly video: HTMLVideoElement;
  35252. private _onUserActionRequestedObservable;
  35253. /**
  35254. * Event triggerd when a dom action is required by the user to play the video.
  35255. * This happens due to recent changes in browser policies preventing video to auto start.
  35256. */
  35257. get onUserActionRequestedObservable(): Observable<Texture>;
  35258. private _generateMipMaps;
  35259. private _stillImageCaptured;
  35260. private _displayingPosterTexture;
  35261. private _settings;
  35262. private _createInternalTextureOnEvent;
  35263. private _frameId;
  35264. private _currentSrc;
  35265. /**
  35266. * Creates a video texture.
  35267. * If you want to display a video in your scene, this is the special texture for that.
  35268. * This special texture works similar to other textures, with the exception of a few parameters.
  35269. * @see https://doc.babylonjs.com/how_to/video_texture
  35270. * @param name optional name, will detect from video source, if not defined
  35271. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35272. * @param scene is obviously the current scene.
  35273. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35274. * @param invertY is false by default but can be used to invert video on Y axis
  35275. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35276. * @param settings allows finer control over video usage
  35277. */
  35278. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35279. private _getName;
  35280. private _getVideo;
  35281. private _createInternalTexture;
  35282. private reset;
  35283. /**
  35284. * @hidden Internal method to initiate `update`.
  35285. */
  35286. _rebuild(): void;
  35287. /**
  35288. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35289. */
  35290. update(): void;
  35291. /**
  35292. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35293. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35294. */
  35295. updateTexture(isVisible: boolean): void;
  35296. protected _updateInternalTexture: () => void;
  35297. /**
  35298. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35299. * @param url New url.
  35300. */
  35301. updateURL(url: string): void;
  35302. /**
  35303. * Clones the texture.
  35304. * @returns the cloned texture
  35305. */
  35306. clone(): VideoTexture;
  35307. /**
  35308. * Dispose the texture and release its associated resources.
  35309. */
  35310. dispose(): void;
  35311. /**
  35312. * Creates a video texture straight from a stream.
  35313. * @param scene Define the scene the texture should be created in
  35314. * @param stream Define the stream the texture should be created from
  35315. * @returns The created video texture as a promise
  35316. */
  35317. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35318. /**
  35319. * Creates a video texture straight from your WebCam video feed.
  35320. * @param scene Define the scene the texture should be created in
  35321. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35322. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35323. * @returns The created video texture as a promise
  35324. */
  35325. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35326. minWidth: number;
  35327. maxWidth: number;
  35328. minHeight: number;
  35329. maxHeight: number;
  35330. deviceId: string;
  35331. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35332. /**
  35333. * Creates a video texture straight from your WebCam video feed.
  35334. * @param scene Define the scene the texture should be created in
  35335. * @param onReady Define a callback to triggered once the texture will be ready
  35336. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35337. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35338. */
  35339. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35340. minWidth: number;
  35341. maxWidth: number;
  35342. minHeight: number;
  35343. maxHeight: number;
  35344. deviceId: string;
  35345. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35346. }
  35347. }
  35348. declare module BABYLON {
  35349. /**
  35350. * Defines the interface used by objects working like Scene
  35351. * @hidden
  35352. */
  35353. export interface ISceneLike {
  35354. _addPendingData(data: any): void;
  35355. _removePendingData(data: any): void;
  35356. offlineProvider: IOfflineProvider;
  35357. }
  35358. /**
  35359. * Information about the current host
  35360. */
  35361. export interface HostInformation {
  35362. /**
  35363. * Defines if the current host is a mobile
  35364. */
  35365. isMobile: boolean;
  35366. }
  35367. /** Interface defining initialization parameters for Engine class */
  35368. export interface EngineOptions extends WebGLContextAttributes {
  35369. /**
  35370. * Defines if the engine should no exceed a specified device ratio
  35371. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35372. */
  35373. limitDeviceRatio?: number;
  35374. /**
  35375. * Defines if webvr should be enabled automatically
  35376. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35377. */
  35378. autoEnableWebVR?: boolean;
  35379. /**
  35380. * Defines if webgl2 should be turned off even if supported
  35381. * @see https://doc.babylonjs.com/features/webgl2
  35382. */
  35383. disableWebGL2Support?: boolean;
  35384. /**
  35385. * Defines if webaudio should be initialized as well
  35386. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35387. */
  35388. audioEngine?: boolean;
  35389. /**
  35390. * Defines if animations should run using a deterministic lock step
  35391. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35392. */
  35393. deterministicLockstep?: boolean;
  35394. /** Defines the maximum steps to use with deterministic lock step mode */
  35395. lockstepMaxSteps?: number;
  35396. /** Defines the seconds between each deterministic lock step */
  35397. timeStep?: number;
  35398. /**
  35399. * Defines that engine should ignore context lost events
  35400. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35401. */
  35402. doNotHandleContextLost?: boolean;
  35403. /**
  35404. * Defines that engine should ignore modifying touch action attribute and style
  35405. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35406. */
  35407. doNotHandleTouchAction?: boolean;
  35408. /**
  35409. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35410. */
  35411. useHighPrecisionFloats?: boolean;
  35412. /**
  35413. * Make the canvas XR Compatible for XR sessions
  35414. */
  35415. xrCompatible?: boolean;
  35416. /**
  35417. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35418. */
  35419. useHighPrecisionMatrix?: boolean;
  35420. }
  35421. /**
  35422. * The base engine class (root of all engines)
  35423. */
  35424. export class ThinEngine {
  35425. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35426. static ExceptionList: ({
  35427. key: string;
  35428. capture: string;
  35429. captureConstraint: number;
  35430. targets: string[];
  35431. } | {
  35432. key: string;
  35433. capture: null;
  35434. captureConstraint: null;
  35435. targets: string[];
  35436. })[];
  35437. /** @hidden */
  35438. static _TextureLoaders: IInternalTextureLoader[];
  35439. /**
  35440. * Returns the current npm package of the sdk
  35441. */
  35442. static get NpmPackage(): string;
  35443. /**
  35444. * Returns the current version of the framework
  35445. */
  35446. static get Version(): string;
  35447. /**
  35448. * Returns a string describing the current engine
  35449. */
  35450. get description(): string;
  35451. /**
  35452. * Gets or sets the epsilon value used by collision engine
  35453. */
  35454. static CollisionsEpsilon: number;
  35455. /**
  35456. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35457. */
  35458. static get ShadersRepository(): string;
  35459. static set ShadersRepository(value: string);
  35460. /** @hidden */
  35461. _shaderProcessor: IShaderProcessor;
  35462. /**
  35463. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35464. */
  35465. forcePOTTextures: boolean;
  35466. /**
  35467. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35468. */
  35469. isFullscreen: boolean;
  35470. /**
  35471. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35472. */
  35473. cullBackFaces: boolean;
  35474. /**
  35475. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35476. */
  35477. renderEvenInBackground: boolean;
  35478. /**
  35479. * Gets or sets a boolean indicating that cache can be kept between frames
  35480. */
  35481. preventCacheWipeBetweenFrames: boolean;
  35482. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35483. validateShaderPrograms: boolean;
  35484. /**
  35485. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35486. * This can provide greater z depth for distant objects.
  35487. */
  35488. useReverseDepthBuffer: boolean;
  35489. /**
  35490. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35491. */
  35492. disableUniformBuffers: boolean;
  35493. /** @hidden */
  35494. _uniformBuffers: UniformBuffer[];
  35495. /**
  35496. * Gets a boolean indicating that the engine supports uniform buffers
  35497. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35498. */
  35499. get supportsUniformBuffers(): boolean;
  35500. /** @hidden */
  35501. _gl: WebGLRenderingContext;
  35502. /** @hidden */
  35503. _webGLVersion: number;
  35504. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35505. protected _windowIsBackground: boolean;
  35506. protected _creationOptions: EngineOptions;
  35507. protected _highPrecisionShadersAllowed: boolean;
  35508. /** @hidden */
  35509. get _shouldUseHighPrecisionShader(): boolean;
  35510. /**
  35511. * Gets a boolean indicating that only power of 2 textures are supported
  35512. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35513. */
  35514. get needPOTTextures(): boolean;
  35515. /** @hidden */
  35516. _badOS: boolean;
  35517. /** @hidden */
  35518. _badDesktopOS: boolean;
  35519. private _hardwareScalingLevel;
  35520. /** @hidden */
  35521. _caps: EngineCapabilities;
  35522. private _isStencilEnable;
  35523. private _glVersion;
  35524. private _glRenderer;
  35525. private _glVendor;
  35526. /** @hidden */
  35527. _videoTextureSupported: boolean;
  35528. protected _renderingQueueLaunched: boolean;
  35529. protected _activeRenderLoops: (() => void)[];
  35530. /**
  35531. * Observable signaled when a context lost event is raised
  35532. */
  35533. onContextLostObservable: Observable<ThinEngine>;
  35534. /**
  35535. * Observable signaled when a context restored event is raised
  35536. */
  35537. onContextRestoredObservable: Observable<ThinEngine>;
  35538. private _onContextLost;
  35539. private _onContextRestored;
  35540. protected _contextWasLost: boolean;
  35541. /** @hidden */
  35542. _doNotHandleContextLost: boolean;
  35543. /**
  35544. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35546. */
  35547. get doNotHandleContextLost(): boolean;
  35548. set doNotHandleContextLost(value: boolean);
  35549. /**
  35550. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35551. */
  35552. disableVertexArrayObjects: boolean;
  35553. /** @hidden */
  35554. protected _colorWrite: boolean;
  35555. /** @hidden */
  35556. protected _colorWriteChanged: boolean;
  35557. /** @hidden */
  35558. protected _depthCullingState: DepthCullingState;
  35559. /** @hidden */
  35560. protected _stencilState: StencilState;
  35561. /** @hidden */
  35562. _alphaState: AlphaState;
  35563. /** @hidden */
  35564. _alphaMode: number;
  35565. /** @hidden */
  35566. _alphaEquation: number;
  35567. /** @hidden */
  35568. _internalTexturesCache: InternalTexture[];
  35569. /** @hidden */
  35570. protected _activeChannel: number;
  35571. private _currentTextureChannel;
  35572. /** @hidden */
  35573. protected _boundTexturesCache: {
  35574. [key: string]: Nullable<InternalTexture>;
  35575. };
  35576. /** @hidden */
  35577. protected _currentEffect: Nullable<Effect>;
  35578. /** @hidden */
  35579. protected _currentProgram: Nullable<WebGLProgram>;
  35580. private _compiledEffects;
  35581. private _vertexAttribArraysEnabled;
  35582. /** @hidden */
  35583. protected _cachedViewport: Nullable<IViewportLike>;
  35584. private _cachedVertexArrayObject;
  35585. /** @hidden */
  35586. protected _cachedVertexBuffers: any;
  35587. /** @hidden */
  35588. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35589. /** @hidden */
  35590. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35591. /** @hidden */
  35592. _currentRenderTarget: Nullable<InternalTexture>;
  35593. private _uintIndicesCurrentlySet;
  35594. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35595. /** @hidden */
  35596. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35597. /** @hidden */
  35598. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35599. private _currentBufferPointers;
  35600. private _currentInstanceLocations;
  35601. private _currentInstanceBuffers;
  35602. private _textureUnits;
  35603. /** @hidden */
  35604. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35605. /** @hidden */
  35606. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35607. /** @hidden */
  35608. _boundRenderFunction: any;
  35609. private _vaoRecordInProgress;
  35610. private _mustWipeVertexAttributes;
  35611. private _emptyTexture;
  35612. private _emptyCubeTexture;
  35613. private _emptyTexture3D;
  35614. private _emptyTexture2DArray;
  35615. /** @hidden */
  35616. _frameHandler: number;
  35617. private _nextFreeTextureSlots;
  35618. private _maxSimultaneousTextures;
  35619. private _activeRequests;
  35620. /** @hidden */
  35621. _transformTextureUrl: Nullable<(url: string) => string>;
  35622. /**
  35623. * Gets information about the current host
  35624. */
  35625. hostInformation: HostInformation;
  35626. protected get _supportsHardwareTextureRescaling(): boolean;
  35627. private _framebufferDimensionsObject;
  35628. /**
  35629. * sets the object from which width and height will be taken from when getting render width and height
  35630. * Will fallback to the gl object
  35631. * @param dimensions the framebuffer width and height that will be used.
  35632. */
  35633. set framebufferDimensionsObject(dimensions: Nullable<{
  35634. framebufferWidth: number;
  35635. framebufferHeight: number;
  35636. }>);
  35637. /**
  35638. * Gets the current viewport
  35639. */
  35640. get currentViewport(): Nullable<IViewportLike>;
  35641. /**
  35642. * Gets the default empty texture
  35643. */
  35644. get emptyTexture(): InternalTexture;
  35645. /**
  35646. * Gets the default empty 3D texture
  35647. */
  35648. get emptyTexture3D(): InternalTexture;
  35649. /**
  35650. * Gets the default empty 2D array texture
  35651. */
  35652. get emptyTexture2DArray(): InternalTexture;
  35653. /**
  35654. * Gets the default empty cube texture
  35655. */
  35656. get emptyCubeTexture(): InternalTexture;
  35657. /**
  35658. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35659. */
  35660. readonly premultipliedAlpha: boolean;
  35661. /**
  35662. * Observable event triggered before each texture is initialized
  35663. */
  35664. onBeforeTextureInitObservable: Observable<Texture>;
  35665. /**
  35666. * Creates a new engine
  35667. * @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
  35668. * @param antialias defines enable antialiasing (default: false)
  35669. * @param options defines further options to be sent to the getContext() function
  35670. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35671. */
  35672. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35673. private _rebuildInternalTextures;
  35674. private _rebuildEffects;
  35675. /**
  35676. * Gets a boolean indicating if all created effects are ready
  35677. * @returns true if all effects are ready
  35678. */
  35679. areAllEffectsReady(): boolean;
  35680. protected _rebuildBuffers(): void;
  35681. protected _initGLContext(): void;
  35682. /**
  35683. * Gets version of the current webGL context
  35684. */
  35685. get webGLVersion(): number;
  35686. /**
  35687. * Gets a string identifying the name of the class
  35688. * @returns "Engine" string
  35689. */
  35690. getClassName(): string;
  35691. /**
  35692. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35693. */
  35694. get isStencilEnable(): boolean;
  35695. /** @hidden */
  35696. _prepareWorkingCanvas(): void;
  35697. /**
  35698. * Reset the texture cache to empty state
  35699. */
  35700. resetTextureCache(): void;
  35701. /**
  35702. * Gets an object containing information about the current webGL context
  35703. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35704. */
  35705. getGlInfo(): {
  35706. vendor: string;
  35707. renderer: string;
  35708. version: string;
  35709. };
  35710. /**
  35711. * Defines the hardware scaling level.
  35712. * By default the hardware scaling level is computed from the window device ratio.
  35713. * 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.
  35714. * @param level defines the level to use
  35715. */
  35716. setHardwareScalingLevel(level: number): void;
  35717. /**
  35718. * Gets the current hardware scaling level.
  35719. * By default the hardware scaling level is computed from the window device ratio.
  35720. * 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.
  35721. * @returns a number indicating the current hardware scaling level
  35722. */
  35723. getHardwareScalingLevel(): number;
  35724. /**
  35725. * Gets the list of loaded textures
  35726. * @returns an array containing all loaded textures
  35727. */
  35728. getLoadedTexturesCache(): InternalTexture[];
  35729. /**
  35730. * Gets the object containing all engine capabilities
  35731. * @returns the EngineCapabilities object
  35732. */
  35733. getCaps(): EngineCapabilities;
  35734. /**
  35735. * stop executing a render loop function and remove it from the execution array
  35736. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35737. */
  35738. stopRenderLoop(renderFunction?: () => void): void;
  35739. /** @hidden */
  35740. _renderLoop(): void;
  35741. /**
  35742. * Gets the HTML canvas attached with the current webGL context
  35743. * @returns a HTML canvas
  35744. */
  35745. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35746. /**
  35747. * Gets host window
  35748. * @returns the host window object
  35749. */
  35750. getHostWindow(): Nullable<Window>;
  35751. /**
  35752. * Gets the current render width
  35753. * @param useScreen defines if screen size must be used (or the current render target if any)
  35754. * @returns a number defining the current render width
  35755. */
  35756. getRenderWidth(useScreen?: boolean): number;
  35757. /**
  35758. * Gets the current render height
  35759. * @param useScreen defines if screen size must be used (or the current render target if any)
  35760. * @returns a number defining the current render height
  35761. */
  35762. getRenderHeight(useScreen?: boolean): number;
  35763. /**
  35764. * Can be used to override the current requestAnimationFrame requester.
  35765. * @hidden
  35766. */
  35767. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35768. /**
  35769. * Register and execute a render loop. The engine can have more than one render function
  35770. * @param renderFunction defines the function to continuously execute
  35771. */
  35772. runRenderLoop(renderFunction: () => void): void;
  35773. /**
  35774. * Clear the current render buffer or the current render target (if any is set up)
  35775. * @param color defines the color to use
  35776. * @param backBuffer defines if the back buffer must be cleared
  35777. * @param depth defines if the depth buffer must be cleared
  35778. * @param stencil defines if the stencil buffer must be cleared
  35779. */
  35780. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35781. private _viewportCached;
  35782. /** @hidden */
  35783. _viewport(x: number, y: number, width: number, height: number): void;
  35784. /**
  35785. * Set the WebGL's viewport
  35786. * @param viewport defines the viewport element to be used
  35787. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35788. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35789. */
  35790. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35791. /**
  35792. * Begin a new frame
  35793. */
  35794. beginFrame(): void;
  35795. /**
  35796. * Enf the current frame
  35797. */
  35798. endFrame(): void;
  35799. /**
  35800. * Resize the view according to the canvas' size
  35801. */
  35802. resize(): void;
  35803. /**
  35804. * Force a specific size of the canvas
  35805. * @param width defines the new canvas' width
  35806. * @param height defines the new canvas' height
  35807. * @returns true if the size was changed
  35808. */
  35809. setSize(width: number, height: number): boolean;
  35810. /**
  35811. * Binds the frame buffer to the specified texture.
  35812. * @param texture The texture to render to or null for the default canvas
  35813. * @param faceIndex The face of the texture to render to in case of cube texture
  35814. * @param requiredWidth The width of the target to render to
  35815. * @param requiredHeight The height of the target to render to
  35816. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35817. * @param lodLevel defines the lod level to bind to the frame buffer
  35818. * @param layer defines the 2d array index to bind to frame buffer to
  35819. */
  35820. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35821. /** @hidden */
  35822. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35823. /**
  35824. * Unbind the current render target texture from the webGL context
  35825. * @param texture defines the render target texture to unbind
  35826. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35827. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35828. */
  35829. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35830. /**
  35831. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35832. */
  35833. flushFramebuffer(): void;
  35834. /**
  35835. * Unbind the current render target and bind the default framebuffer
  35836. */
  35837. restoreDefaultFramebuffer(): void;
  35838. /** @hidden */
  35839. protected _resetVertexBufferBinding(): void;
  35840. /**
  35841. * Creates a vertex buffer
  35842. * @param data the data for the vertex buffer
  35843. * @returns the new WebGL static buffer
  35844. */
  35845. createVertexBuffer(data: DataArray): DataBuffer;
  35846. private _createVertexBuffer;
  35847. /**
  35848. * Creates a dynamic vertex buffer
  35849. * @param data the data for the dynamic vertex buffer
  35850. * @returns the new WebGL dynamic buffer
  35851. */
  35852. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35853. protected _resetIndexBufferBinding(): void;
  35854. /**
  35855. * Creates a new index buffer
  35856. * @param indices defines the content of the index buffer
  35857. * @param updatable defines if the index buffer must be updatable
  35858. * @returns a new webGL buffer
  35859. */
  35860. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35861. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35862. /**
  35863. * Bind a webGL buffer to the webGL context
  35864. * @param buffer defines the buffer to bind
  35865. */
  35866. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35867. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35868. private bindBuffer;
  35869. /**
  35870. * update the bound buffer with the given data
  35871. * @param data defines the data to update
  35872. */
  35873. updateArrayBuffer(data: Float32Array): void;
  35874. private _vertexAttribPointer;
  35875. /** @hidden */
  35876. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35877. private _bindVertexBuffersAttributes;
  35878. /**
  35879. * Records a vertex array object
  35880. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35881. * @param vertexBuffers defines the list of vertex buffers to store
  35882. * @param indexBuffer defines the index buffer to store
  35883. * @param effect defines the effect to store
  35884. * @returns the new vertex array object
  35885. */
  35886. recordVertexArrayObject(vertexBuffers: {
  35887. [key: string]: VertexBuffer;
  35888. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35889. /**
  35890. * Bind a specific vertex array object
  35891. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35892. * @param vertexArrayObject defines the vertex array object to bind
  35893. * @param indexBuffer defines the index buffer to bind
  35894. */
  35895. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35896. /**
  35897. * Bind webGl buffers directly to the webGL context
  35898. * @param vertexBuffer defines the vertex buffer to bind
  35899. * @param indexBuffer defines the index buffer to bind
  35900. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35901. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35902. * @param effect defines the effect associated with the vertex buffer
  35903. */
  35904. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35905. private _unbindVertexArrayObject;
  35906. /**
  35907. * Bind a list of vertex buffers to the webGL context
  35908. * @param vertexBuffers defines the list of vertex buffers to bind
  35909. * @param indexBuffer defines the index buffer to bind
  35910. * @param effect defines the effect associated with the vertex buffers
  35911. */
  35912. bindBuffers(vertexBuffers: {
  35913. [key: string]: Nullable<VertexBuffer>;
  35914. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35915. /**
  35916. * Unbind all instance attributes
  35917. */
  35918. unbindInstanceAttributes(): void;
  35919. /**
  35920. * Release and free the memory of a vertex array object
  35921. * @param vao defines the vertex array object to delete
  35922. */
  35923. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35924. /** @hidden */
  35925. _releaseBuffer(buffer: DataBuffer): boolean;
  35926. protected _deleteBuffer(buffer: DataBuffer): void;
  35927. /**
  35928. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35929. * @param instancesBuffer defines the webGL buffer to update and bind
  35930. * @param data defines the data to store in the buffer
  35931. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35932. */
  35933. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35934. /**
  35935. * Bind the content of a webGL buffer used with instantiation
  35936. * @param instancesBuffer defines the webGL buffer to bind
  35937. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35938. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35939. */
  35940. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35941. /**
  35942. * Disable the instance attribute corresponding to the name in parameter
  35943. * @param name defines the name of the attribute to disable
  35944. */
  35945. disableInstanceAttributeByName(name: string): void;
  35946. /**
  35947. * Disable the instance attribute corresponding to the location in parameter
  35948. * @param attributeLocation defines the attribute location of the attribute to disable
  35949. */
  35950. disableInstanceAttribute(attributeLocation: number): void;
  35951. /**
  35952. * Disable the attribute corresponding to the location in parameter
  35953. * @param attributeLocation defines the attribute location of the attribute to disable
  35954. */
  35955. disableAttributeByIndex(attributeLocation: number): void;
  35956. /**
  35957. * Send a draw order
  35958. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35959. * @param indexStart defines the starting index
  35960. * @param indexCount defines the number of index to draw
  35961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35962. */
  35963. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35964. /**
  35965. * Draw a list of points
  35966. * @param verticesStart defines the index of first vertex to draw
  35967. * @param verticesCount defines the count of vertices to draw
  35968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35969. */
  35970. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35971. /**
  35972. * Draw a list of unindexed primitives
  35973. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35974. * @param verticesStart defines the index of first vertex to draw
  35975. * @param verticesCount defines the count of vertices to draw
  35976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35977. */
  35978. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35979. /**
  35980. * Draw a list of indexed primitives
  35981. * @param fillMode defines the primitive to use
  35982. * @param indexStart defines the starting index
  35983. * @param indexCount defines the number of index to draw
  35984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35985. */
  35986. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35987. /**
  35988. * Draw a list of unindexed primitives
  35989. * @param fillMode defines the primitive to use
  35990. * @param verticesStart defines the index of first vertex to draw
  35991. * @param verticesCount defines the count of vertices to draw
  35992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35993. */
  35994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35995. private _drawMode;
  35996. /** @hidden */
  35997. protected _reportDrawCall(): void;
  35998. /** @hidden */
  35999. _releaseEffect(effect: Effect): void;
  36000. /** @hidden */
  36001. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36002. /**
  36003. * Create a new effect (used to store vertex/fragment shaders)
  36004. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36005. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36006. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36007. * @param samplers defines an array of string used to represent textures
  36008. * @param defines defines the string containing the defines to use to compile the shaders
  36009. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36010. * @param onCompiled defines a function to call when the effect creation is successful
  36011. * @param onError defines a function to call when the effect creation has failed
  36012. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36013. * @returns the new Effect
  36014. */
  36015. 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;
  36016. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36017. private _compileShader;
  36018. private _compileRawShader;
  36019. /** @hidden */
  36020. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36021. /**
  36022. * Directly creates a webGL program
  36023. * @param pipelineContext defines the pipeline context to attach to
  36024. * @param vertexCode defines the vertex shader code to use
  36025. * @param fragmentCode defines the fragment shader code to use
  36026. * @param context defines the webGL context to use (if not set, the current one will be used)
  36027. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36028. * @returns the new webGL program
  36029. */
  36030. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36031. /**
  36032. * Creates a webGL program
  36033. * @param pipelineContext defines the pipeline context to attach to
  36034. * @param vertexCode defines the vertex shader code to use
  36035. * @param fragmentCode defines the fragment shader code to use
  36036. * @param defines defines the string containing the defines to use to compile the shaders
  36037. * @param context defines the webGL context to use (if not set, the current one will be used)
  36038. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36039. * @returns the new webGL program
  36040. */
  36041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36042. /**
  36043. * Creates a new pipeline context
  36044. * @returns the new pipeline
  36045. */
  36046. createPipelineContext(): IPipelineContext;
  36047. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36048. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36049. /** @hidden */
  36050. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36051. /** @hidden */
  36052. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36053. /** @hidden */
  36054. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36055. /**
  36056. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36057. * @param pipelineContext defines the pipeline context to use
  36058. * @param uniformsNames defines the list of uniform names
  36059. * @returns an array of webGL uniform locations
  36060. */
  36061. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36062. /**
  36063. * Gets the lsit of active attributes for a given webGL program
  36064. * @param pipelineContext defines the pipeline context to use
  36065. * @param attributesNames defines the list of attribute names to get
  36066. * @returns an array of indices indicating the offset of each attribute
  36067. */
  36068. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36069. /**
  36070. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36071. * @param effect defines the effect to activate
  36072. */
  36073. enableEffect(effect: Nullable<Effect>): void;
  36074. /**
  36075. * Set the value of an uniform to a number (int)
  36076. * @param uniform defines the webGL uniform location where to store the value
  36077. * @param value defines the int number to store
  36078. */
  36079. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36080. /**
  36081. * Set the value of an uniform to an array of int32
  36082. * @param uniform defines the webGL uniform location where to store the value
  36083. * @param array defines the array of int32 to store
  36084. */
  36085. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36086. /**
  36087. * Set the value of an uniform to an array of int32 (stored as vec2)
  36088. * @param uniform defines the webGL uniform location where to store the value
  36089. * @param array defines the array of int32 to store
  36090. */
  36091. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36092. /**
  36093. * Set the value of an uniform to an array of int32 (stored as vec3)
  36094. * @param uniform defines the webGL uniform location where to store the value
  36095. * @param array defines the array of int32 to store
  36096. */
  36097. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36098. /**
  36099. * Set the value of an uniform to an array of int32 (stored as vec4)
  36100. * @param uniform defines the webGL uniform location where to store the value
  36101. * @param array defines the array of int32 to store
  36102. */
  36103. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36104. /**
  36105. * Set the value of an uniform to an array of number
  36106. * @param uniform defines the webGL uniform location where to store the value
  36107. * @param array defines the array of number to store
  36108. */
  36109. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36110. /**
  36111. * Set the value of an uniform to an array of number (stored as vec2)
  36112. * @param uniform defines the webGL uniform location where to store the value
  36113. * @param array defines the array of number to store
  36114. */
  36115. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36116. /**
  36117. * Set the value of an uniform to an array of number (stored as vec3)
  36118. * @param uniform defines the webGL uniform location where to store the value
  36119. * @param array defines the array of number to store
  36120. */
  36121. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36122. /**
  36123. * Set the value of an uniform to an array of number (stored as vec4)
  36124. * @param uniform defines the webGL uniform location where to store the value
  36125. * @param array defines the array of number to store
  36126. */
  36127. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36128. /**
  36129. * Set the value of an uniform to an array of float32 (stored as matrices)
  36130. * @param uniform defines the webGL uniform location where to store the value
  36131. * @param matrices defines the array of float32 to store
  36132. */
  36133. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36134. /**
  36135. * Set the value of an uniform to a matrix (3x3)
  36136. * @param uniform defines the webGL uniform location where to store the value
  36137. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36138. */
  36139. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36140. /**
  36141. * Set the value of an uniform to a matrix (2x2)
  36142. * @param uniform defines the webGL uniform location where to store the value
  36143. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36144. */
  36145. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36146. /**
  36147. * Set the value of an uniform to a number (float)
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param value defines the float number to store
  36150. */
  36151. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36152. /**
  36153. * Set the value of an uniform to a vec2
  36154. * @param uniform defines the webGL uniform location where to store the value
  36155. * @param x defines the 1st component of the value
  36156. * @param y defines the 2nd component of the value
  36157. */
  36158. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36159. /**
  36160. * Set the value of an uniform to a vec3
  36161. * @param uniform defines the webGL uniform location where to store the value
  36162. * @param x defines the 1st component of the value
  36163. * @param y defines the 2nd component of the value
  36164. * @param z defines the 3rd component of the value
  36165. */
  36166. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36167. /**
  36168. * Set the value of an uniform to a vec4
  36169. * @param uniform defines the webGL uniform location where to store the value
  36170. * @param x defines the 1st component of the value
  36171. * @param y defines the 2nd component of the value
  36172. * @param z defines the 3rd component of the value
  36173. * @param w defines the 4th component of the value
  36174. */
  36175. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36176. /**
  36177. * Apply all cached states (depth, culling, stencil and alpha)
  36178. */
  36179. applyStates(): void;
  36180. /**
  36181. * Enable or disable color writing
  36182. * @param enable defines the state to set
  36183. */
  36184. setColorWrite(enable: boolean): void;
  36185. /**
  36186. * Gets a boolean indicating if color writing is enabled
  36187. * @returns the current color writing state
  36188. */
  36189. getColorWrite(): boolean;
  36190. /**
  36191. * Gets the depth culling state manager
  36192. */
  36193. get depthCullingState(): DepthCullingState;
  36194. /**
  36195. * Gets the alpha state manager
  36196. */
  36197. get alphaState(): AlphaState;
  36198. /**
  36199. * Gets the stencil state manager
  36200. */
  36201. get stencilState(): StencilState;
  36202. /**
  36203. * Clears the list of texture accessible through engine.
  36204. * This can help preventing texture load conflict due to name collision.
  36205. */
  36206. clearInternalTexturesCache(): void;
  36207. /**
  36208. * Force the entire cache to be cleared
  36209. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36210. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36211. */
  36212. wipeCaches(bruteForce?: boolean): void;
  36213. /** @hidden */
  36214. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36215. min: number;
  36216. mag: number;
  36217. };
  36218. /** @hidden */
  36219. _createTexture(): WebGLTexture;
  36220. /**
  36221. * Usually called from Texture.ts.
  36222. * Passed information to create a WebGLTexture
  36223. * @param url defines a value which contains one of the following:
  36224. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36225. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36226. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36227. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36228. * @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)
  36229. * @param scene needed for loading to the correct scene
  36230. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36231. * @param onLoad optional callback to be called upon successful completion
  36232. * @param onError optional callback to be called upon failure
  36233. * @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
  36234. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36235. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36236. * @param forcedExtension defines the extension to use to pick the right loader
  36237. * @param mimeType defines an optional mime type
  36238. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36239. */
  36240. 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;
  36241. /**
  36242. * Loads an image as an HTMLImageElement.
  36243. * @param input url string, ArrayBuffer, or Blob to load
  36244. * @param onLoad callback called when the image successfully loads
  36245. * @param onError callback called when the image fails to load
  36246. * @param offlineProvider offline provider for caching
  36247. * @param mimeType optional mime type
  36248. * @returns the HTMLImageElement of the loaded image
  36249. * @hidden
  36250. */
  36251. 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>;
  36252. /**
  36253. * @hidden
  36254. */
  36255. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36256. private _unpackFlipYCached;
  36257. /**
  36258. * In case you are sharing the context with other applications, it might
  36259. * be interested to not cache the unpack flip y state to ensure a consistent
  36260. * value would be set.
  36261. */
  36262. enableUnpackFlipYCached: boolean;
  36263. /** @hidden */
  36264. _unpackFlipY(value: boolean): void;
  36265. /** @hidden */
  36266. _getUnpackAlignement(): number;
  36267. private _getTextureTarget;
  36268. /**
  36269. * Update the sampling mode of a given texture
  36270. * @param samplingMode defines the required sampling mode
  36271. * @param texture defines the texture to update
  36272. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36273. */
  36274. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36275. /**
  36276. * Update the sampling mode of a given texture
  36277. * @param texture defines the texture to update
  36278. * @param wrapU defines the texture wrap mode of the u coordinates
  36279. * @param wrapV defines the texture wrap mode of the v coordinates
  36280. * @param wrapR defines the texture wrap mode of the r coordinates
  36281. */
  36282. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36283. /** @hidden */
  36284. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36285. width: number;
  36286. height: number;
  36287. layers?: number;
  36288. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36289. /** @hidden */
  36290. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36291. /** @hidden */
  36292. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36293. /**
  36294. * Update a portion of an internal texture
  36295. * @param texture defines the texture to update
  36296. * @param imageData defines the data to store into the texture
  36297. * @param xOffset defines the x coordinates of the update rectangle
  36298. * @param yOffset defines the y coordinates of the update rectangle
  36299. * @param width defines the width of the update rectangle
  36300. * @param height defines the height of the update rectangle
  36301. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36302. * @param lod defines the lod level to update (0 by default)
  36303. */
  36304. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36305. /** @hidden */
  36306. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36307. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36308. private _prepareWebGLTexture;
  36309. /** @hidden */
  36310. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36311. private _getDepthStencilBuffer;
  36312. /** @hidden */
  36313. _releaseFramebufferObjects(texture: InternalTexture): void;
  36314. /** @hidden */
  36315. _releaseTexture(texture: InternalTexture): void;
  36316. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36317. protected _setProgram(program: WebGLProgram): void;
  36318. protected _boundUniforms: {
  36319. [key: number]: WebGLUniformLocation;
  36320. };
  36321. /**
  36322. * Binds an effect to the webGL context
  36323. * @param effect defines the effect to bind
  36324. */
  36325. bindSamplers(effect: Effect): void;
  36326. private _activateCurrentTexture;
  36327. /** @hidden */
  36328. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36329. /** @hidden */
  36330. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36331. /**
  36332. * Unbind all textures from the webGL context
  36333. */
  36334. unbindAllTextures(): void;
  36335. /**
  36336. * Sets a texture to the according uniform.
  36337. * @param channel The texture channel
  36338. * @param uniform The uniform to set
  36339. * @param texture The texture to apply
  36340. */
  36341. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36342. private _bindSamplerUniformToChannel;
  36343. private _getTextureWrapMode;
  36344. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36345. /**
  36346. * Sets an array of texture to the webGL context
  36347. * @param channel defines the channel where the texture array must be set
  36348. * @param uniform defines the associated uniform location
  36349. * @param textures defines the array of textures to bind
  36350. */
  36351. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36352. /** @hidden */
  36353. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36354. private _setTextureParameterFloat;
  36355. private _setTextureParameterInteger;
  36356. /**
  36357. * Unbind all vertex attributes from the webGL context
  36358. */
  36359. unbindAllAttributes(): void;
  36360. /**
  36361. * 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
  36362. */
  36363. releaseEffects(): void;
  36364. /**
  36365. * Dispose and release all associated resources
  36366. */
  36367. dispose(): void;
  36368. /**
  36369. * Attach a new callback raised when context lost event is fired
  36370. * @param callback defines the callback to call
  36371. */
  36372. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36373. /**
  36374. * Attach a new callback raised when context restored event is fired
  36375. * @param callback defines the callback to call
  36376. */
  36377. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36378. /**
  36379. * Get the current error code of the webGL context
  36380. * @returns the error code
  36381. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36382. */
  36383. getError(): number;
  36384. private _canRenderToFloatFramebuffer;
  36385. private _canRenderToHalfFloatFramebuffer;
  36386. private _canRenderToFramebuffer;
  36387. /** @hidden */
  36388. _getWebGLTextureType(type: number): number;
  36389. /** @hidden */
  36390. _getInternalFormat(format: number): number;
  36391. /** @hidden */
  36392. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36393. /** @hidden */
  36394. _getRGBAMultiSampleBufferFormat(type: number): number;
  36395. /** @hidden */
  36396. _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;
  36397. /**
  36398. * Loads a file from a url
  36399. * @param url url to load
  36400. * @param onSuccess callback called when the file successfully loads
  36401. * @param onProgress callback called while file is loading (if the server supports this mode)
  36402. * @param offlineProvider defines the offline provider for caching
  36403. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36404. * @param onError callback called when the file fails to load
  36405. * @returns a file request object
  36406. * @hidden
  36407. */
  36408. 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;
  36409. /**
  36410. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36411. * @param x defines the x coordinate of the rectangle where pixels must be read
  36412. * @param y defines the y coordinate of the rectangle where pixels must be read
  36413. * @param width defines the width of the rectangle where pixels must be read
  36414. * @param height defines the height of the rectangle where pixels must be read
  36415. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36416. * @returns a Uint8Array containing RGBA colors
  36417. */
  36418. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36419. private static _isSupported;
  36420. /**
  36421. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36422. * @returns true if the engine can be created
  36423. * @ignorenaming
  36424. */
  36425. static isSupported(): boolean;
  36426. /**
  36427. * Find the next highest power of two.
  36428. * @param x Number to start search from.
  36429. * @return Next highest power of two.
  36430. */
  36431. static CeilingPOT(x: number): number;
  36432. /**
  36433. * Find the next lowest power of two.
  36434. * @param x Number to start search from.
  36435. * @return Next lowest power of two.
  36436. */
  36437. static FloorPOT(x: number): number;
  36438. /**
  36439. * Find the nearest power of two.
  36440. * @param x Number to start search from.
  36441. * @return Next nearest power of two.
  36442. */
  36443. static NearestPOT(x: number): number;
  36444. /**
  36445. * Get the closest exponent of two
  36446. * @param value defines the value to approximate
  36447. * @param max defines the maximum value to return
  36448. * @param mode defines how to define the closest value
  36449. * @returns closest exponent of two of the given value
  36450. */
  36451. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36452. /**
  36453. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36454. * @param func - the function to be called
  36455. * @param requester - the object that will request the next frame. Falls back to window.
  36456. * @returns frame number
  36457. */
  36458. static QueueNewFrame(func: () => void, requester?: any): number;
  36459. /**
  36460. * Gets host document
  36461. * @returns the host document object
  36462. */
  36463. getHostDocument(): Nullable<Document>;
  36464. }
  36465. }
  36466. declare module BABYLON {
  36467. /**
  36468. * Class representing spherical harmonics coefficients to the 3rd degree
  36469. */
  36470. export class SphericalHarmonics {
  36471. /**
  36472. * Defines whether or not the harmonics have been prescaled for rendering.
  36473. */
  36474. preScaled: boolean;
  36475. /**
  36476. * The l0,0 coefficients of the spherical harmonics
  36477. */
  36478. l00: Vector3;
  36479. /**
  36480. * The l1,-1 coefficients of the spherical harmonics
  36481. */
  36482. l1_1: Vector3;
  36483. /**
  36484. * The l1,0 coefficients of the spherical harmonics
  36485. */
  36486. l10: Vector3;
  36487. /**
  36488. * The l1,1 coefficients of the spherical harmonics
  36489. */
  36490. l11: Vector3;
  36491. /**
  36492. * The l2,-2 coefficients of the spherical harmonics
  36493. */
  36494. l2_2: Vector3;
  36495. /**
  36496. * The l2,-1 coefficients of the spherical harmonics
  36497. */
  36498. l2_1: Vector3;
  36499. /**
  36500. * The l2,0 coefficients of the spherical harmonics
  36501. */
  36502. l20: Vector3;
  36503. /**
  36504. * The l2,1 coefficients of the spherical harmonics
  36505. */
  36506. l21: Vector3;
  36507. /**
  36508. * The l2,2 coefficients of the spherical harmonics
  36509. */
  36510. l22: Vector3;
  36511. /**
  36512. * Adds a light to the spherical harmonics
  36513. * @param direction the direction of the light
  36514. * @param color the color of the light
  36515. * @param deltaSolidAngle the delta solid angle of the light
  36516. */
  36517. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36518. /**
  36519. * Scales the spherical harmonics by the given amount
  36520. * @param scale the amount to scale
  36521. */
  36522. scaleInPlace(scale: number): void;
  36523. /**
  36524. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36525. *
  36526. * ```
  36527. * E_lm = A_l * L_lm
  36528. * ```
  36529. *
  36530. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36531. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36532. * the scaling factors are given in equation 9.
  36533. */
  36534. convertIncidentRadianceToIrradiance(): void;
  36535. /**
  36536. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36537. *
  36538. * ```
  36539. * L = (1/pi) * E * rho
  36540. * ```
  36541. *
  36542. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36543. */
  36544. convertIrradianceToLambertianRadiance(): void;
  36545. /**
  36546. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36547. * required operations at run time.
  36548. *
  36549. * This is simply done by scaling back the SH with Ylm constants parameter.
  36550. * The trigonometric part being applied by the shader at run time.
  36551. */
  36552. preScaleForRendering(): void;
  36553. /**
  36554. * Constructs a spherical harmonics from an array.
  36555. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36556. * @returns the spherical harmonics
  36557. */
  36558. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36559. /**
  36560. * Gets the spherical harmonics from polynomial
  36561. * @param polynomial the spherical polynomial
  36562. * @returns the spherical harmonics
  36563. */
  36564. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36565. }
  36566. /**
  36567. * Class representing spherical polynomial coefficients to the 3rd degree
  36568. */
  36569. export class SphericalPolynomial {
  36570. private _harmonics;
  36571. /**
  36572. * The spherical harmonics used to create the polynomials.
  36573. */
  36574. get preScaledHarmonics(): SphericalHarmonics;
  36575. /**
  36576. * The x coefficients of the spherical polynomial
  36577. */
  36578. x: Vector3;
  36579. /**
  36580. * The y coefficients of the spherical polynomial
  36581. */
  36582. y: Vector3;
  36583. /**
  36584. * The z coefficients of the spherical polynomial
  36585. */
  36586. z: Vector3;
  36587. /**
  36588. * The xx coefficients of the spherical polynomial
  36589. */
  36590. xx: Vector3;
  36591. /**
  36592. * The yy coefficients of the spherical polynomial
  36593. */
  36594. yy: Vector3;
  36595. /**
  36596. * The zz coefficients of the spherical polynomial
  36597. */
  36598. zz: Vector3;
  36599. /**
  36600. * The xy coefficients of the spherical polynomial
  36601. */
  36602. xy: Vector3;
  36603. /**
  36604. * The yz coefficients of the spherical polynomial
  36605. */
  36606. yz: Vector3;
  36607. /**
  36608. * The zx coefficients of the spherical polynomial
  36609. */
  36610. zx: Vector3;
  36611. /**
  36612. * Adds an ambient color to the spherical polynomial
  36613. * @param color the color to add
  36614. */
  36615. addAmbient(color: Color3): void;
  36616. /**
  36617. * Scales the spherical polynomial by the given amount
  36618. * @param scale the amount to scale
  36619. */
  36620. scaleInPlace(scale: number): void;
  36621. /**
  36622. * Gets the spherical polynomial from harmonics
  36623. * @param harmonics the spherical harmonics
  36624. * @returns the spherical polynomial
  36625. */
  36626. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36627. /**
  36628. * Constructs a spherical polynomial from an array.
  36629. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36630. * @returns the spherical polynomial
  36631. */
  36632. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36633. }
  36634. }
  36635. declare module BABYLON {
  36636. /**
  36637. * Defines the source of the internal texture
  36638. */
  36639. export enum InternalTextureSource {
  36640. /**
  36641. * The source of the texture data is unknown
  36642. */
  36643. Unknown = 0,
  36644. /**
  36645. * Texture data comes from an URL
  36646. */
  36647. Url = 1,
  36648. /**
  36649. * Texture data is only used for temporary storage
  36650. */
  36651. Temp = 2,
  36652. /**
  36653. * Texture data comes from raw data (ArrayBuffer)
  36654. */
  36655. Raw = 3,
  36656. /**
  36657. * Texture content is dynamic (video or dynamic texture)
  36658. */
  36659. Dynamic = 4,
  36660. /**
  36661. * Texture content is generated by rendering to it
  36662. */
  36663. RenderTarget = 5,
  36664. /**
  36665. * Texture content is part of a multi render target process
  36666. */
  36667. MultiRenderTarget = 6,
  36668. /**
  36669. * Texture data comes from a cube data file
  36670. */
  36671. Cube = 7,
  36672. /**
  36673. * Texture data comes from a raw cube data
  36674. */
  36675. CubeRaw = 8,
  36676. /**
  36677. * Texture data come from a prefiltered cube data file
  36678. */
  36679. CubePrefiltered = 9,
  36680. /**
  36681. * Texture content is raw 3D data
  36682. */
  36683. Raw3D = 10,
  36684. /**
  36685. * Texture content is raw 2D array data
  36686. */
  36687. Raw2DArray = 11,
  36688. /**
  36689. * Texture content is a depth texture
  36690. */
  36691. Depth = 12,
  36692. /**
  36693. * Texture data comes from a raw cube data encoded with RGBD
  36694. */
  36695. CubeRawRGBD = 13
  36696. }
  36697. /**
  36698. * Class used to store data associated with WebGL texture data for the engine
  36699. * This class should not be used directly
  36700. */
  36701. export class InternalTexture {
  36702. /** @hidden */
  36703. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36704. /**
  36705. * Defines if the texture is ready
  36706. */
  36707. isReady: boolean;
  36708. /**
  36709. * Defines if the texture is a cube texture
  36710. */
  36711. isCube: boolean;
  36712. /**
  36713. * Defines if the texture contains 3D data
  36714. */
  36715. is3D: boolean;
  36716. /**
  36717. * Defines if the texture contains 2D array data
  36718. */
  36719. is2DArray: boolean;
  36720. /**
  36721. * Defines if the texture contains multiview data
  36722. */
  36723. isMultiview: boolean;
  36724. /**
  36725. * Gets the URL used to load this texture
  36726. */
  36727. url: string;
  36728. /**
  36729. * Gets the sampling mode of the texture
  36730. */
  36731. samplingMode: number;
  36732. /**
  36733. * Gets a boolean indicating if the texture needs mipmaps generation
  36734. */
  36735. generateMipMaps: boolean;
  36736. /**
  36737. * Gets the number of samples used by the texture (WebGL2+ only)
  36738. */
  36739. samples: number;
  36740. /**
  36741. * Gets the type of the texture (int, float...)
  36742. */
  36743. type: number;
  36744. /**
  36745. * Gets the format of the texture (RGB, RGBA...)
  36746. */
  36747. format: number;
  36748. /**
  36749. * Observable called when the texture is loaded
  36750. */
  36751. onLoadedObservable: Observable<InternalTexture>;
  36752. /**
  36753. * Gets the width of the texture
  36754. */
  36755. width: number;
  36756. /**
  36757. * Gets the height of the texture
  36758. */
  36759. height: number;
  36760. /**
  36761. * Gets the depth of the texture
  36762. */
  36763. depth: number;
  36764. /**
  36765. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36766. */
  36767. baseWidth: number;
  36768. /**
  36769. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36770. */
  36771. baseHeight: number;
  36772. /**
  36773. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36774. */
  36775. baseDepth: number;
  36776. /**
  36777. * Gets a boolean indicating if the texture is inverted on Y axis
  36778. */
  36779. invertY: boolean;
  36780. /** @hidden */
  36781. _invertVScale: boolean;
  36782. /** @hidden */
  36783. _associatedChannel: number;
  36784. /** @hidden */
  36785. _source: InternalTextureSource;
  36786. /** @hidden */
  36787. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36788. /** @hidden */
  36789. _bufferView: Nullable<ArrayBufferView>;
  36790. /** @hidden */
  36791. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36792. /** @hidden */
  36793. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36794. /** @hidden */
  36795. _size: number;
  36796. /** @hidden */
  36797. _extension: string;
  36798. /** @hidden */
  36799. _files: Nullable<string[]>;
  36800. /** @hidden */
  36801. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36802. /** @hidden */
  36803. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36804. /** @hidden */
  36805. _framebuffer: Nullable<WebGLFramebuffer>;
  36806. /** @hidden */
  36807. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36808. /** @hidden */
  36809. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36810. /** @hidden */
  36811. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36812. /** @hidden */
  36813. _attachments: Nullable<number[]>;
  36814. /** @hidden */
  36815. _textureArray: Nullable<InternalTexture[]>;
  36816. /** @hidden */
  36817. _cachedCoordinatesMode: Nullable<number>;
  36818. /** @hidden */
  36819. _cachedWrapU: Nullable<number>;
  36820. /** @hidden */
  36821. _cachedWrapV: Nullable<number>;
  36822. /** @hidden */
  36823. _cachedWrapR: Nullable<number>;
  36824. /** @hidden */
  36825. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36826. /** @hidden */
  36827. _isDisabled: boolean;
  36828. /** @hidden */
  36829. _compression: Nullable<string>;
  36830. /** @hidden */
  36831. _generateStencilBuffer: boolean;
  36832. /** @hidden */
  36833. _generateDepthBuffer: boolean;
  36834. /** @hidden */
  36835. _comparisonFunction: number;
  36836. /** @hidden */
  36837. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36838. /** @hidden */
  36839. _lodGenerationScale: number;
  36840. /** @hidden */
  36841. _lodGenerationOffset: number;
  36842. /** @hidden */
  36843. _depthStencilTexture: Nullable<InternalTexture>;
  36844. /** @hidden */
  36845. _colorTextureArray: Nullable<WebGLTexture>;
  36846. /** @hidden */
  36847. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36848. /** @hidden */
  36849. _lodTextureHigh: Nullable<BaseTexture>;
  36850. /** @hidden */
  36851. _lodTextureMid: Nullable<BaseTexture>;
  36852. /** @hidden */
  36853. _lodTextureLow: Nullable<BaseTexture>;
  36854. /** @hidden */
  36855. _isRGBD: boolean;
  36856. /** @hidden */
  36857. _linearSpecularLOD: boolean;
  36858. /** @hidden */
  36859. _irradianceTexture: Nullable<BaseTexture>;
  36860. /** @hidden */
  36861. _webGLTexture: Nullable<WebGLTexture>;
  36862. /** @hidden */
  36863. _references: number;
  36864. /** @hidden */
  36865. _gammaSpace: Nullable<boolean>;
  36866. private _engine;
  36867. /**
  36868. * Gets the Engine the texture belongs to.
  36869. * @returns The babylon engine
  36870. */
  36871. getEngine(): ThinEngine;
  36872. /**
  36873. * Gets the data source type of the texture
  36874. */
  36875. get source(): InternalTextureSource;
  36876. /**
  36877. * Creates a new InternalTexture
  36878. * @param engine defines the engine to use
  36879. * @param source defines the type of data that will be used
  36880. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36881. */
  36882. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36883. /**
  36884. * Increments the number of references (ie. the number of Texture that point to it)
  36885. */
  36886. incrementReferences(): void;
  36887. /**
  36888. * Change the size of the texture (not the size of the content)
  36889. * @param width defines the new width
  36890. * @param height defines the new height
  36891. * @param depth defines the new depth (1 by default)
  36892. */
  36893. updateSize(width: int, height: int, depth?: int): void;
  36894. /** @hidden */
  36895. _rebuild(): void;
  36896. /** @hidden */
  36897. _swapAndDie(target: InternalTexture): void;
  36898. /**
  36899. * Dispose the current allocated resources
  36900. */
  36901. dispose(): void;
  36902. }
  36903. }
  36904. declare module BABYLON {
  36905. /**
  36906. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36908. */
  36909. export class Analyser {
  36910. /**
  36911. * Gets or sets the smoothing
  36912. * @ignorenaming
  36913. */
  36914. SMOOTHING: number;
  36915. /**
  36916. * Gets or sets the FFT table size
  36917. * @ignorenaming
  36918. */
  36919. FFT_SIZE: number;
  36920. /**
  36921. * Gets or sets the bar graph amplitude
  36922. * @ignorenaming
  36923. */
  36924. BARGRAPHAMPLITUDE: number;
  36925. /**
  36926. * Gets or sets the position of the debug canvas
  36927. * @ignorenaming
  36928. */
  36929. DEBUGCANVASPOS: {
  36930. x: number;
  36931. y: number;
  36932. };
  36933. /**
  36934. * Gets or sets the debug canvas size
  36935. * @ignorenaming
  36936. */
  36937. DEBUGCANVASSIZE: {
  36938. width: number;
  36939. height: number;
  36940. };
  36941. private _byteFreqs;
  36942. private _byteTime;
  36943. private _floatFreqs;
  36944. private _webAudioAnalyser;
  36945. private _debugCanvas;
  36946. private _debugCanvasContext;
  36947. private _scene;
  36948. private _registerFunc;
  36949. private _audioEngine;
  36950. /**
  36951. * Creates a new analyser
  36952. * @param scene defines hosting scene
  36953. */
  36954. constructor(scene: Scene);
  36955. /**
  36956. * Get the number of data values you will have to play with for the visualization
  36957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36958. * @returns a number
  36959. */
  36960. getFrequencyBinCount(): number;
  36961. /**
  36962. * Gets the current frequency data as a byte array
  36963. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36964. * @returns a Uint8Array
  36965. */
  36966. getByteFrequencyData(): Uint8Array;
  36967. /**
  36968. * Gets the current waveform as a byte array
  36969. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36970. * @returns a Uint8Array
  36971. */
  36972. getByteTimeDomainData(): Uint8Array;
  36973. /**
  36974. * Gets the current frequency data as a float array
  36975. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36976. * @returns a Float32Array
  36977. */
  36978. getFloatFrequencyData(): Float32Array;
  36979. /**
  36980. * Renders the debug canvas
  36981. */
  36982. drawDebugCanvas(): void;
  36983. /**
  36984. * Stops rendering the debug canvas and removes it
  36985. */
  36986. stopDebugCanvas(): void;
  36987. /**
  36988. * Connects two audio nodes
  36989. * @param inputAudioNode defines first node to connect
  36990. * @param outputAudioNode defines second node to connect
  36991. */
  36992. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36993. /**
  36994. * Releases all associated resources
  36995. */
  36996. dispose(): void;
  36997. }
  36998. }
  36999. declare module BABYLON {
  37000. /**
  37001. * This represents an audio engine and it is responsible
  37002. * to play, synchronize and analyse sounds throughout the application.
  37003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37004. */
  37005. export interface IAudioEngine extends IDisposable {
  37006. /**
  37007. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37008. */
  37009. readonly canUseWebAudio: boolean;
  37010. /**
  37011. * Gets the current AudioContext if available.
  37012. */
  37013. readonly audioContext: Nullable<AudioContext>;
  37014. /**
  37015. * The master gain node defines the global audio volume of your audio engine.
  37016. */
  37017. readonly masterGain: GainNode;
  37018. /**
  37019. * Gets whether or not mp3 are supported by your browser.
  37020. */
  37021. readonly isMP3supported: boolean;
  37022. /**
  37023. * Gets whether or not ogg are supported by your browser.
  37024. */
  37025. readonly isOGGsupported: boolean;
  37026. /**
  37027. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37028. * @ignoreNaming
  37029. */
  37030. WarnedWebAudioUnsupported: boolean;
  37031. /**
  37032. * Defines if the audio engine relies on a custom unlocked button.
  37033. * In this case, the embedded button will not be displayed.
  37034. */
  37035. useCustomUnlockedButton: boolean;
  37036. /**
  37037. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37038. */
  37039. readonly unlocked: boolean;
  37040. /**
  37041. * Event raised when audio has been unlocked on the browser.
  37042. */
  37043. onAudioUnlockedObservable: Observable<AudioEngine>;
  37044. /**
  37045. * Event raised when audio has been locked on the browser.
  37046. */
  37047. onAudioLockedObservable: Observable<AudioEngine>;
  37048. /**
  37049. * Flags the audio engine in Locked state.
  37050. * This happens due to new browser policies preventing audio to autoplay.
  37051. */
  37052. lock(): void;
  37053. /**
  37054. * Unlocks the audio engine once a user action has been done on the dom.
  37055. * This is helpful to resume play once browser policies have been satisfied.
  37056. */
  37057. unlock(): void;
  37058. /**
  37059. * Gets the global volume sets on the master gain.
  37060. * @returns the global volume if set or -1 otherwise
  37061. */
  37062. getGlobalVolume(): number;
  37063. /**
  37064. * Sets the global volume of your experience (sets on the master gain).
  37065. * @param newVolume Defines the new global volume of the application
  37066. */
  37067. setGlobalVolume(newVolume: number): void;
  37068. /**
  37069. * Connect the audio engine to an audio analyser allowing some amazing
  37070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37072. * @param analyser The analyser to connect to the engine
  37073. */
  37074. connectToAnalyser(analyser: Analyser): void;
  37075. }
  37076. /**
  37077. * This represents the default audio engine used in babylon.
  37078. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37079. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37080. */
  37081. export class AudioEngine implements IAudioEngine {
  37082. private _audioContext;
  37083. private _audioContextInitialized;
  37084. private _muteButton;
  37085. private _hostElement;
  37086. /**
  37087. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37088. */
  37089. canUseWebAudio: boolean;
  37090. /**
  37091. * The master gain node defines the global audio volume of your audio engine.
  37092. */
  37093. masterGain: GainNode;
  37094. /**
  37095. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37096. * @ignoreNaming
  37097. */
  37098. WarnedWebAudioUnsupported: boolean;
  37099. /**
  37100. * Gets whether or not mp3 are supported by your browser.
  37101. */
  37102. isMP3supported: boolean;
  37103. /**
  37104. * Gets whether or not ogg are supported by your browser.
  37105. */
  37106. isOGGsupported: boolean;
  37107. /**
  37108. * Gets whether audio has been unlocked on the device.
  37109. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37110. * a user interaction has happened.
  37111. */
  37112. unlocked: boolean;
  37113. /**
  37114. * Defines if the audio engine relies on a custom unlocked button.
  37115. * In this case, the embedded button will not be displayed.
  37116. */
  37117. useCustomUnlockedButton: boolean;
  37118. /**
  37119. * Event raised when audio has been unlocked on the browser.
  37120. */
  37121. onAudioUnlockedObservable: Observable<AudioEngine>;
  37122. /**
  37123. * Event raised when audio has been locked on the browser.
  37124. */
  37125. onAudioLockedObservable: Observable<AudioEngine>;
  37126. /**
  37127. * Gets the current AudioContext if available.
  37128. */
  37129. get audioContext(): Nullable<AudioContext>;
  37130. private _connectedAnalyser;
  37131. /**
  37132. * Instantiates a new audio engine.
  37133. *
  37134. * There should be only one per page as some browsers restrict the number
  37135. * of audio contexts you can create.
  37136. * @param hostElement defines the host element where to display the mute icon if necessary
  37137. */
  37138. constructor(hostElement?: Nullable<HTMLElement>);
  37139. /**
  37140. * Flags the audio engine in Locked state.
  37141. * This happens due to new browser policies preventing audio to autoplay.
  37142. */
  37143. lock(): void;
  37144. /**
  37145. * Unlocks the audio engine once a user action has been done on the dom.
  37146. * This is helpful to resume play once browser policies have been satisfied.
  37147. */
  37148. unlock(): void;
  37149. private _resumeAudioContext;
  37150. private _initializeAudioContext;
  37151. private _tryToRun;
  37152. private _triggerRunningState;
  37153. private _triggerSuspendedState;
  37154. private _displayMuteButton;
  37155. private _moveButtonToTopLeft;
  37156. private _onResize;
  37157. private _hideMuteButton;
  37158. /**
  37159. * Destroy and release the resources associated with the audio ccontext.
  37160. */
  37161. dispose(): void;
  37162. /**
  37163. * Gets the global volume sets on the master gain.
  37164. * @returns the global volume if set or -1 otherwise
  37165. */
  37166. getGlobalVolume(): number;
  37167. /**
  37168. * Sets the global volume of your experience (sets on the master gain).
  37169. * @param newVolume Defines the new global volume of the application
  37170. */
  37171. setGlobalVolume(newVolume: number): void;
  37172. /**
  37173. * Connect the audio engine to an audio analyser allowing some amazing
  37174. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37175. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37176. * @param analyser The analyser to connect to the engine
  37177. */
  37178. connectToAnalyser(analyser: Analyser): void;
  37179. }
  37180. }
  37181. declare module BABYLON {
  37182. /**
  37183. * Interface used to present a loading screen while loading a scene
  37184. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37185. */
  37186. export interface ILoadingScreen {
  37187. /**
  37188. * Function called to display the loading screen
  37189. */
  37190. displayLoadingUI: () => void;
  37191. /**
  37192. * Function called to hide the loading screen
  37193. */
  37194. hideLoadingUI: () => void;
  37195. /**
  37196. * Gets or sets the color to use for the background
  37197. */
  37198. loadingUIBackgroundColor: string;
  37199. /**
  37200. * Gets or sets the text to display while loading
  37201. */
  37202. loadingUIText: string;
  37203. }
  37204. /**
  37205. * Class used for the default loading screen
  37206. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37207. */
  37208. export class DefaultLoadingScreen implements ILoadingScreen {
  37209. private _renderingCanvas;
  37210. private _loadingText;
  37211. private _loadingDivBackgroundColor;
  37212. private _loadingDiv;
  37213. private _loadingTextDiv;
  37214. /** Gets or sets the logo url to use for the default loading screen */
  37215. static DefaultLogoUrl: string;
  37216. /** Gets or sets the spinner url to use for the default loading screen */
  37217. static DefaultSpinnerUrl: string;
  37218. /**
  37219. * Creates a new default loading screen
  37220. * @param _renderingCanvas defines the canvas used to render the scene
  37221. * @param _loadingText defines the default text to display
  37222. * @param _loadingDivBackgroundColor defines the default background color
  37223. */
  37224. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37225. /**
  37226. * Function called to display the loading screen
  37227. */
  37228. displayLoadingUI(): void;
  37229. /**
  37230. * Function called to hide the loading screen
  37231. */
  37232. hideLoadingUI(): void;
  37233. /**
  37234. * Gets or sets the text to display while loading
  37235. */
  37236. set loadingUIText(text: string);
  37237. get loadingUIText(): string;
  37238. /**
  37239. * Gets or sets the color to use for the background
  37240. */
  37241. get loadingUIBackgroundColor(): string;
  37242. set loadingUIBackgroundColor(color: string);
  37243. private _resizeLoadingUI;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /**
  37248. * Interface for any object that can request an animation frame
  37249. */
  37250. export interface ICustomAnimationFrameRequester {
  37251. /**
  37252. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37253. */
  37254. renderFunction?: Function;
  37255. /**
  37256. * Called to request the next frame to render to
  37257. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37258. */
  37259. requestAnimationFrame: Function;
  37260. /**
  37261. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37262. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37263. */
  37264. requestID?: number;
  37265. }
  37266. }
  37267. declare module BABYLON {
  37268. /**
  37269. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37270. */
  37271. export class PerformanceMonitor {
  37272. private _enabled;
  37273. private _rollingFrameTime;
  37274. private _lastFrameTimeMs;
  37275. /**
  37276. * constructor
  37277. * @param frameSampleSize The number of samples required to saturate the sliding window
  37278. */
  37279. constructor(frameSampleSize?: number);
  37280. /**
  37281. * Samples current frame
  37282. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37283. */
  37284. sampleFrame(timeMs?: number): void;
  37285. /**
  37286. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37287. */
  37288. get averageFrameTime(): number;
  37289. /**
  37290. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37291. */
  37292. get averageFrameTimeVariance(): number;
  37293. /**
  37294. * Returns the frame time of the most recent frame
  37295. */
  37296. get instantaneousFrameTime(): number;
  37297. /**
  37298. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37299. */
  37300. get averageFPS(): number;
  37301. /**
  37302. * Returns the average framerate in frames per second using the most recent frame time
  37303. */
  37304. get instantaneousFPS(): number;
  37305. /**
  37306. * Returns true if enough samples have been taken to completely fill the sliding window
  37307. */
  37308. get isSaturated(): boolean;
  37309. /**
  37310. * Enables contributions to the sliding window sample set
  37311. */
  37312. enable(): void;
  37313. /**
  37314. * Disables contributions to the sliding window sample set
  37315. * Samples will not be interpolated over the disabled period
  37316. */
  37317. disable(): void;
  37318. /**
  37319. * Returns true if sampling is enabled
  37320. */
  37321. get isEnabled(): boolean;
  37322. /**
  37323. * Resets performance monitor
  37324. */
  37325. reset(): void;
  37326. }
  37327. /**
  37328. * RollingAverage
  37329. *
  37330. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37331. */
  37332. export class RollingAverage {
  37333. /**
  37334. * Current average
  37335. */
  37336. average: number;
  37337. /**
  37338. * Current variance
  37339. */
  37340. variance: number;
  37341. protected _samples: Array<number>;
  37342. protected _sampleCount: number;
  37343. protected _pos: number;
  37344. protected _m2: number;
  37345. /**
  37346. * constructor
  37347. * @param length The number of samples required to saturate the sliding window
  37348. */
  37349. constructor(length: number);
  37350. /**
  37351. * Adds a sample to the sample set
  37352. * @param v The sample value
  37353. */
  37354. add(v: number): void;
  37355. /**
  37356. * Returns previously added values or null if outside of history or outside the sliding window domain
  37357. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37358. * @return Value previously recorded with add() or null if outside of range
  37359. */
  37360. history(i: number): number;
  37361. /**
  37362. * Returns true if enough samples have been taken to completely fill the sliding window
  37363. * @return true if sample-set saturated
  37364. */
  37365. isSaturated(): boolean;
  37366. /**
  37367. * Resets the rolling average (equivalent to 0 samples taken so far)
  37368. */
  37369. reset(): void;
  37370. /**
  37371. * Wraps a value around the sample range boundaries
  37372. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37373. * @return Wrapped position in sample range
  37374. */
  37375. protected _wrapPosition(i: number): number;
  37376. }
  37377. }
  37378. declare module BABYLON {
  37379. /**
  37380. * This class is used to track a performance counter which is number based.
  37381. * The user has access to many properties which give statistics of different nature.
  37382. *
  37383. * The implementer can track two kinds of Performance Counter: time and count.
  37384. * 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.
  37385. * 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.
  37386. */
  37387. export class PerfCounter {
  37388. /**
  37389. * Gets or sets a global boolean to turn on and off all the counters
  37390. */
  37391. static Enabled: boolean;
  37392. /**
  37393. * Returns the smallest value ever
  37394. */
  37395. get min(): number;
  37396. /**
  37397. * Returns the biggest value ever
  37398. */
  37399. get max(): number;
  37400. /**
  37401. * Returns the average value since the performance counter is running
  37402. */
  37403. get average(): number;
  37404. /**
  37405. * Returns the average value of the last second the counter was monitored
  37406. */
  37407. get lastSecAverage(): number;
  37408. /**
  37409. * Returns the current value
  37410. */
  37411. get current(): number;
  37412. /**
  37413. * Gets the accumulated total
  37414. */
  37415. get total(): number;
  37416. /**
  37417. * Gets the total value count
  37418. */
  37419. get count(): number;
  37420. /**
  37421. * Creates a new counter
  37422. */
  37423. constructor();
  37424. /**
  37425. * Call this method to start monitoring a new frame.
  37426. * 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.
  37427. */
  37428. fetchNewFrame(): void;
  37429. /**
  37430. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37431. * @param newCount the count value to add to the monitored count
  37432. * @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.
  37433. */
  37434. addCount(newCount: number, fetchResult: boolean): void;
  37435. /**
  37436. * Start monitoring this performance counter
  37437. */
  37438. beginMonitoring(): void;
  37439. /**
  37440. * Compute the time lapsed since the previous beginMonitoring() call.
  37441. * @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
  37442. */
  37443. endMonitoring(newFrame?: boolean): void;
  37444. private _fetchResult;
  37445. private _startMonitoringTime;
  37446. private _min;
  37447. private _max;
  37448. private _average;
  37449. private _current;
  37450. private _totalValueCount;
  37451. private _totalAccumulated;
  37452. private _lastSecAverage;
  37453. private _lastSecAccumulated;
  37454. private _lastSecTime;
  37455. private _lastSecValueCount;
  37456. }
  37457. }
  37458. declare module BABYLON {
  37459. interface ThinEngine {
  37460. /** @hidden */
  37461. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37462. }
  37463. }
  37464. declare module BABYLON {
  37465. /**
  37466. * Defines the interface used by display changed events
  37467. */
  37468. export interface IDisplayChangedEventArgs {
  37469. /** Gets the vrDisplay object (if any) */
  37470. vrDisplay: Nullable<any>;
  37471. /** Gets a boolean indicating if webVR is supported */
  37472. vrSupported: boolean;
  37473. }
  37474. /**
  37475. * Defines the interface used by objects containing a viewport (like a camera)
  37476. */
  37477. interface IViewportOwnerLike {
  37478. /**
  37479. * Gets or sets the viewport
  37480. */
  37481. viewport: IViewportLike;
  37482. }
  37483. /**
  37484. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37485. */
  37486. export class Engine extends ThinEngine {
  37487. /** Defines that alpha blending is disabled */
  37488. static readonly ALPHA_DISABLE: number;
  37489. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37490. static readonly ALPHA_ADD: number;
  37491. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37492. static readonly ALPHA_COMBINE: number;
  37493. /** Defines that alpha blending to DEST - SRC * DEST */
  37494. static readonly ALPHA_SUBTRACT: number;
  37495. /** Defines that alpha blending to SRC * DEST */
  37496. static readonly ALPHA_MULTIPLY: number;
  37497. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37498. static readonly ALPHA_MAXIMIZED: number;
  37499. /** Defines that alpha blending to SRC + DEST */
  37500. static readonly ALPHA_ONEONE: number;
  37501. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37502. static readonly ALPHA_PREMULTIPLIED: number;
  37503. /**
  37504. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37505. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37506. */
  37507. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37508. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37509. static readonly ALPHA_INTERPOLATE: number;
  37510. /**
  37511. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37512. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37513. */
  37514. static readonly ALPHA_SCREENMODE: number;
  37515. /** Defines that the ressource is not delayed*/
  37516. static readonly DELAYLOADSTATE_NONE: number;
  37517. /** Defines that the ressource was successfully delay loaded */
  37518. static readonly DELAYLOADSTATE_LOADED: number;
  37519. /** Defines that the ressource is currently delay loading */
  37520. static readonly DELAYLOADSTATE_LOADING: number;
  37521. /** Defines that the ressource is delayed and has not started loading */
  37522. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37524. static readonly NEVER: number;
  37525. /** 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 */
  37526. static readonly ALWAYS: number;
  37527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37528. static readonly LESS: number;
  37529. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37530. static readonly EQUAL: number;
  37531. /** 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 */
  37532. static readonly LEQUAL: number;
  37533. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37534. static readonly GREATER: number;
  37535. /** 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 */
  37536. static readonly GEQUAL: number;
  37537. /** 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 */
  37538. static readonly NOTEQUAL: number;
  37539. /** Passed to stencilOperation to specify that stencil value must be kept */
  37540. static readonly KEEP: number;
  37541. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37542. static readonly REPLACE: number;
  37543. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37544. static readonly INCR: number;
  37545. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37546. static readonly DECR: number;
  37547. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37548. static readonly INVERT: number;
  37549. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37550. static readonly INCR_WRAP: number;
  37551. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37552. static readonly DECR_WRAP: number;
  37553. /** Texture is not repeating outside of 0..1 UVs */
  37554. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37555. /** Texture is repeating outside of 0..1 UVs */
  37556. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37557. /** Texture is repeating and mirrored */
  37558. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37559. /** ALPHA */
  37560. static readonly TEXTUREFORMAT_ALPHA: number;
  37561. /** LUMINANCE */
  37562. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37563. /** LUMINANCE_ALPHA */
  37564. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37565. /** RGB */
  37566. static readonly TEXTUREFORMAT_RGB: number;
  37567. /** RGBA */
  37568. static readonly TEXTUREFORMAT_RGBA: number;
  37569. /** RED */
  37570. static readonly TEXTUREFORMAT_RED: number;
  37571. /** RED (2nd reference) */
  37572. static readonly TEXTUREFORMAT_R: number;
  37573. /** RG */
  37574. static readonly TEXTUREFORMAT_RG: number;
  37575. /** RED_INTEGER */
  37576. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37577. /** RED_INTEGER (2nd reference) */
  37578. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37579. /** RG_INTEGER */
  37580. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37581. /** RGB_INTEGER */
  37582. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37583. /** RGBA_INTEGER */
  37584. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37585. /** UNSIGNED_BYTE */
  37586. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37587. /** UNSIGNED_BYTE (2nd reference) */
  37588. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37589. /** FLOAT */
  37590. static readonly TEXTURETYPE_FLOAT: number;
  37591. /** HALF_FLOAT */
  37592. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37593. /** BYTE */
  37594. static readonly TEXTURETYPE_BYTE: number;
  37595. /** SHORT */
  37596. static readonly TEXTURETYPE_SHORT: number;
  37597. /** UNSIGNED_SHORT */
  37598. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37599. /** INT */
  37600. static readonly TEXTURETYPE_INT: number;
  37601. /** UNSIGNED_INT */
  37602. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37603. /** UNSIGNED_SHORT_4_4_4_4 */
  37604. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37605. /** UNSIGNED_SHORT_5_5_5_1 */
  37606. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37607. /** UNSIGNED_SHORT_5_6_5 */
  37608. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37609. /** UNSIGNED_INT_2_10_10_10_REV */
  37610. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37611. /** UNSIGNED_INT_24_8 */
  37612. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37613. /** UNSIGNED_INT_10F_11F_11F_REV */
  37614. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37615. /** UNSIGNED_INT_5_9_9_9_REV */
  37616. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37617. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37618. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37619. /** nearest is mag = nearest and min = nearest and mip = linear */
  37620. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37621. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37622. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37623. /** Trilinear is mag = linear and min = linear and mip = linear */
  37624. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37625. /** nearest is mag = nearest and min = nearest and mip = linear */
  37626. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37627. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37628. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37629. /** Trilinear is mag = linear and min = linear and mip = linear */
  37630. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37631. /** mag = nearest and min = nearest and mip = nearest */
  37632. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37633. /** mag = nearest and min = linear and mip = nearest */
  37634. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37635. /** mag = nearest and min = linear and mip = linear */
  37636. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37637. /** mag = nearest and min = linear and mip = none */
  37638. static readonly TEXTURE_NEAREST_LINEAR: number;
  37639. /** mag = nearest and min = nearest and mip = none */
  37640. static readonly TEXTURE_NEAREST_NEAREST: number;
  37641. /** mag = linear and min = nearest and mip = nearest */
  37642. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37643. /** mag = linear and min = nearest and mip = linear */
  37644. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37645. /** mag = linear and min = linear and mip = none */
  37646. static readonly TEXTURE_LINEAR_LINEAR: number;
  37647. /** mag = linear and min = nearest and mip = none */
  37648. static readonly TEXTURE_LINEAR_NEAREST: number;
  37649. /** Explicit coordinates mode */
  37650. static readonly TEXTURE_EXPLICIT_MODE: number;
  37651. /** Spherical coordinates mode */
  37652. static readonly TEXTURE_SPHERICAL_MODE: number;
  37653. /** Planar coordinates mode */
  37654. static readonly TEXTURE_PLANAR_MODE: number;
  37655. /** Cubic coordinates mode */
  37656. static readonly TEXTURE_CUBIC_MODE: number;
  37657. /** Projection coordinates mode */
  37658. static readonly TEXTURE_PROJECTION_MODE: number;
  37659. /** Skybox coordinates mode */
  37660. static readonly TEXTURE_SKYBOX_MODE: number;
  37661. /** Inverse Cubic coordinates mode */
  37662. static readonly TEXTURE_INVCUBIC_MODE: number;
  37663. /** Equirectangular coordinates mode */
  37664. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37665. /** Equirectangular Fixed coordinates mode */
  37666. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37667. /** Equirectangular Fixed Mirrored coordinates mode */
  37668. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37669. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37670. static readonly SCALEMODE_FLOOR: number;
  37671. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37672. static readonly SCALEMODE_NEAREST: number;
  37673. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37674. static readonly SCALEMODE_CEILING: number;
  37675. /**
  37676. * Returns the current npm package of the sdk
  37677. */
  37678. static get NpmPackage(): string;
  37679. /**
  37680. * Returns the current version of the framework
  37681. */
  37682. static get Version(): string;
  37683. /** Gets the list of created engines */
  37684. static get Instances(): Engine[];
  37685. /**
  37686. * Gets the latest created engine
  37687. */
  37688. static get LastCreatedEngine(): Nullable<Engine>;
  37689. /**
  37690. * Gets the latest created scene
  37691. */
  37692. static get LastCreatedScene(): Nullable<Scene>;
  37693. /**
  37694. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37695. * @param flag defines which part of the materials must be marked as dirty
  37696. * @param predicate defines a predicate used to filter which materials should be affected
  37697. */
  37698. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37699. /**
  37700. * Method called to create the default loading screen.
  37701. * This can be overriden in your own app.
  37702. * @param canvas The rendering canvas element
  37703. * @returns The loading screen
  37704. */
  37705. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37706. /**
  37707. * Method called to create the default rescale post process on each engine.
  37708. */
  37709. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37710. /**
  37711. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37712. **/
  37713. enableOfflineSupport: boolean;
  37714. /**
  37715. * 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)
  37716. **/
  37717. disableManifestCheck: boolean;
  37718. /**
  37719. * Gets the list of created scenes
  37720. */
  37721. scenes: Scene[];
  37722. /**
  37723. * Event raised when a new scene is created
  37724. */
  37725. onNewSceneAddedObservable: Observable<Scene>;
  37726. /**
  37727. * Gets the list of created postprocesses
  37728. */
  37729. postProcesses: PostProcess[];
  37730. /**
  37731. * Gets a boolean indicating if the pointer is currently locked
  37732. */
  37733. isPointerLock: boolean;
  37734. /**
  37735. * Observable event triggered each time the rendering canvas is resized
  37736. */
  37737. onResizeObservable: Observable<Engine>;
  37738. /**
  37739. * Observable event triggered each time the canvas loses focus
  37740. */
  37741. onCanvasBlurObservable: Observable<Engine>;
  37742. /**
  37743. * Observable event triggered each time the canvas gains focus
  37744. */
  37745. onCanvasFocusObservable: Observable<Engine>;
  37746. /**
  37747. * Observable event triggered each time the canvas receives pointerout event
  37748. */
  37749. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37750. /**
  37751. * Observable raised when the engine begins a new frame
  37752. */
  37753. onBeginFrameObservable: Observable<Engine>;
  37754. /**
  37755. * If set, will be used to request the next animation frame for the render loop
  37756. */
  37757. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37758. /**
  37759. * Observable raised when the engine ends the current frame
  37760. */
  37761. onEndFrameObservable: Observable<Engine>;
  37762. /**
  37763. * Observable raised when the engine is about to compile a shader
  37764. */
  37765. onBeforeShaderCompilationObservable: Observable<Engine>;
  37766. /**
  37767. * Observable raised when the engine has jsut compiled a shader
  37768. */
  37769. onAfterShaderCompilationObservable: Observable<Engine>;
  37770. /**
  37771. * Gets the audio engine
  37772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37773. * @ignorenaming
  37774. */
  37775. static audioEngine: IAudioEngine;
  37776. /**
  37777. * Default AudioEngine factory responsible of creating the Audio Engine.
  37778. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37779. */
  37780. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37781. /**
  37782. * Default offline support factory responsible of creating a tool used to store data locally.
  37783. * By default, this will create a Database object if the workload has been embedded.
  37784. */
  37785. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37786. private _loadingScreen;
  37787. private _pointerLockRequested;
  37788. private _rescalePostProcess;
  37789. private _deterministicLockstep;
  37790. private _lockstepMaxSteps;
  37791. private _timeStep;
  37792. protected get _supportsHardwareTextureRescaling(): boolean;
  37793. private _fps;
  37794. private _deltaTime;
  37795. /** @hidden */
  37796. _drawCalls: PerfCounter;
  37797. /** 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 */
  37798. canvasTabIndex: number;
  37799. /**
  37800. * Turn this value on if you want to pause FPS computation when in background
  37801. */
  37802. disablePerformanceMonitorInBackground: boolean;
  37803. private _performanceMonitor;
  37804. /**
  37805. * Gets the performance monitor attached to this engine
  37806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37807. */
  37808. get performanceMonitor(): PerformanceMonitor;
  37809. private _onFocus;
  37810. private _onBlur;
  37811. private _onCanvasPointerOut;
  37812. private _onCanvasBlur;
  37813. private _onCanvasFocus;
  37814. private _onFullscreenChange;
  37815. private _onPointerLockChange;
  37816. /**
  37817. * Gets the HTML element used to attach event listeners
  37818. * @returns a HTML element
  37819. */
  37820. getInputElement(): Nullable<HTMLElement>;
  37821. /**
  37822. * Creates a new engine
  37823. * @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
  37824. * @param antialias defines enable antialiasing (default: false)
  37825. * @param options defines further options to be sent to the getContext() function
  37826. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37827. */
  37828. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37829. /**
  37830. * Gets current aspect ratio
  37831. * @param viewportOwner defines the camera to use to get the aspect ratio
  37832. * @param useScreen defines if screen size must be used (or the current render target if any)
  37833. * @returns a number defining the aspect ratio
  37834. */
  37835. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37836. /**
  37837. * Gets current screen aspect ratio
  37838. * @returns a number defining the aspect ratio
  37839. */
  37840. getScreenAspectRatio(): number;
  37841. /**
  37842. * Gets the client rect of the HTML canvas attached with the current webGL context
  37843. * @returns a client rectanglee
  37844. */
  37845. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37846. /**
  37847. * Gets the client rect of the HTML element used for events
  37848. * @returns a client rectanglee
  37849. */
  37850. getInputElementClientRect(): Nullable<ClientRect>;
  37851. /**
  37852. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37853. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37854. * @returns true if engine is in deterministic lock step mode
  37855. */
  37856. isDeterministicLockStep(): boolean;
  37857. /**
  37858. * Gets the max steps when engine is running in deterministic lock step
  37859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37860. * @returns the max steps
  37861. */
  37862. getLockstepMaxSteps(): number;
  37863. /**
  37864. * Returns the time in ms between steps when using deterministic lock step.
  37865. * @returns time step in (ms)
  37866. */
  37867. getTimeStep(): number;
  37868. /**
  37869. * Force the mipmap generation for the given render target texture
  37870. * @param texture defines the render target texture to use
  37871. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37872. */
  37873. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37874. /** States */
  37875. /**
  37876. * Set various states to the webGL context
  37877. * @param culling defines backface culling state
  37878. * @param zOffset defines the value to apply to zOffset (0 by default)
  37879. * @param force defines if states must be applied even if cache is up to date
  37880. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37881. */
  37882. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37883. /**
  37884. * Set the z offset to apply to current rendering
  37885. * @param value defines the offset to apply
  37886. */
  37887. setZOffset(value: number): void;
  37888. /**
  37889. * Gets the current value of the zOffset
  37890. * @returns the current zOffset state
  37891. */
  37892. getZOffset(): number;
  37893. /**
  37894. * Enable or disable depth buffering
  37895. * @param enable defines the state to set
  37896. */
  37897. setDepthBuffer(enable: boolean): void;
  37898. /**
  37899. * Gets a boolean indicating if depth writing is enabled
  37900. * @returns the current depth writing state
  37901. */
  37902. getDepthWrite(): boolean;
  37903. /**
  37904. * Enable or disable depth writing
  37905. * @param enable defines the state to set
  37906. */
  37907. setDepthWrite(enable: boolean): void;
  37908. /**
  37909. * Gets a boolean indicating if stencil buffer is enabled
  37910. * @returns the current stencil buffer state
  37911. */
  37912. getStencilBuffer(): boolean;
  37913. /**
  37914. * Enable or disable the stencil buffer
  37915. * @param enable defines if the stencil buffer must be enabled or disabled
  37916. */
  37917. setStencilBuffer(enable: boolean): void;
  37918. /**
  37919. * Gets the current stencil mask
  37920. * @returns a number defining the new stencil mask to use
  37921. */
  37922. getStencilMask(): number;
  37923. /**
  37924. * Sets the current stencil mask
  37925. * @param mask defines the new stencil mask to use
  37926. */
  37927. setStencilMask(mask: number): void;
  37928. /**
  37929. * Gets the current stencil function
  37930. * @returns a number defining the stencil function to use
  37931. */
  37932. getStencilFunction(): number;
  37933. /**
  37934. * Gets the current stencil reference value
  37935. * @returns a number defining the stencil reference value to use
  37936. */
  37937. getStencilFunctionReference(): number;
  37938. /**
  37939. * Gets the current stencil mask
  37940. * @returns a number defining the stencil mask to use
  37941. */
  37942. getStencilFunctionMask(): number;
  37943. /**
  37944. * Sets the current stencil function
  37945. * @param stencilFunc defines the new stencil function to use
  37946. */
  37947. setStencilFunction(stencilFunc: number): void;
  37948. /**
  37949. * Sets the current stencil reference
  37950. * @param reference defines the new stencil reference to use
  37951. */
  37952. setStencilFunctionReference(reference: number): void;
  37953. /**
  37954. * Sets the current stencil mask
  37955. * @param mask defines the new stencil mask to use
  37956. */
  37957. setStencilFunctionMask(mask: number): void;
  37958. /**
  37959. * Gets the current stencil operation when stencil fails
  37960. * @returns a number defining stencil operation to use when stencil fails
  37961. */
  37962. getStencilOperationFail(): number;
  37963. /**
  37964. * Gets the current stencil operation when depth fails
  37965. * @returns a number defining stencil operation to use when depth fails
  37966. */
  37967. getStencilOperationDepthFail(): number;
  37968. /**
  37969. * Gets the current stencil operation when stencil passes
  37970. * @returns a number defining stencil operation to use when stencil passes
  37971. */
  37972. getStencilOperationPass(): number;
  37973. /**
  37974. * Sets the stencil operation to use when stencil fails
  37975. * @param operation defines the stencil operation to use when stencil fails
  37976. */
  37977. setStencilOperationFail(operation: number): void;
  37978. /**
  37979. * Sets the stencil operation to use when depth fails
  37980. * @param operation defines the stencil operation to use when depth fails
  37981. */
  37982. setStencilOperationDepthFail(operation: number): void;
  37983. /**
  37984. * Sets the stencil operation to use when stencil passes
  37985. * @param operation defines the stencil operation to use when stencil passes
  37986. */
  37987. setStencilOperationPass(operation: number): void;
  37988. /**
  37989. * Sets a boolean indicating if the dithering state is enabled or disabled
  37990. * @param value defines the dithering state
  37991. */
  37992. setDitheringState(value: boolean): void;
  37993. /**
  37994. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37995. * @param value defines the rasterizer state
  37996. */
  37997. setRasterizerState(value: boolean): void;
  37998. /**
  37999. * Gets the current depth function
  38000. * @returns a number defining the depth function
  38001. */
  38002. getDepthFunction(): Nullable<number>;
  38003. /**
  38004. * Sets the current depth function
  38005. * @param depthFunc defines the function to use
  38006. */
  38007. setDepthFunction(depthFunc: number): void;
  38008. /**
  38009. * Sets the current depth function to GREATER
  38010. */
  38011. setDepthFunctionToGreater(): void;
  38012. /**
  38013. * Sets the current depth function to GEQUAL
  38014. */
  38015. setDepthFunctionToGreaterOrEqual(): void;
  38016. /**
  38017. * Sets the current depth function to LESS
  38018. */
  38019. setDepthFunctionToLess(): void;
  38020. /**
  38021. * Sets the current depth function to LEQUAL
  38022. */
  38023. setDepthFunctionToLessOrEqual(): void;
  38024. private _cachedStencilBuffer;
  38025. private _cachedStencilFunction;
  38026. private _cachedStencilMask;
  38027. private _cachedStencilOperationPass;
  38028. private _cachedStencilOperationFail;
  38029. private _cachedStencilOperationDepthFail;
  38030. private _cachedStencilReference;
  38031. /**
  38032. * Caches the the state of the stencil buffer
  38033. */
  38034. cacheStencilState(): void;
  38035. /**
  38036. * Restores the state of the stencil buffer
  38037. */
  38038. restoreStencilState(): void;
  38039. /**
  38040. * Directly set the WebGL Viewport
  38041. * @param x defines the x coordinate of the viewport (in screen space)
  38042. * @param y defines the y coordinate of the viewport (in screen space)
  38043. * @param width defines the width of the viewport (in screen space)
  38044. * @param height defines the height of the viewport (in screen space)
  38045. * @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
  38046. */
  38047. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38048. /**
  38049. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38050. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38051. * @param y defines the y-coordinate of the corner of the clear rectangle
  38052. * @param width defines the width of the clear rectangle
  38053. * @param height defines the height of the clear rectangle
  38054. * @param clearColor defines the clear color
  38055. */
  38056. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38057. /**
  38058. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38059. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38060. * @param y defines the y-coordinate of the corner of the clear rectangle
  38061. * @param width defines the width of the clear rectangle
  38062. * @param height defines the height of the clear rectangle
  38063. */
  38064. enableScissor(x: number, y: number, width: number, height: number): void;
  38065. /**
  38066. * Disable previously set scissor test rectangle
  38067. */
  38068. disableScissor(): void;
  38069. protected _reportDrawCall(): void;
  38070. /**
  38071. * Initializes a webVR display and starts listening to display change events
  38072. * The onVRDisplayChangedObservable will be notified upon these changes
  38073. * @returns The onVRDisplayChangedObservable
  38074. */
  38075. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38076. /** @hidden */
  38077. _prepareVRComponent(): void;
  38078. /** @hidden */
  38079. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38080. /** @hidden */
  38081. _submitVRFrame(): void;
  38082. /**
  38083. * Call this function to leave webVR mode
  38084. * Will do nothing if webVR is not supported or if there is no webVR device
  38085. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38086. */
  38087. disableVR(): void;
  38088. /**
  38089. * Gets a boolean indicating that the system is in VR mode and is presenting
  38090. * @returns true if VR mode is engaged
  38091. */
  38092. isVRPresenting(): boolean;
  38093. /** @hidden */
  38094. _requestVRFrame(): void;
  38095. /** @hidden */
  38096. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38097. /**
  38098. * Gets the source code of the vertex shader associated with a specific webGL program
  38099. * @param program defines the program to use
  38100. * @returns a string containing the source code of the vertex shader associated with the program
  38101. */
  38102. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38103. /**
  38104. * Gets the source code of the fragment shader associated with a specific webGL program
  38105. * @param program defines the program to use
  38106. * @returns a string containing the source code of the fragment shader associated with the program
  38107. */
  38108. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38109. /**
  38110. * Sets a depth stencil texture from a render target to the according uniform.
  38111. * @param channel The texture channel
  38112. * @param uniform The uniform to set
  38113. * @param texture The render target texture containing the depth stencil texture to apply
  38114. */
  38115. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38116. /**
  38117. * Sets a texture to the webGL context from a postprocess
  38118. * @param channel defines the channel to use
  38119. * @param postProcess defines the source postprocess
  38120. */
  38121. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38122. /**
  38123. * Binds the output of the passed in post process to the texture channel specified
  38124. * @param channel The channel the texture should be bound to
  38125. * @param postProcess The post process which's output should be bound
  38126. */
  38127. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38128. protected _rebuildBuffers(): void;
  38129. /** @hidden */
  38130. _renderFrame(): void;
  38131. _renderLoop(): void;
  38132. /** @hidden */
  38133. _renderViews(): boolean;
  38134. /**
  38135. * Toggle full screen mode
  38136. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38137. */
  38138. switchFullscreen(requestPointerLock: boolean): void;
  38139. /**
  38140. * Enters full screen mode
  38141. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38142. */
  38143. enterFullscreen(requestPointerLock: boolean): void;
  38144. /**
  38145. * Exits full screen mode
  38146. */
  38147. exitFullscreen(): void;
  38148. /**
  38149. * Enters Pointerlock mode
  38150. */
  38151. enterPointerlock(): void;
  38152. /**
  38153. * Exits Pointerlock mode
  38154. */
  38155. exitPointerlock(): void;
  38156. /**
  38157. * Begin a new frame
  38158. */
  38159. beginFrame(): void;
  38160. /**
  38161. * Enf the current frame
  38162. */
  38163. endFrame(): void;
  38164. resize(): void;
  38165. /**
  38166. * Force a specific size of the canvas
  38167. * @param width defines the new canvas' width
  38168. * @param height defines the new canvas' height
  38169. * @returns true if the size was changed
  38170. */
  38171. setSize(width: number, height: number): boolean;
  38172. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38173. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38174. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38175. _releaseTexture(texture: InternalTexture): void;
  38176. /**
  38177. * @hidden
  38178. * Rescales a texture
  38179. * @param source input texutre
  38180. * @param destination destination texture
  38181. * @param scene scene to use to render the resize
  38182. * @param internalFormat format to use when resizing
  38183. * @param onComplete callback to be called when resize has completed
  38184. */
  38185. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38186. /**
  38187. * Gets the current framerate
  38188. * @returns a number representing the framerate
  38189. */
  38190. getFps(): number;
  38191. /**
  38192. * Gets the time spent between current and previous frame
  38193. * @returns a number representing the delta time in ms
  38194. */
  38195. getDeltaTime(): number;
  38196. private _measureFps;
  38197. /** @hidden */
  38198. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38199. /**
  38200. * Updates the sample count of a render target texture
  38201. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38202. * @param texture defines the texture to update
  38203. * @param samples defines the sample count to set
  38204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38205. */
  38206. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38207. /**
  38208. * Updates a depth texture Comparison Mode and Function.
  38209. * If the comparison Function is equal to 0, the mode will be set to none.
  38210. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38211. * @param texture The texture to set the comparison function for
  38212. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38213. */
  38214. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38215. /**
  38216. * Creates a webGL buffer to use with instanciation
  38217. * @param capacity defines the size of the buffer
  38218. * @returns the webGL buffer
  38219. */
  38220. createInstancesBuffer(capacity: number): DataBuffer;
  38221. /**
  38222. * Delete a webGL buffer used with instanciation
  38223. * @param buffer defines the webGL buffer to delete
  38224. */
  38225. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38226. private _clientWaitAsync;
  38227. /** @hidden */
  38228. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38229. dispose(): void;
  38230. private _disableTouchAction;
  38231. /**
  38232. * Display the loading screen
  38233. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38234. */
  38235. displayLoadingUI(): void;
  38236. /**
  38237. * Hide the loading screen
  38238. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38239. */
  38240. hideLoadingUI(): void;
  38241. /**
  38242. * Gets the current loading screen object
  38243. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38244. */
  38245. get loadingScreen(): ILoadingScreen;
  38246. /**
  38247. * Sets the current loading screen object
  38248. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38249. */
  38250. set loadingScreen(loadingScreen: ILoadingScreen);
  38251. /**
  38252. * Sets the current loading screen text
  38253. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38254. */
  38255. set loadingUIText(text: string);
  38256. /**
  38257. * Sets the current loading screen background color
  38258. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38259. */
  38260. set loadingUIBackgroundColor(color: string);
  38261. /** Pointerlock and fullscreen */
  38262. /**
  38263. * Ask the browser to promote the current element to pointerlock mode
  38264. * @param element defines the DOM element to promote
  38265. */
  38266. static _RequestPointerlock(element: HTMLElement): void;
  38267. /**
  38268. * Asks the browser to exit pointerlock mode
  38269. */
  38270. static _ExitPointerlock(): void;
  38271. /**
  38272. * Ask the browser to promote the current element to fullscreen rendering mode
  38273. * @param element defines the DOM element to promote
  38274. */
  38275. static _RequestFullscreen(element: HTMLElement): void;
  38276. /**
  38277. * Asks the browser to exit fullscreen mode
  38278. */
  38279. static _ExitFullscreen(): void;
  38280. }
  38281. }
  38282. declare module BABYLON {
  38283. /**
  38284. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38285. * during the life time of the application.
  38286. */
  38287. export class EngineStore {
  38288. /** Gets the list of created engines */
  38289. static Instances: Engine[];
  38290. /** @hidden */
  38291. static _LastCreatedScene: Nullable<Scene>;
  38292. /**
  38293. * Gets the latest created engine
  38294. */
  38295. static get LastCreatedEngine(): Nullable<Engine>;
  38296. /**
  38297. * Gets the latest created scene
  38298. */
  38299. static get LastCreatedScene(): Nullable<Scene>;
  38300. /**
  38301. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38302. * @ignorenaming
  38303. */
  38304. static UseFallbackTexture: boolean;
  38305. /**
  38306. * Texture content used if a texture cannot loaded
  38307. * @ignorenaming
  38308. */
  38309. static FallbackTexture: string;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /**
  38314. * Helper class that provides a small promise polyfill
  38315. */
  38316. export class PromisePolyfill {
  38317. /**
  38318. * Static function used to check if the polyfill is required
  38319. * If this is the case then the function will inject the polyfill to window.Promise
  38320. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38321. */
  38322. static Apply(force?: boolean): void;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /**
  38327. * Interface for screenshot methods with describe argument called `size` as object with options
  38328. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38329. */
  38330. export interface IScreenshotSize {
  38331. /**
  38332. * number in pixels for canvas height
  38333. */
  38334. height?: number;
  38335. /**
  38336. * multiplier allowing render at a higher or lower resolution
  38337. * If value is defined then height and width will be ignored and taken from camera
  38338. */
  38339. precision?: number;
  38340. /**
  38341. * number in pixels for canvas width
  38342. */
  38343. width?: number;
  38344. }
  38345. }
  38346. declare module BABYLON {
  38347. interface IColor4Like {
  38348. r: float;
  38349. g: float;
  38350. b: float;
  38351. a: float;
  38352. }
  38353. /**
  38354. * Class containing a set of static utilities functions
  38355. */
  38356. export class Tools {
  38357. /**
  38358. * Gets or sets the base URL to use to load assets
  38359. */
  38360. static get BaseUrl(): string;
  38361. static set BaseUrl(value: string);
  38362. /**
  38363. * Enable/Disable Custom HTTP Request Headers globally.
  38364. * default = false
  38365. * @see CustomRequestHeaders
  38366. */
  38367. static UseCustomRequestHeaders: boolean;
  38368. /**
  38369. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38370. * i.e. when loading files, where the server/service expects an Authorization header
  38371. */
  38372. static CustomRequestHeaders: {
  38373. [key: string]: string;
  38374. };
  38375. /**
  38376. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38377. */
  38378. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38379. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38380. /**
  38381. * Default behaviour for cors in the application.
  38382. * It can be a string if the expected behavior is identical in the entire app.
  38383. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38384. */
  38385. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38386. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38387. /**
  38388. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38389. * @ignorenaming
  38390. */
  38391. static get UseFallbackTexture(): boolean;
  38392. static set UseFallbackTexture(value: boolean);
  38393. /**
  38394. * Use this object to register external classes like custom textures or material
  38395. * to allow the laoders to instantiate them
  38396. */
  38397. static get RegisteredExternalClasses(): {
  38398. [key: string]: Object;
  38399. };
  38400. static set RegisteredExternalClasses(classes: {
  38401. [key: string]: Object;
  38402. });
  38403. /**
  38404. * Texture content used if a texture cannot loaded
  38405. * @ignorenaming
  38406. */
  38407. static get fallbackTexture(): string;
  38408. static set fallbackTexture(value: string);
  38409. /**
  38410. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38411. * @param u defines the coordinate on X axis
  38412. * @param v defines the coordinate on Y axis
  38413. * @param width defines the width of the source data
  38414. * @param height defines the height of the source data
  38415. * @param pixels defines the source byte array
  38416. * @param color defines the output color
  38417. */
  38418. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38419. /**
  38420. * Interpolates between a and b via alpha
  38421. * @param a The lower value (returned when alpha = 0)
  38422. * @param b The upper value (returned when alpha = 1)
  38423. * @param alpha The interpolation-factor
  38424. * @return The mixed value
  38425. */
  38426. static Mix(a: number, b: number, alpha: number): number;
  38427. /**
  38428. * Tries to instantiate a new object from a given class name
  38429. * @param className defines the class name to instantiate
  38430. * @returns the new object or null if the system was not able to do the instantiation
  38431. */
  38432. static Instantiate(className: string): any;
  38433. /**
  38434. * Provides a slice function that will work even on IE
  38435. * @param data defines the array to slice
  38436. * @param start defines the start of the data (optional)
  38437. * @param end defines the end of the data (optional)
  38438. * @returns the new sliced array
  38439. */
  38440. static Slice<T>(data: T, start?: number, end?: number): T;
  38441. /**
  38442. * Polyfill for setImmediate
  38443. * @param action defines the action to execute after the current execution block
  38444. */
  38445. static SetImmediate(action: () => void): void;
  38446. /**
  38447. * Function indicating if a number is an exponent of 2
  38448. * @param value defines the value to test
  38449. * @returns true if the value is an exponent of 2
  38450. */
  38451. static IsExponentOfTwo(value: number): boolean;
  38452. private static _tmpFloatArray;
  38453. /**
  38454. * Returns the nearest 32-bit single precision float representation of a Number
  38455. * @param value A Number. If the parameter is of a different type, it will get converted
  38456. * to a number or to NaN if it cannot be converted
  38457. * @returns number
  38458. */
  38459. static FloatRound(value: number): number;
  38460. /**
  38461. * Extracts the filename from a path
  38462. * @param path defines the path to use
  38463. * @returns the filename
  38464. */
  38465. static GetFilename(path: string): string;
  38466. /**
  38467. * Extracts the "folder" part of a path (everything before the filename).
  38468. * @param uri The URI to extract the info from
  38469. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38470. * @returns The "folder" part of the path
  38471. */
  38472. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38473. /**
  38474. * Extracts text content from a DOM element hierarchy
  38475. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38476. */
  38477. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38478. /**
  38479. * Convert an angle in radians to degrees
  38480. * @param angle defines the angle to convert
  38481. * @returns the angle in degrees
  38482. */
  38483. static ToDegrees(angle: number): number;
  38484. /**
  38485. * Convert an angle in degrees to radians
  38486. * @param angle defines the angle to convert
  38487. * @returns the angle in radians
  38488. */
  38489. static ToRadians(angle: number): number;
  38490. /**
  38491. * Returns an array if obj is not an array
  38492. * @param obj defines the object to evaluate as an array
  38493. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38494. * @returns either obj directly if obj is an array or a new array containing obj
  38495. */
  38496. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38497. /**
  38498. * Gets the pointer prefix to use
  38499. * @param engine defines the engine we are finding the prefix for
  38500. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38501. */
  38502. static GetPointerPrefix(engine: Engine): string;
  38503. /**
  38504. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38505. * @param url define the url we are trying
  38506. * @param element define the dom element where to configure the cors policy
  38507. */
  38508. static SetCorsBehavior(url: string | string[], element: {
  38509. crossOrigin: string | null;
  38510. }): void;
  38511. /**
  38512. * Removes unwanted characters from an url
  38513. * @param url defines the url to clean
  38514. * @returns the cleaned url
  38515. */
  38516. static CleanUrl(url: string): string;
  38517. /**
  38518. * Gets or sets a function used to pre-process url before using them to load assets
  38519. */
  38520. static get PreprocessUrl(): (url: string) => string;
  38521. static set PreprocessUrl(processor: (url: string) => string);
  38522. /**
  38523. * Loads an image as an HTMLImageElement.
  38524. * @param input url string, ArrayBuffer, or Blob to load
  38525. * @param onLoad callback called when the image successfully loads
  38526. * @param onError callback called when the image fails to load
  38527. * @param offlineProvider offline provider for caching
  38528. * @param mimeType optional mime type
  38529. * @returns the HTMLImageElement of the loaded image
  38530. */
  38531. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38532. /**
  38533. * Loads a file from a url
  38534. * @param url url string, ArrayBuffer, or Blob to load
  38535. * @param onSuccess callback called when the file successfully loads
  38536. * @param onProgress callback called while file is loading (if the server supports this mode)
  38537. * @param offlineProvider defines the offline provider for caching
  38538. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38539. * @param onError callback called when the file fails to load
  38540. * @returns a file request object
  38541. */
  38542. 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;
  38543. /**
  38544. * Loads a file from a url
  38545. * @param url the file url to load
  38546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38547. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38548. */
  38549. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38550. /**
  38551. * Load a script (identified by an url). When the url returns, the
  38552. * content of this file is added into a new script element, attached to the DOM (body element)
  38553. * @param scriptUrl defines the url of the script to laod
  38554. * @param onSuccess defines the callback called when the script is loaded
  38555. * @param onError defines the callback to call if an error occurs
  38556. * @param scriptId defines the id of the script element
  38557. */
  38558. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38559. /**
  38560. * Load an asynchronous script (identified by an url). When the url returns, the
  38561. * content of this file is added into a new script element, attached to the DOM (body element)
  38562. * @param scriptUrl defines the url of the script to laod
  38563. * @param scriptId defines the id of the script element
  38564. * @returns a promise request object
  38565. */
  38566. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38567. /**
  38568. * Loads a file from a blob
  38569. * @param fileToLoad defines the blob to use
  38570. * @param callback defines the callback to call when data is loaded
  38571. * @param progressCallback defines the callback to call during loading process
  38572. * @returns a file request object
  38573. */
  38574. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38575. /**
  38576. * Reads a file from a File object
  38577. * @param file defines the file to load
  38578. * @param onSuccess defines the callback to call when data is loaded
  38579. * @param onProgress defines the callback to call during loading process
  38580. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38581. * @param onError defines the callback to call when an error occurs
  38582. * @returns a file request object
  38583. */
  38584. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38585. /**
  38586. * Creates a data url from a given string content
  38587. * @param content defines the content to convert
  38588. * @returns the new data url link
  38589. */
  38590. static FileAsURL(content: string): string;
  38591. /**
  38592. * Format the given number to a specific decimal format
  38593. * @param value defines the number to format
  38594. * @param decimals defines the number of decimals to use
  38595. * @returns the formatted string
  38596. */
  38597. static Format(value: number, decimals?: number): string;
  38598. /**
  38599. * Tries to copy an object by duplicating every property
  38600. * @param source defines the source object
  38601. * @param destination defines the target object
  38602. * @param doNotCopyList defines a list of properties to avoid
  38603. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38604. */
  38605. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38606. /**
  38607. * Gets a boolean indicating if the given object has no own property
  38608. * @param obj defines the object to test
  38609. * @returns true if object has no own property
  38610. */
  38611. static IsEmpty(obj: any): boolean;
  38612. /**
  38613. * Function used to register events at window level
  38614. * @param windowElement defines the Window object to use
  38615. * @param events defines the events to register
  38616. */
  38617. static RegisterTopRootEvents(windowElement: Window, events: {
  38618. name: string;
  38619. handler: Nullable<(e: FocusEvent) => any>;
  38620. }[]): void;
  38621. /**
  38622. * Function used to unregister events from window level
  38623. * @param windowElement defines the Window object to use
  38624. * @param events defines the events to unregister
  38625. */
  38626. static UnregisterTopRootEvents(windowElement: Window, events: {
  38627. name: string;
  38628. handler: Nullable<(e: FocusEvent) => any>;
  38629. }[]): void;
  38630. /**
  38631. * @ignore
  38632. */
  38633. static _ScreenshotCanvas: HTMLCanvasElement;
  38634. /**
  38635. * Dumps the current bound framebuffer
  38636. * @param width defines the rendering width
  38637. * @param height defines the rendering height
  38638. * @param engine defines the hosting engine
  38639. * @param successCallback defines the callback triggered once the data are available
  38640. * @param mimeType defines the mime type of the result
  38641. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38642. */
  38643. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38644. /**
  38645. * Converts the canvas data to blob.
  38646. * This acts as a polyfill for browsers not supporting the to blob function.
  38647. * @param canvas Defines the canvas to extract the data from
  38648. * @param successCallback Defines the callback triggered once the data are available
  38649. * @param mimeType Defines the mime type of the result
  38650. */
  38651. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38652. /**
  38653. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38654. * @param successCallback defines the callback triggered once the data are available
  38655. * @param mimeType defines the mime type of the result
  38656. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38657. */
  38658. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38659. /**
  38660. * Downloads a blob in the browser
  38661. * @param blob defines the blob to download
  38662. * @param fileName defines the name of the downloaded file
  38663. */
  38664. static Download(blob: Blob, fileName: string): void;
  38665. /**
  38666. * Captures a screenshot of the current rendering
  38667. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38668. * @param engine defines the rendering engine
  38669. * @param camera defines the source camera
  38670. * @param size This parameter can be set to a single number or to an object with the
  38671. * following (optional) properties: precision, width, height. If a single number is passed,
  38672. * it will be used for both width and height. If an object is passed, the screenshot size
  38673. * will be derived from the parameters. The precision property is a multiplier allowing
  38674. * rendering at a higher or lower resolution
  38675. * @param successCallback defines the callback receives a single parameter which contains the
  38676. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38677. * src parameter of an <img> to display it
  38678. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38679. * Check your browser for supported MIME types
  38680. */
  38681. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38682. /**
  38683. * Captures a screenshot of the current rendering
  38684. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38685. * @param engine defines the rendering engine
  38686. * @param camera defines the source camera
  38687. * @param size This parameter can be set to a single number or to an object with the
  38688. * following (optional) properties: precision, width, height. If a single number is passed,
  38689. * it will be used for both width and height. If an object is passed, the screenshot size
  38690. * will be derived from the parameters. The precision property is a multiplier allowing
  38691. * rendering at a higher or lower resolution
  38692. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38693. * Check your browser for supported MIME types
  38694. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38695. * to the src parameter of an <img> to display it
  38696. */
  38697. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38698. /**
  38699. * Generates an image screenshot from the specified camera.
  38700. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38701. * @param engine The engine to use for rendering
  38702. * @param camera The camera to use for rendering
  38703. * @param size This parameter can be set to a single number or to an object with the
  38704. * following (optional) properties: precision, width, height. If a single number is passed,
  38705. * it will be used for both width and height. If an object is passed, the screenshot size
  38706. * will be derived from the parameters. The precision property is a multiplier allowing
  38707. * rendering at a higher or lower resolution
  38708. * @param successCallback The callback receives a single parameter which contains the
  38709. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38710. * src parameter of an <img> to display it
  38711. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38712. * Check your browser for supported MIME types
  38713. * @param samples Texture samples (default: 1)
  38714. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38715. * @param fileName A name for for the downloaded file.
  38716. */
  38717. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38718. /**
  38719. * Generates an image screenshot from the specified camera.
  38720. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38721. * @param engine The engine to use for rendering
  38722. * @param camera The camera to use for rendering
  38723. * @param size This parameter can be set to a single number or to an object with the
  38724. * following (optional) properties: precision, width, height. If a single number is passed,
  38725. * it will be used for both width and height. If an object is passed, the screenshot size
  38726. * will be derived from the parameters. The precision property is a multiplier allowing
  38727. * rendering at a higher or lower resolution
  38728. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38729. * Check your browser for supported MIME types
  38730. * @param samples Texture samples (default: 1)
  38731. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38732. * @param fileName A name for for the downloaded file.
  38733. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38734. * to the src parameter of an <img> to display it
  38735. */
  38736. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38737. /**
  38738. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38739. * Be aware Math.random() could cause collisions, but:
  38740. * "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"
  38741. * @returns a pseudo random id
  38742. */
  38743. static RandomId(): string;
  38744. /**
  38745. * Test if the given uri is a base64 string
  38746. * @param uri The uri to test
  38747. * @return True if the uri is a base64 string or false otherwise
  38748. */
  38749. static IsBase64(uri: string): boolean;
  38750. /**
  38751. * Decode the given base64 uri.
  38752. * @param uri The uri to decode
  38753. * @return The decoded base64 data.
  38754. */
  38755. static DecodeBase64(uri: string): ArrayBuffer;
  38756. /**
  38757. * Gets the absolute url.
  38758. * @param url the input url
  38759. * @return the absolute url
  38760. */
  38761. static GetAbsoluteUrl(url: string): string;
  38762. /**
  38763. * No log
  38764. */
  38765. static readonly NoneLogLevel: number;
  38766. /**
  38767. * Only message logs
  38768. */
  38769. static readonly MessageLogLevel: number;
  38770. /**
  38771. * Only warning logs
  38772. */
  38773. static readonly WarningLogLevel: number;
  38774. /**
  38775. * Only error logs
  38776. */
  38777. static readonly ErrorLogLevel: number;
  38778. /**
  38779. * All logs
  38780. */
  38781. static readonly AllLogLevel: number;
  38782. /**
  38783. * Gets a value indicating the number of loading errors
  38784. * @ignorenaming
  38785. */
  38786. static get errorsCount(): number;
  38787. /**
  38788. * Callback called when a new log is added
  38789. */
  38790. static OnNewCacheEntry: (entry: string) => void;
  38791. /**
  38792. * Log a message to the console
  38793. * @param message defines the message to log
  38794. */
  38795. static Log(message: string): void;
  38796. /**
  38797. * Write a warning message to the console
  38798. * @param message defines the message to log
  38799. */
  38800. static Warn(message: string): void;
  38801. /**
  38802. * Write an error message to the console
  38803. * @param message defines the message to log
  38804. */
  38805. static Error(message: string): void;
  38806. /**
  38807. * Gets current log cache (list of logs)
  38808. */
  38809. static get LogCache(): string;
  38810. /**
  38811. * Clears the log cache
  38812. */
  38813. static ClearLogCache(): void;
  38814. /**
  38815. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38816. */
  38817. static set LogLevels(level: number);
  38818. /**
  38819. * Checks if the window object exists
  38820. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38821. */
  38822. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38823. /**
  38824. * No performance log
  38825. */
  38826. static readonly PerformanceNoneLogLevel: number;
  38827. /**
  38828. * Use user marks to log performance
  38829. */
  38830. static readonly PerformanceUserMarkLogLevel: number;
  38831. /**
  38832. * Log performance to the console
  38833. */
  38834. static readonly PerformanceConsoleLogLevel: number;
  38835. private static _performance;
  38836. /**
  38837. * Sets the current performance log level
  38838. */
  38839. static set PerformanceLogLevel(level: number);
  38840. private static _StartPerformanceCounterDisabled;
  38841. private static _EndPerformanceCounterDisabled;
  38842. private static _StartUserMark;
  38843. private static _EndUserMark;
  38844. private static _StartPerformanceConsole;
  38845. private static _EndPerformanceConsole;
  38846. /**
  38847. * Starts a performance counter
  38848. */
  38849. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38850. /**
  38851. * Ends a specific performance coutner
  38852. */
  38853. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38854. /**
  38855. * Gets either window.performance.now() if supported or Date.now() else
  38856. */
  38857. static get Now(): number;
  38858. /**
  38859. * This method will return the name of the class used to create the instance of the given object.
  38860. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38861. * @param object the object to get the class name from
  38862. * @param isType defines if the object is actually a type
  38863. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38864. */
  38865. static GetClassName(object: any, isType?: boolean): string;
  38866. /**
  38867. * Gets the first element of an array satisfying a given predicate
  38868. * @param array defines the array to browse
  38869. * @param predicate defines the predicate to use
  38870. * @returns null if not found or the element
  38871. */
  38872. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38873. /**
  38874. * This method will return the name of the full name of the class, including its owning module (if any).
  38875. * 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).
  38876. * @param object the object to get the class name from
  38877. * @param isType defines if the object is actually a type
  38878. * @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.
  38879. * @ignorenaming
  38880. */
  38881. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38882. /**
  38883. * Returns a promise that resolves after the given amount of time.
  38884. * @param delay Number of milliseconds to delay
  38885. * @returns Promise that resolves after the given amount of time
  38886. */
  38887. static DelayAsync(delay: number): Promise<void>;
  38888. /**
  38889. * Utility function to detect if the current user agent is Safari
  38890. * @returns whether or not the current user agent is safari
  38891. */
  38892. static IsSafari(): boolean;
  38893. }
  38894. /**
  38895. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38896. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38897. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38898. * @param name The name of the class, case should be preserved
  38899. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38900. */
  38901. export function className(name: string, module?: string): (target: Object) => void;
  38902. /**
  38903. * An implementation of a loop for asynchronous functions.
  38904. */
  38905. export class AsyncLoop {
  38906. /**
  38907. * Defines the number of iterations for the loop
  38908. */
  38909. iterations: number;
  38910. /**
  38911. * Defines the current index of the loop.
  38912. */
  38913. index: number;
  38914. private _done;
  38915. private _fn;
  38916. private _successCallback;
  38917. /**
  38918. * Constructor.
  38919. * @param iterations the number of iterations.
  38920. * @param func the function to run each iteration
  38921. * @param successCallback the callback that will be called upon succesful execution
  38922. * @param offset starting offset.
  38923. */
  38924. constructor(
  38925. /**
  38926. * Defines the number of iterations for the loop
  38927. */
  38928. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38929. /**
  38930. * Execute the next iteration. Must be called after the last iteration was finished.
  38931. */
  38932. executeNext(): void;
  38933. /**
  38934. * Break the loop and run the success callback.
  38935. */
  38936. breakLoop(): void;
  38937. /**
  38938. * Create and run an async loop.
  38939. * @param iterations the number of iterations.
  38940. * @param fn the function to run each iteration
  38941. * @param successCallback the callback that will be called upon succesful execution
  38942. * @param offset starting offset.
  38943. * @returns the created async loop object
  38944. */
  38945. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38946. /**
  38947. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38948. * @param iterations total number of iterations
  38949. * @param syncedIterations number of synchronous iterations in each async iteration.
  38950. * @param fn the function to call each iteration.
  38951. * @param callback a success call back that will be called when iterating stops.
  38952. * @param breakFunction a break condition (optional)
  38953. * @param timeout timeout settings for the setTimeout function. default - 0.
  38954. * @returns the created async loop object
  38955. */
  38956. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38957. }
  38958. }
  38959. declare module BABYLON {
  38960. /**
  38961. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38962. * The underlying implementation relies on an associative array to ensure the best performances.
  38963. * The value can be anything including 'null' but except 'undefined'
  38964. */
  38965. export class StringDictionary<T> {
  38966. /**
  38967. * This will clear this dictionary and copy the content from the 'source' one.
  38968. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38969. * @param source the dictionary to take the content from and copy to this dictionary
  38970. */
  38971. copyFrom(source: StringDictionary<T>): void;
  38972. /**
  38973. * Get a value based from its key
  38974. * @param key the given key to get the matching value from
  38975. * @return the value if found, otherwise undefined is returned
  38976. */
  38977. get(key: string): T | undefined;
  38978. /**
  38979. * Get a value from its key or add it if it doesn't exist.
  38980. * This method will ensure you that a given key/data will be present in the dictionary.
  38981. * @param key the given key to get the matching value from
  38982. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38983. * The factory will only be invoked if there's no data for the given key.
  38984. * @return the value corresponding to the key.
  38985. */
  38986. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38987. /**
  38988. * Get a value from its key if present in the dictionary otherwise add it
  38989. * @param key the key to get the value from
  38990. * @param val if there's no such key/value pair in the dictionary add it with this value
  38991. * @return the value corresponding to the key
  38992. */
  38993. getOrAdd(key: string, val: T): T;
  38994. /**
  38995. * Check if there's a given key in the dictionary
  38996. * @param key the key to check for
  38997. * @return true if the key is present, false otherwise
  38998. */
  38999. contains(key: string): boolean;
  39000. /**
  39001. * Add a new key and its corresponding value
  39002. * @param key the key to add
  39003. * @param value the value corresponding to the key
  39004. * @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
  39005. */
  39006. add(key: string, value: T): boolean;
  39007. /**
  39008. * Update a specific value associated to a key
  39009. * @param key defines the key to use
  39010. * @param value defines the value to store
  39011. * @returns true if the value was updated (or false if the key was not found)
  39012. */
  39013. set(key: string, value: T): boolean;
  39014. /**
  39015. * Get the element of the given key and remove it from the dictionary
  39016. * @param key defines the key to search
  39017. * @returns the value associated with the key or null if not found
  39018. */
  39019. getAndRemove(key: string): Nullable<T>;
  39020. /**
  39021. * Remove a key/value from the dictionary.
  39022. * @param key the key to remove
  39023. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39024. */
  39025. remove(key: string): boolean;
  39026. /**
  39027. * Clear the whole content of the dictionary
  39028. */
  39029. clear(): void;
  39030. /**
  39031. * Gets the current count
  39032. */
  39033. get count(): number;
  39034. /**
  39035. * Execute a callback on each key/val of the dictionary.
  39036. * Note that you can remove any element in this dictionary in the callback implementation
  39037. * @param callback the callback to execute on a given key/value pair
  39038. */
  39039. forEach(callback: (key: string, val: T) => void): void;
  39040. /**
  39041. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39042. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39043. * Note that you can remove any element in this dictionary in the callback implementation
  39044. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39045. * @returns the first item
  39046. */
  39047. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39048. private _count;
  39049. private _data;
  39050. }
  39051. }
  39052. declare module BABYLON {
  39053. /** @hidden */
  39054. export interface ICollisionCoordinator {
  39055. createCollider(): Collider;
  39056. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39057. init(scene: Scene): void;
  39058. }
  39059. /** @hidden */
  39060. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39061. private _scene;
  39062. private _scaledPosition;
  39063. private _scaledVelocity;
  39064. private _finalPosition;
  39065. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39066. createCollider(): Collider;
  39067. init(scene: Scene): void;
  39068. private _collideWithWorld;
  39069. }
  39070. }
  39071. declare module BABYLON {
  39072. /**
  39073. * Class used to manage all inputs for the scene.
  39074. */
  39075. export class InputManager {
  39076. /** The distance in pixel that you have to move to prevent some events */
  39077. static DragMovementThreshold: number;
  39078. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39079. static LongPressDelay: number;
  39080. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39081. static DoubleClickDelay: number;
  39082. /** If you need to check double click without raising a single click at first click, enable this flag */
  39083. static ExclusiveDoubleClickMode: boolean;
  39084. /** 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. */
  39085. private _alreadyAttached;
  39086. private _wheelEventName;
  39087. private _onPointerMove;
  39088. private _onPointerDown;
  39089. private _onPointerUp;
  39090. private _initClickEvent;
  39091. private _initActionManager;
  39092. private _delayedSimpleClick;
  39093. private _delayedSimpleClickTimeout;
  39094. private _previousDelayedSimpleClickTimeout;
  39095. private _meshPickProceed;
  39096. private _previousButtonPressed;
  39097. private _currentPickResult;
  39098. private _previousPickResult;
  39099. private _totalPointersPressed;
  39100. private _doubleClickOccured;
  39101. private _pointerOverMesh;
  39102. private _pickedDownMesh;
  39103. private _pickedUpMesh;
  39104. private _pointerX;
  39105. private _pointerY;
  39106. private _unTranslatedPointerX;
  39107. private _unTranslatedPointerY;
  39108. private _startingPointerPosition;
  39109. private _previousStartingPointerPosition;
  39110. private _startingPointerTime;
  39111. private _previousStartingPointerTime;
  39112. private _pointerCaptures;
  39113. private _meshUnderPointerId;
  39114. private _onKeyDown;
  39115. private _onKeyUp;
  39116. private _onCanvasFocusObserver;
  39117. private _onCanvasBlurObserver;
  39118. private _scene;
  39119. /**
  39120. * Creates a new InputManager
  39121. * @param scene defines the hosting scene
  39122. */
  39123. constructor(scene: Scene);
  39124. /**
  39125. * Gets the mesh that is currently under the pointer
  39126. */
  39127. get meshUnderPointer(): Nullable<AbstractMesh>;
  39128. /**
  39129. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39130. * @param pointerId the pointer id to use
  39131. * @returns The mesh under this pointer id or null if not found
  39132. */
  39133. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39134. /**
  39135. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39136. */
  39137. get unTranslatedPointer(): Vector2;
  39138. /**
  39139. * Gets or sets the current on-screen X position of the pointer
  39140. */
  39141. get pointerX(): number;
  39142. set pointerX(value: number);
  39143. /**
  39144. * Gets or sets the current on-screen Y position of the pointer
  39145. */
  39146. get pointerY(): number;
  39147. set pointerY(value: number);
  39148. private _updatePointerPosition;
  39149. private _processPointerMove;
  39150. private _setRayOnPointerInfo;
  39151. private _checkPrePointerObservable;
  39152. /**
  39153. * Use this method to simulate a pointer move on a mesh
  39154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39157. */
  39158. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39159. /**
  39160. * Use this method to simulate a pointer down on a mesh
  39161. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39162. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39163. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39164. */
  39165. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39166. private _processPointerDown;
  39167. /** @hidden */
  39168. _isPointerSwiping(): boolean;
  39169. /**
  39170. * Use this method to simulate a pointer up on a mesh
  39171. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39172. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39173. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39174. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39175. */
  39176. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39177. private _processPointerUp;
  39178. /**
  39179. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39180. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39181. * @returns true if the pointer was captured
  39182. */
  39183. isPointerCaptured(pointerId?: number): boolean;
  39184. /**
  39185. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39186. * @param attachUp defines if you want to attach events to pointerup
  39187. * @param attachDown defines if you want to attach events to pointerdown
  39188. * @param attachMove defines if you want to attach events to pointermove
  39189. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39190. */
  39191. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39192. /**
  39193. * Detaches all event handlers
  39194. */
  39195. detachControl(): void;
  39196. /**
  39197. * Force the value of meshUnderPointer
  39198. * @param mesh defines the mesh to use
  39199. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39200. */
  39201. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39202. /**
  39203. * Gets the mesh under the pointer
  39204. * @returns a Mesh or null if no mesh is under the pointer
  39205. */
  39206. getPointerOverMesh(): Nullable<AbstractMesh>;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. /**
  39211. * This class defines the direct association between an animation and a target
  39212. */
  39213. export class TargetedAnimation {
  39214. /**
  39215. * Animation to perform
  39216. */
  39217. animation: Animation;
  39218. /**
  39219. * Target to animate
  39220. */
  39221. target: any;
  39222. /**
  39223. * Returns the string "TargetedAnimation"
  39224. * @returns "TargetedAnimation"
  39225. */
  39226. getClassName(): string;
  39227. /**
  39228. * Serialize the object
  39229. * @returns the JSON object representing the current entity
  39230. */
  39231. serialize(): any;
  39232. }
  39233. /**
  39234. * Use this class to create coordinated animations on multiple targets
  39235. */
  39236. export class AnimationGroup implements IDisposable {
  39237. /** The name of the animation group */
  39238. name: string;
  39239. private _scene;
  39240. private _targetedAnimations;
  39241. private _animatables;
  39242. private _from;
  39243. private _to;
  39244. private _isStarted;
  39245. private _isPaused;
  39246. private _speedRatio;
  39247. private _loopAnimation;
  39248. private _isAdditive;
  39249. /**
  39250. * Gets or sets the unique id of the node
  39251. */
  39252. uniqueId: number;
  39253. /**
  39254. * This observable will notify when one animation have ended
  39255. */
  39256. onAnimationEndObservable: Observable<TargetedAnimation>;
  39257. /**
  39258. * Observer raised when one animation loops
  39259. */
  39260. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39261. /**
  39262. * Observer raised when all animations have looped
  39263. */
  39264. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39265. /**
  39266. * This observable will notify when all animations have ended.
  39267. */
  39268. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39269. /**
  39270. * This observable will notify when all animations have paused.
  39271. */
  39272. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39273. /**
  39274. * This observable will notify when all animations are playing.
  39275. */
  39276. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39277. /**
  39278. * Gets the first frame
  39279. */
  39280. get from(): number;
  39281. /**
  39282. * Gets the last frame
  39283. */
  39284. get to(): number;
  39285. /**
  39286. * Define if the animations are started
  39287. */
  39288. get isStarted(): boolean;
  39289. /**
  39290. * Gets a value indicating that the current group is playing
  39291. */
  39292. get isPlaying(): boolean;
  39293. /**
  39294. * Gets or sets the speed ratio to use for all animations
  39295. */
  39296. get speedRatio(): number;
  39297. /**
  39298. * Gets or sets the speed ratio to use for all animations
  39299. */
  39300. set speedRatio(value: number);
  39301. /**
  39302. * Gets or sets if all animations should loop or not
  39303. */
  39304. get loopAnimation(): boolean;
  39305. set loopAnimation(value: boolean);
  39306. /**
  39307. * Gets or sets if all animations should be evaluated additively
  39308. */
  39309. get isAdditive(): boolean;
  39310. set isAdditive(value: boolean);
  39311. /**
  39312. * Gets the targeted animations for this animation group
  39313. */
  39314. get targetedAnimations(): Array<TargetedAnimation>;
  39315. /**
  39316. * returning the list of animatables controlled by this animation group.
  39317. */
  39318. get animatables(): Array<Animatable>;
  39319. /**
  39320. * Gets the list of target animations
  39321. */
  39322. get children(): TargetedAnimation[];
  39323. /**
  39324. * Instantiates a new Animation Group.
  39325. * This helps managing several animations at once.
  39326. * @see https://doc.babylonjs.com/how_to/group
  39327. * @param name Defines the name of the group
  39328. * @param scene Defines the scene the group belongs to
  39329. */
  39330. constructor(
  39331. /** The name of the animation group */
  39332. name: string, scene?: Nullable<Scene>);
  39333. /**
  39334. * Add an animation (with its target) in the group
  39335. * @param animation defines the animation we want to add
  39336. * @param target defines the target of the animation
  39337. * @returns the TargetedAnimation object
  39338. */
  39339. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39340. /**
  39341. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39342. * It can add constant keys at begin or end
  39343. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39344. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39345. * @returns the animation group
  39346. */
  39347. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39348. private _animationLoopCount;
  39349. private _animationLoopFlags;
  39350. private _processLoop;
  39351. /**
  39352. * Start all animations on given targets
  39353. * @param loop defines if animations must loop
  39354. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39355. * @param from defines the from key (optional)
  39356. * @param to defines the to key (optional)
  39357. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39358. * @returns the current animation group
  39359. */
  39360. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39361. /**
  39362. * Pause all animations
  39363. * @returns the animation group
  39364. */
  39365. pause(): AnimationGroup;
  39366. /**
  39367. * Play all animations to initial state
  39368. * This function will start() the animations if they were not started or will restart() them if they were paused
  39369. * @param loop defines if animations must loop
  39370. * @returns the animation group
  39371. */
  39372. play(loop?: boolean): AnimationGroup;
  39373. /**
  39374. * Reset all animations to initial state
  39375. * @returns the animation group
  39376. */
  39377. reset(): AnimationGroup;
  39378. /**
  39379. * Restart animations from key 0
  39380. * @returns the animation group
  39381. */
  39382. restart(): AnimationGroup;
  39383. /**
  39384. * Stop all animations
  39385. * @returns the animation group
  39386. */
  39387. stop(): AnimationGroup;
  39388. /**
  39389. * Set animation weight for all animatables
  39390. * @param weight defines the weight to use
  39391. * @return the animationGroup
  39392. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39393. */
  39394. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39395. /**
  39396. * Synchronize and normalize all animatables with a source animatable
  39397. * @param root defines the root animatable to synchronize with
  39398. * @return the animationGroup
  39399. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39400. */
  39401. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39402. /**
  39403. * Goes to a specific frame in this animation group
  39404. * @param frame the frame number to go to
  39405. * @return the animationGroup
  39406. */
  39407. goToFrame(frame: number): AnimationGroup;
  39408. /**
  39409. * Dispose all associated resources
  39410. */
  39411. dispose(): void;
  39412. private _checkAnimationGroupEnded;
  39413. /**
  39414. * Clone the current animation group and returns a copy
  39415. * @param newName defines the name of the new group
  39416. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39417. * @returns the new aniamtion group
  39418. */
  39419. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39420. /**
  39421. * Serializes the animationGroup to an object
  39422. * @returns Serialized object
  39423. */
  39424. serialize(): any;
  39425. /**
  39426. * Returns a new AnimationGroup object parsed from the source provided.
  39427. * @param parsedAnimationGroup defines the source
  39428. * @param scene defines the scene that will receive the animationGroup
  39429. * @returns a new AnimationGroup
  39430. */
  39431. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39432. /**
  39433. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39434. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39435. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39436. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39437. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39438. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39439. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39440. */
  39441. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39442. /**
  39443. * Returns the string "AnimationGroup"
  39444. * @returns "AnimationGroup"
  39445. */
  39446. getClassName(): string;
  39447. /**
  39448. * Creates a detailled string about the object
  39449. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39450. * @returns a string representing the object
  39451. */
  39452. toString(fullDetails?: boolean): string;
  39453. }
  39454. }
  39455. declare module BABYLON {
  39456. /**
  39457. * Define an interface for all classes that will hold resources
  39458. */
  39459. export interface IDisposable {
  39460. /**
  39461. * Releases all held resources
  39462. */
  39463. dispose(): void;
  39464. }
  39465. /** Interface defining initialization parameters for Scene class */
  39466. export interface SceneOptions {
  39467. /**
  39468. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39469. * It will improve performance when the number of geometries becomes important.
  39470. */
  39471. useGeometryUniqueIdsMap?: boolean;
  39472. /**
  39473. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39474. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39475. */
  39476. useMaterialMeshMap?: boolean;
  39477. /**
  39478. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39479. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39480. */
  39481. useClonedMeshMap?: boolean;
  39482. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39483. virtual?: boolean;
  39484. }
  39485. /**
  39486. * Represents a scene to be rendered by the engine.
  39487. * @see https://doc.babylonjs.com/features/scene
  39488. */
  39489. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39490. /** The fog is deactivated */
  39491. static readonly FOGMODE_NONE: number;
  39492. /** The fog density is following an exponential function */
  39493. static readonly FOGMODE_EXP: number;
  39494. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39495. static readonly FOGMODE_EXP2: number;
  39496. /** The fog density is following a linear function. */
  39497. static readonly FOGMODE_LINEAR: number;
  39498. /**
  39499. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39500. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39501. */
  39502. static MinDeltaTime: number;
  39503. /**
  39504. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39505. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39506. */
  39507. static MaxDeltaTime: number;
  39508. /**
  39509. * Factory used to create the default material.
  39510. * @param name The name of the material to create
  39511. * @param scene The scene to create the material for
  39512. * @returns The default material
  39513. */
  39514. static DefaultMaterialFactory(scene: Scene): Material;
  39515. /**
  39516. * Factory used to create the a collision coordinator.
  39517. * @returns The collision coordinator
  39518. */
  39519. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39520. /** @hidden */
  39521. _inputManager: InputManager;
  39522. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39523. cameraToUseForPointers: Nullable<Camera>;
  39524. /** @hidden */
  39525. readonly _isScene: boolean;
  39526. /** @hidden */
  39527. _blockEntityCollection: boolean;
  39528. /**
  39529. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39530. */
  39531. autoClear: boolean;
  39532. /**
  39533. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39534. */
  39535. autoClearDepthAndStencil: boolean;
  39536. /**
  39537. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39538. */
  39539. clearColor: Color4;
  39540. /**
  39541. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39542. */
  39543. ambientColor: Color3;
  39544. /**
  39545. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39546. * It should only be one of the following (if not the default embedded one):
  39547. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39548. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39549. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39550. * The material properties need to be setup according to the type of texture in use.
  39551. */
  39552. environmentBRDFTexture: BaseTexture;
  39553. /**
  39554. * Texture used in all pbr material as the reflection texture.
  39555. * As in the majority of the scene they are the same (exception for multi room and so on),
  39556. * this is easier to reference from here than from all the materials.
  39557. */
  39558. get environmentTexture(): Nullable<BaseTexture>;
  39559. /**
  39560. * Texture used in all pbr material as the reflection texture.
  39561. * As in the majority of the scene they are the same (exception for multi room and so on),
  39562. * this is easier to set here than in all the materials.
  39563. */
  39564. set environmentTexture(value: Nullable<BaseTexture>);
  39565. /** @hidden */
  39566. protected _environmentIntensity: number;
  39567. /**
  39568. * Intensity of the environment in all pbr material.
  39569. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39570. * As in the majority of the scene they are the same (exception for multi room and so on),
  39571. * this is easier to reference from here than from all the materials.
  39572. */
  39573. get environmentIntensity(): number;
  39574. /**
  39575. * Intensity of the environment in all pbr material.
  39576. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39577. * As in the majority of the scene they are the same (exception for multi room and so on),
  39578. * this is easier to set here than in all the materials.
  39579. */
  39580. set environmentIntensity(value: number);
  39581. /** @hidden */
  39582. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39583. /**
  39584. * Default image processing configuration used either in the rendering
  39585. * Forward main pass or through the imageProcessingPostProcess if present.
  39586. * As in the majority of the scene they are the same (exception for multi camera),
  39587. * this is easier to reference from here than from all the materials and post process.
  39588. *
  39589. * No setter as we it is a shared configuration, you can set the values instead.
  39590. */
  39591. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39592. private _forceWireframe;
  39593. /**
  39594. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39595. */
  39596. set forceWireframe(value: boolean);
  39597. get forceWireframe(): boolean;
  39598. private _skipFrustumClipping;
  39599. /**
  39600. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39601. */
  39602. set skipFrustumClipping(value: boolean);
  39603. get skipFrustumClipping(): boolean;
  39604. private _forcePointsCloud;
  39605. /**
  39606. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39607. */
  39608. set forcePointsCloud(value: boolean);
  39609. get forcePointsCloud(): boolean;
  39610. /**
  39611. * Gets or sets the active clipplane 1
  39612. */
  39613. clipPlane: Nullable<Plane>;
  39614. /**
  39615. * Gets or sets the active clipplane 2
  39616. */
  39617. clipPlane2: Nullable<Plane>;
  39618. /**
  39619. * Gets or sets the active clipplane 3
  39620. */
  39621. clipPlane3: Nullable<Plane>;
  39622. /**
  39623. * Gets or sets the active clipplane 4
  39624. */
  39625. clipPlane4: Nullable<Plane>;
  39626. /**
  39627. * Gets or sets the active clipplane 5
  39628. */
  39629. clipPlane5: Nullable<Plane>;
  39630. /**
  39631. * Gets or sets the active clipplane 6
  39632. */
  39633. clipPlane6: Nullable<Plane>;
  39634. /**
  39635. * Gets or sets a boolean indicating if animations are enabled
  39636. */
  39637. animationsEnabled: boolean;
  39638. private _animationPropertiesOverride;
  39639. /**
  39640. * Gets or sets the animation properties override
  39641. */
  39642. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39643. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39644. /**
  39645. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39646. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39647. */
  39648. useConstantAnimationDeltaTime: boolean;
  39649. /**
  39650. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39651. * Please note that it requires to run a ray cast through the scene on every frame
  39652. */
  39653. constantlyUpdateMeshUnderPointer: boolean;
  39654. /**
  39655. * Defines the HTML cursor to use when hovering over interactive elements
  39656. */
  39657. hoverCursor: string;
  39658. /**
  39659. * Defines the HTML default cursor to use (empty by default)
  39660. */
  39661. defaultCursor: string;
  39662. /**
  39663. * Defines whether cursors are handled by the scene.
  39664. */
  39665. doNotHandleCursors: boolean;
  39666. /**
  39667. * This is used to call preventDefault() on pointer down
  39668. * in order to block unwanted artifacts like system double clicks
  39669. */
  39670. preventDefaultOnPointerDown: boolean;
  39671. /**
  39672. * This is used to call preventDefault() on pointer up
  39673. * in order to block unwanted artifacts like system double clicks
  39674. */
  39675. preventDefaultOnPointerUp: boolean;
  39676. /**
  39677. * Gets or sets user defined metadata
  39678. */
  39679. metadata: any;
  39680. /**
  39681. * For internal use only. Please do not use.
  39682. */
  39683. reservedDataStore: any;
  39684. /**
  39685. * Gets the name of the plugin used to load this scene (null by default)
  39686. */
  39687. loadingPluginName: string;
  39688. /**
  39689. * Use this array to add regular expressions used to disable offline support for specific urls
  39690. */
  39691. disableOfflineSupportExceptionRules: RegExp[];
  39692. /**
  39693. * An event triggered when the scene is disposed.
  39694. */
  39695. onDisposeObservable: Observable<Scene>;
  39696. private _onDisposeObserver;
  39697. /** Sets a function to be executed when this scene is disposed. */
  39698. set onDispose(callback: () => void);
  39699. /**
  39700. * An event triggered before rendering the scene (right after animations and physics)
  39701. */
  39702. onBeforeRenderObservable: Observable<Scene>;
  39703. private _onBeforeRenderObserver;
  39704. /** Sets a function to be executed before rendering this scene */
  39705. set beforeRender(callback: Nullable<() => void>);
  39706. /**
  39707. * An event triggered after rendering the scene
  39708. */
  39709. onAfterRenderObservable: Observable<Scene>;
  39710. /**
  39711. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39712. */
  39713. onAfterRenderCameraObservable: Observable<Camera>;
  39714. private _onAfterRenderObserver;
  39715. /** Sets a function to be executed after rendering this scene */
  39716. set afterRender(callback: Nullable<() => void>);
  39717. /**
  39718. * An event triggered before animating the scene
  39719. */
  39720. onBeforeAnimationsObservable: Observable<Scene>;
  39721. /**
  39722. * An event triggered after animations processing
  39723. */
  39724. onAfterAnimationsObservable: Observable<Scene>;
  39725. /**
  39726. * An event triggered before draw calls are ready to be sent
  39727. */
  39728. onBeforeDrawPhaseObservable: Observable<Scene>;
  39729. /**
  39730. * An event triggered after draw calls have been sent
  39731. */
  39732. onAfterDrawPhaseObservable: Observable<Scene>;
  39733. /**
  39734. * An event triggered when the scene is ready
  39735. */
  39736. onReadyObservable: Observable<Scene>;
  39737. /**
  39738. * An event triggered before rendering a camera
  39739. */
  39740. onBeforeCameraRenderObservable: Observable<Camera>;
  39741. private _onBeforeCameraRenderObserver;
  39742. /** Sets a function to be executed before rendering a camera*/
  39743. set beforeCameraRender(callback: () => void);
  39744. /**
  39745. * An event triggered after rendering a camera
  39746. */
  39747. onAfterCameraRenderObservable: Observable<Camera>;
  39748. private _onAfterCameraRenderObserver;
  39749. /** Sets a function to be executed after rendering a camera*/
  39750. set afterCameraRender(callback: () => void);
  39751. /**
  39752. * An event triggered when active meshes evaluation is about to start
  39753. */
  39754. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39755. /**
  39756. * An event triggered when active meshes evaluation is done
  39757. */
  39758. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39759. /**
  39760. * An event triggered when particles rendering is about to start
  39761. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39762. */
  39763. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39764. /**
  39765. * An event triggered when particles rendering is done
  39766. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39767. */
  39768. onAfterParticlesRenderingObservable: Observable<Scene>;
  39769. /**
  39770. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39771. */
  39772. onDataLoadedObservable: Observable<Scene>;
  39773. /**
  39774. * An event triggered when a camera is created
  39775. */
  39776. onNewCameraAddedObservable: Observable<Camera>;
  39777. /**
  39778. * An event triggered when a camera is removed
  39779. */
  39780. onCameraRemovedObservable: Observable<Camera>;
  39781. /**
  39782. * An event triggered when a light is created
  39783. */
  39784. onNewLightAddedObservable: Observable<Light>;
  39785. /**
  39786. * An event triggered when a light is removed
  39787. */
  39788. onLightRemovedObservable: Observable<Light>;
  39789. /**
  39790. * An event triggered when a geometry is created
  39791. */
  39792. onNewGeometryAddedObservable: Observable<Geometry>;
  39793. /**
  39794. * An event triggered when a geometry is removed
  39795. */
  39796. onGeometryRemovedObservable: Observable<Geometry>;
  39797. /**
  39798. * An event triggered when a transform node is created
  39799. */
  39800. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39801. /**
  39802. * An event triggered when a transform node is removed
  39803. */
  39804. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39805. /**
  39806. * An event triggered when a mesh is created
  39807. */
  39808. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39809. /**
  39810. * An event triggered when a mesh is removed
  39811. */
  39812. onMeshRemovedObservable: Observable<AbstractMesh>;
  39813. /**
  39814. * An event triggered when a skeleton is created
  39815. */
  39816. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39817. /**
  39818. * An event triggered when a skeleton is removed
  39819. */
  39820. onSkeletonRemovedObservable: Observable<Skeleton>;
  39821. /**
  39822. * An event triggered when a material is created
  39823. */
  39824. onNewMaterialAddedObservable: Observable<Material>;
  39825. /**
  39826. * An event triggered when a material is removed
  39827. */
  39828. onMaterialRemovedObservable: Observable<Material>;
  39829. /**
  39830. * An event triggered when a texture is created
  39831. */
  39832. onNewTextureAddedObservable: Observable<BaseTexture>;
  39833. /**
  39834. * An event triggered when a texture is removed
  39835. */
  39836. onTextureRemovedObservable: Observable<BaseTexture>;
  39837. /**
  39838. * An event triggered when render targets are about to be rendered
  39839. * Can happen multiple times per frame.
  39840. */
  39841. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39842. /**
  39843. * An event triggered when render targets were rendered.
  39844. * Can happen multiple times per frame.
  39845. */
  39846. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39847. /**
  39848. * An event triggered before calculating deterministic simulation step
  39849. */
  39850. onBeforeStepObservable: Observable<Scene>;
  39851. /**
  39852. * An event triggered after calculating deterministic simulation step
  39853. */
  39854. onAfterStepObservable: Observable<Scene>;
  39855. /**
  39856. * An event triggered when the activeCamera property is updated
  39857. */
  39858. onActiveCameraChanged: Observable<Scene>;
  39859. /**
  39860. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39861. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39862. * 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)
  39863. */
  39864. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39865. /**
  39866. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39867. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39868. * 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)
  39869. */
  39870. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39871. /**
  39872. * This Observable will when a mesh has been imported into the scene.
  39873. */
  39874. onMeshImportedObservable: Observable<AbstractMesh>;
  39875. /**
  39876. * This Observable will when an animation file has been imported into the scene.
  39877. */
  39878. onAnimationFileImportedObservable: Observable<Scene>;
  39879. /**
  39880. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39881. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39882. */
  39883. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39884. /** @hidden */
  39885. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39886. /**
  39887. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39888. */
  39889. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39890. /**
  39891. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39892. */
  39893. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39894. /**
  39895. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39896. */
  39897. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39898. /** Callback called when a pointer move is detected */
  39899. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39900. /** Callback called when a pointer down is detected */
  39901. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39902. /** Callback called when a pointer up is detected */
  39903. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39904. /** Callback called when a pointer pick is detected */
  39905. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39906. /**
  39907. * 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).
  39908. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39909. */
  39910. onPrePointerObservable: Observable<PointerInfoPre>;
  39911. /**
  39912. * Observable event triggered each time an input event is received from the rendering canvas
  39913. */
  39914. onPointerObservable: Observable<PointerInfo>;
  39915. /**
  39916. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39917. */
  39918. get unTranslatedPointer(): Vector2;
  39919. /**
  39920. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39921. */
  39922. static get DragMovementThreshold(): number;
  39923. static set DragMovementThreshold(value: number);
  39924. /**
  39925. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39926. */
  39927. static get LongPressDelay(): number;
  39928. static set LongPressDelay(value: number);
  39929. /**
  39930. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39931. */
  39932. static get DoubleClickDelay(): number;
  39933. static set DoubleClickDelay(value: number);
  39934. /** If you need to check double click without raising a single click at first click, enable this flag */
  39935. static get ExclusiveDoubleClickMode(): boolean;
  39936. static set ExclusiveDoubleClickMode(value: boolean);
  39937. /** @hidden */
  39938. _mirroredCameraPosition: Nullable<Vector3>;
  39939. /**
  39940. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39941. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39942. */
  39943. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39944. /**
  39945. * Observable event triggered each time an keyboard event is received from the hosting window
  39946. */
  39947. onKeyboardObservable: Observable<KeyboardInfo>;
  39948. private _useRightHandedSystem;
  39949. /**
  39950. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39951. */
  39952. set useRightHandedSystem(value: boolean);
  39953. get useRightHandedSystem(): boolean;
  39954. private _timeAccumulator;
  39955. private _currentStepId;
  39956. private _currentInternalStep;
  39957. /**
  39958. * Sets the step Id used by deterministic lock step
  39959. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39960. * @param newStepId defines the step Id
  39961. */
  39962. setStepId(newStepId: number): void;
  39963. /**
  39964. * Gets the step Id used by deterministic lock step
  39965. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39966. * @returns the step Id
  39967. */
  39968. getStepId(): number;
  39969. /**
  39970. * Gets the internal step used by deterministic lock step
  39971. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39972. * @returns the internal step
  39973. */
  39974. getInternalStep(): number;
  39975. private _fogEnabled;
  39976. /**
  39977. * Gets or sets a boolean indicating if fog is enabled on this scene
  39978. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39979. * (Default is true)
  39980. */
  39981. set fogEnabled(value: boolean);
  39982. get fogEnabled(): boolean;
  39983. private _fogMode;
  39984. /**
  39985. * Gets or sets the fog mode to use
  39986. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39987. * | mode | value |
  39988. * | --- | --- |
  39989. * | FOGMODE_NONE | 0 |
  39990. * | FOGMODE_EXP | 1 |
  39991. * | FOGMODE_EXP2 | 2 |
  39992. * | FOGMODE_LINEAR | 3 |
  39993. */
  39994. set fogMode(value: number);
  39995. get fogMode(): number;
  39996. /**
  39997. * Gets or sets the fog color to use
  39998. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39999. * (Default is Color3(0.2, 0.2, 0.3))
  40000. */
  40001. fogColor: Color3;
  40002. /**
  40003. * Gets or sets the fog density to use
  40004. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40005. * (Default is 0.1)
  40006. */
  40007. fogDensity: number;
  40008. /**
  40009. * Gets or sets the fog start distance to use
  40010. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40011. * (Default is 0)
  40012. */
  40013. fogStart: number;
  40014. /**
  40015. * Gets or sets the fog end distance to use
  40016. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40017. * (Default is 1000)
  40018. */
  40019. fogEnd: number;
  40020. /**
  40021. * Flag indicating that the frame buffer binding is handled by another component
  40022. */
  40023. prePass: boolean;
  40024. private _shadowsEnabled;
  40025. /**
  40026. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40027. */
  40028. set shadowsEnabled(value: boolean);
  40029. get shadowsEnabled(): boolean;
  40030. private _lightsEnabled;
  40031. /**
  40032. * Gets or sets a boolean indicating if lights are enabled on this scene
  40033. */
  40034. set lightsEnabled(value: boolean);
  40035. get lightsEnabled(): boolean;
  40036. /** All of the active cameras added to this scene. */
  40037. activeCameras: Camera[];
  40038. /** @hidden */
  40039. _activeCamera: Nullable<Camera>;
  40040. /** Gets or sets the current active camera */
  40041. get activeCamera(): Nullable<Camera>;
  40042. set activeCamera(value: Nullable<Camera>);
  40043. private _defaultMaterial;
  40044. /** The default material used on meshes when no material is affected */
  40045. get defaultMaterial(): Material;
  40046. /** The default material used on meshes when no material is affected */
  40047. set defaultMaterial(value: Material);
  40048. private _texturesEnabled;
  40049. /**
  40050. * Gets or sets a boolean indicating if textures are enabled on this scene
  40051. */
  40052. set texturesEnabled(value: boolean);
  40053. get texturesEnabled(): boolean;
  40054. /**
  40055. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40056. */
  40057. physicsEnabled: boolean;
  40058. /**
  40059. * Gets or sets a boolean indicating if particles are enabled on this scene
  40060. */
  40061. particlesEnabled: boolean;
  40062. /**
  40063. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40064. */
  40065. spritesEnabled: boolean;
  40066. private _skeletonsEnabled;
  40067. /**
  40068. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40069. */
  40070. set skeletonsEnabled(value: boolean);
  40071. get skeletonsEnabled(): boolean;
  40072. /**
  40073. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40074. */
  40075. lensFlaresEnabled: boolean;
  40076. /**
  40077. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40078. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40079. */
  40080. collisionsEnabled: boolean;
  40081. private _collisionCoordinator;
  40082. /** @hidden */
  40083. get collisionCoordinator(): ICollisionCoordinator;
  40084. /**
  40085. * Defines the gravity applied to this scene (used only for collisions)
  40086. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40087. */
  40088. gravity: Vector3;
  40089. /**
  40090. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40091. */
  40092. postProcessesEnabled: boolean;
  40093. /**
  40094. * Gets the current postprocess manager
  40095. */
  40096. postProcessManager: PostProcessManager;
  40097. /**
  40098. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40099. */
  40100. renderTargetsEnabled: boolean;
  40101. /**
  40102. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40103. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40104. */
  40105. dumpNextRenderTargets: boolean;
  40106. /**
  40107. * The list of user defined render targets added to the scene
  40108. */
  40109. customRenderTargets: RenderTargetTexture[];
  40110. /**
  40111. * Defines if texture loading must be delayed
  40112. * If true, textures will only be loaded when they need to be rendered
  40113. */
  40114. useDelayedTextureLoading: boolean;
  40115. /**
  40116. * Gets the list of meshes imported to the scene through SceneLoader
  40117. */
  40118. importedMeshesFiles: String[];
  40119. /**
  40120. * Gets or sets a boolean indicating if probes are enabled on this scene
  40121. */
  40122. probesEnabled: boolean;
  40123. /**
  40124. * Gets or sets the current offline provider to use to store scene data
  40125. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40126. */
  40127. offlineProvider: IOfflineProvider;
  40128. /**
  40129. * Gets or sets the action manager associated with the scene
  40130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40131. */
  40132. actionManager: AbstractActionManager;
  40133. private _meshesForIntersections;
  40134. /**
  40135. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40136. */
  40137. proceduralTexturesEnabled: boolean;
  40138. private _engine;
  40139. private _totalVertices;
  40140. /** @hidden */
  40141. _activeIndices: PerfCounter;
  40142. /** @hidden */
  40143. _activeParticles: PerfCounter;
  40144. /** @hidden */
  40145. _activeBones: PerfCounter;
  40146. private _animationRatio;
  40147. /** @hidden */
  40148. _animationTimeLast: number;
  40149. /** @hidden */
  40150. _animationTime: number;
  40151. /**
  40152. * Gets or sets a general scale for animation speed
  40153. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40154. */
  40155. animationTimeScale: number;
  40156. /** @hidden */
  40157. _cachedMaterial: Nullable<Material>;
  40158. /** @hidden */
  40159. _cachedEffect: Nullable<Effect>;
  40160. /** @hidden */
  40161. _cachedVisibility: Nullable<number>;
  40162. private _renderId;
  40163. private _frameId;
  40164. private _executeWhenReadyTimeoutId;
  40165. private _intermediateRendering;
  40166. private _viewUpdateFlag;
  40167. private _projectionUpdateFlag;
  40168. /** @hidden */
  40169. _toBeDisposed: Nullable<IDisposable>[];
  40170. private _activeRequests;
  40171. /** @hidden */
  40172. _pendingData: any[];
  40173. private _isDisposed;
  40174. /**
  40175. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40176. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40177. */
  40178. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40179. private _activeMeshes;
  40180. private _processedMaterials;
  40181. private _renderTargets;
  40182. /** @hidden */
  40183. _activeParticleSystems: SmartArray<IParticleSystem>;
  40184. private _activeSkeletons;
  40185. private _softwareSkinnedMeshes;
  40186. private _renderingManager;
  40187. /** @hidden */
  40188. _activeAnimatables: Animatable[];
  40189. private _transformMatrix;
  40190. private _sceneUbo;
  40191. /** @hidden */
  40192. _viewMatrix: Matrix;
  40193. private _projectionMatrix;
  40194. /** @hidden */
  40195. _forcedViewPosition: Nullable<Vector3>;
  40196. /** @hidden */
  40197. _frustumPlanes: Plane[];
  40198. /**
  40199. * Gets the list of frustum planes (built from the active camera)
  40200. */
  40201. get frustumPlanes(): Plane[];
  40202. /**
  40203. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40204. * This is useful if there are more lights that the maximum simulteanous authorized
  40205. */
  40206. requireLightSorting: boolean;
  40207. /** @hidden */
  40208. readonly useMaterialMeshMap: boolean;
  40209. /** @hidden */
  40210. readonly useClonedMeshMap: boolean;
  40211. private _externalData;
  40212. private _uid;
  40213. /**
  40214. * @hidden
  40215. * Backing store of defined scene components.
  40216. */
  40217. _components: ISceneComponent[];
  40218. /**
  40219. * @hidden
  40220. * Backing store of defined scene components.
  40221. */
  40222. _serializableComponents: ISceneSerializableComponent[];
  40223. /**
  40224. * List of components to register on the next registration step.
  40225. */
  40226. private _transientComponents;
  40227. /**
  40228. * Registers the transient components if needed.
  40229. */
  40230. private _registerTransientComponents;
  40231. /**
  40232. * @hidden
  40233. * Add a component to the scene.
  40234. * Note that the ccomponent could be registered on th next frame if this is called after
  40235. * the register component stage.
  40236. * @param component Defines the component to add to the scene
  40237. */
  40238. _addComponent(component: ISceneComponent): void;
  40239. /**
  40240. * @hidden
  40241. * Gets a component from the scene.
  40242. * @param name defines the name of the component to retrieve
  40243. * @returns the component or null if not present
  40244. */
  40245. _getComponent(name: string): Nullable<ISceneComponent>;
  40246. /**
  40247. * @hidden
  40248. * Defines the actions happening before camera updates.
  40249. */
  40250. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40251. /**
  40252. * @hidden
  40253. * Defines the actions happening before clear the canvas.
  40254. */
  40255. _beforeClearStage: Stage<SimpleStageAction>;
  40256. /**
  40257. * @hidden
  40258. * Defines the actions when collecting render targets for the frame.
  40259. */
  40260. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40261. /**
  40262. * @hidden
  40263. * Defines the actions happening for one camera in the frame.
  40264. */
  40265. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40266. /**
  40267. * @hidden
  40268. * Defines the actions happening during the per mesh ready checks.
  40269. */
  40270. _isReadyForMeshStage: Stage<MeshStageAction>;
  40271. /**
  40272. * @hidden
  40273. * Defines the actions happening before evaluate active mesh checks.
  40274. */
  40275. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40276. /**
  40277. * @hidden
  40278. * Defines the actions happening during the evaluate sub mesh checks.
  40279. */
  40280. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40281. /**
  40282. * @hidden
  40283. * Defines the actions happening during the active mesh stage.
  40284. */
  40285. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40286. /**
  40287. * @hidden
  40288. * Defines the actions happening during the per camera render target step.
  40289. */
  40290. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40291. /**
  40292. * @hidden
  40293. * Defines the actions happening just before the active camera is drawing.
  40294. */
  40295. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40296. /**
  40297. * @hidden
  40298. * Defines the actions happening just before a render target is drawing.
  40299. */
  40300. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40301. /**
  40302. * @hidden
  40303. * Defines the actions happening just before a rendering group is drawing.
  40304. */
  40305. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40306. /**
  40307. * @hidden
  40308. * Defines the actions happening just before a mesh is drawing.
  40309. */
  40310. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40311. /**
  40312. * @hidden
  40313. * Defines the actions happening just after a mesh has been drawn.
  40314. */
  40315. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40316. /**
  40317. * @hidden
  40318. * Defines the actions happening just after a rendering group has been drawn.
  40319. */
  40320. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40321. /**
  40322. * @hidden
  40323. * Defines the actions happening just after the active camera has been drawn.
  40324. */
  40325. _afterCameraDrawStage: Stage<CameraStageAction>;
  40326. /**
  40327. * @hidden
  40328. * Defines the actions happening just after a render target has been drawn.
  40329. */
  40330. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40331. /**
  40332. * @hidden
  40333. * Defines the actions happening just after rendering all cameras and computing intersections.
  40334. */
  40335. _afterRenderStage: Stage<SimpleStageAction>;
  40336. /**
  40337. * @hidden
  40338. * Defines the actions happening when a pointer move event happens.
  40339. */
  40340. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40341. /**
  40342. * @hidden
  40343. * Defines the actions happening when a pointer down event happens.
  40344. */
  40345. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40346. /**
  40347. * @hidden
  40348. * Defines the actions happening when a pointer up event happens.
  40349. */
  40350. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40351. /**
  40352. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40353. */
  40354. private geometriesByUniqueId;
  40355. /**
  40356. * Creates a new Scene
  40357. * @param engine defines the engine to use to render this scene
  40358. * @param options defines the scene options
  40359. */
  40360. constructor(engine: Engine, options?: SceneOptions);
  40361. /**
  40362. * Gets a string identifying the name of the class
  40363. * @returns "Scene" string
  40364. */
  40365. getClassName(): string;
  40366. private _defaultMeshCandidates;
  40367. /**
  40368. * @hidden
  40369. */
  40370. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40371. private _defaultSubMeshCandidates;
  40372. /**
  40373. * @hidden
  40374. */
  40375. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40376. /**
  40377. * Sets the default candidate providers for the scene.
  40378. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40379. * and getCollidingSubMeshCandidates to their default function
  40380. */
  40381. setDefaultCandidateProviders(): void;
  40382. /**
  40383. * Gets the mesh that is currently under the pointer
  40384. */
  40385. get meshUnderPointer(): Nullable<AbstractMesh>;
  40386. /**
  40387. * Gets or sets the current on-screen X position of the pointer
  40388. */
  40389. get pointerX(): number;
  40390. set pointerX(value: number);
  40391. /**
  40392. * Gets or sets the current on-screen Y position of the pointer
  40393. */
  40394. get pointerY(): number;
  40395. set pointerY(value: number);
  40396. /**
  40397. * Gets the cached material (ie. the latest rendered one)
  40398. * @returns the cached material
  40399. */
  40400. getCachedMaterial(): Nullable<Material>;
  40401. /**
  40402. * Gets the cached effect (ie. the latest rendered one)
  40403. * @returns the cached effect
  40404. */
  40405. getCachedEffect(): Nullable<Effect>;
  40406. /**
  40407. * Gets the cached visibility state (ie. the latest rendered one)
  40408. * @returns the cached visibility state
  40409. */
  40410. getCachedVisibility(): Nullable<number>;
  40411. /**
  40412. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40413. * @param material defines the current material
  40414. * @param effect defines the current effect
  40415. * @param visibility defines the current visibility state
  40416. * @returns true if one parameter is not cached
  40417. */
  40418. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40419. /**
  40420. * Gets the engine associated with the scene
  40421. * @returns an Engine
  40422. */
  40423. getEngine(): Engine;
  40424. /**
  40425. * Gets the total number of vertices rendered per frame
  40426. * @returns the total number of vertices rendered per frame
  40427. */
  40428. getTotalVertices(): number;
  40429. /**
  40430. * Gets the performance counter for total vertices
  40431. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40432. */
  40433. get totalVerticesPerfCounter(): PerfCounter;
  40434. /**
  40435. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40436. * @returns the total number of active indices rendered per frame
  40437. */
  40438. getActiveIndices(): number;
  40439. /**
  40440. * Gets the performance counter for active indices
  40441. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40442. */
  40443. get totalActiveIndicesPerfCounter(): PerfCounter;
  40444. /**
  40445. * Gets the total number of active particles rendered per frame
  40446. * @returns the total number of active particles rendered per frame
  40447. */
  40448. getActiveParticles(): number;
  40449. /**
  40450. * Gets the performance counter for active particles
  40451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40452. */
  40453. get activeParticlesPerfCounter(): PerfCounter;
  40454. /**
  40455. * Gets the total number of active bones rendered per frame
  40456. * @returns the total number of active bones rendered per frame
  40457. */
  40458. getActiveBones(): number;
  40459. /**
  40460. * Gets the performance counter for active bones
  40461. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40462. */
  40463. get activeBonesPerfCounter(): PerfCounter;
  40464. /**
  40465. * Gets the array of active meshes
  40466. * @returns an array of AbstractMesh
  40467. */
  40468. getActiveMeshes(): SmartArray<AbstractMesh>;
  40469. /**
  40470. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40471. * @returns a number
  40472. */
  40473. getAnimationRatio(): number;
  40474. /**
  40475. * Gets an unique Id for the current render phase
  40476. * @returns a number
  40477. */
  40478. getRenderId(): number;
  40479. /**
  40480. * Gets an unique Id for the current frame
  40481. * @returns a number
  40482. */
  40483. getFrameId(): number;
  40484. /** Call this function if you want to manually increment the render Id*/
  40485. incrementRenderId(): void;
  40486. private _createUbo;
  40487. /**
  40488. * Use this method to simulate a pointer move on a mesh
  40489. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40490. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40491. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40492. * @returns the current scene
  40493. */
  40494. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40495. /**
  40496. * Use this method to simulate a pointer down on a mesh
  40497. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40498. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40499. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40500. * @returns the current scene
  40501. */
  40502. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40503. /**
  40504. * Use this method to simulate a pointer up on a mesh
  40505. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40506. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40507. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40508. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40509. * @returns the current scene
  40510. */
  40511. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40512. /**
  40513. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40514. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40515. * @returns true if the pointer was captured
  40516. */
  40517. isPointerCaptured(pointerId?: number): boolean;
  40518. /**
  40519. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40520. * @param attachUp defines if you want to attach events to pointerup
  40521. * @param attachDown defines if you want to attach events to pointerdown
  40522. * @param attachMove defines if you want to attach events to pointermove
  40523. */
  40524. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40525. /** Detaches all event handlers*/
  40526. detachControl(): void;
  40527. /**
  40528. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40529. * Delay loaded resources are not taking in account
  40530. * @return true if all required resources are ready
  40531. */
  40532. isReady(): boolean;
  40533. /** Resets all cached information relative to material (including effect and visibility) */
  40534. resetCachedMaterial(): void;
  40535. /**
  40536. * Registers a function to be called before every frame render
  40537. * @param func defines the function to register
  40538. */
  40539. registerBeforeRender(func: () => void): void;
  40540. /**
  40541. * Unregisters a function called before every frame render
  40542. * @param func defines the function to unregister
  40543. */
  40544. unregisterBeforeRender(func: () => void): void;
  40545. /**
  40546. * Registers a function to be called after every frame render
  40547. * @param func defines the function to register
  40548. */
  40549. registerAfterRender(func: () => void): void;
  40550. /**
  40551. * Unregisters a function called after every frame render
  40552. * @param func defines the function to unregister
  40553. */
  40554. unregisterAfterRender(func: () => void): void;
  40555. private _executeOnceBeforeRender;
  40556. /**
  40557. * The provided function will run before render once and will be disposed afterwards.
  40558. * A timeout delay can be provided so that the function will be executed in N ms.
  40559. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40560. * @param func The function to be executed.
  40561. * @param timeout optional delay in ms
  40562. */
  40563. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40564. /** @hidden */
  40565. _addPendingData(data: any): void;
  40566. /** @hidden */
  40567. _removePendingData(data: any): void;
  40568. /**
  40569. * Returns the number of items waiting to be loaded
  40570. * @returns the number of items waiting to be loaded
  40571. */
  40572. getWaitingItemsCount(): number;
  40573. /**
  40574. * Returns a boolean indicating if the scene is still loading data
  40575. */
  40576. get isLoading(): boolean;
  40577. /**
  40578. * Registers a function to be executed when the scene is ready
  40579. * @param {Function} func - the function to be executed
  40580. */
  40581. executeWhenReady(func: () => void): void;
  40582. /**
  40583. * Returns a promise that resolves when the scene is ready
  40584. * @returns A promise that resolves when the scene is ready
  40585. */
  40586. whenReadyAsync(): Promise<void>;
  40587. /** @hidden */
  40588. _checkIsReady(): void;
  40589. /**
  40590. * Gets all animatable attached to the scene
  40591. */
  40592. get animatables(): Animatable[];
  40593. /**
  40594. * Resets the last animation time frame.
  40595. * Useful to override when animations start running when loading a scene for the first time.
  40596. */
  40597. resetLastAnimationTimeFrame(): void;
  40598. /**
  40599. * Gets the current view matrix
  40600. * @returns a Matrix
  40601. */
  40602. getViewMatrix(): Matrix;
  40603. /**
  40604. * Gets the current projection matrix
  40605. * @returns a Matrix
  40606. */
  40607. getProjectionMatrix(): Matrix;
  40608. /**
  40609. * Gets the current transform matrix
  40610. * @returns a Matrix made of View * Projection
  40611. */
  40612. getTransformMatrix(): Matrix;
  40613. /**
  40614. * Sets the current transform matrix
  40615. * @param viewL defines the View matrix to use
  40616. * @param projectionL defines the Projection matrix to use
  40617. * @param viewR defines the right View matrix to use (if provided)
  40618. * @param projectionR defines the right Projection matrix to use (if provided)
  40619. */
  40620. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40621. /**
  40622. * Gets the uniform buffer used to store scene data
  40623. * @returns a UniformBuffer
  40624. */
  40625. getSceneUniformBuffer(): UniformBuffer;
  40626. /**
  40627. * Gets an unique (relatively to the current scene) Id
  40628. * @returns an unique number for the scene
  40629. */
  40630. getUniqueId(): number;
  40631. /**
  40632. * Add a mesh to the list of scene's meshes
  40633. * @param newMesh defines the mesh to add
  40634. * @param recursive if all child meshes should also be added to the scene
  40635. */
  40636. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40637. /**
  40638. * Remove a mesh for the list of scene's meshes
  40639. * @param toRemove defines the mesh to remove
  40640. * @param recursive if all child meshes should also be removed from the scene
  40641. * @returns the index where the mesh was in the mesh list
  40642. */
  40643. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40644. /**
  40645. * Add a transform node to the list of scene's transform nodes
  40646. * @param newTransformNode defines the transform node to add
  40647. */
  40648. addTransformNode(newTransformNode: TransformNode): void;
  40649. /**
  40650. * Remove a transform node for the list of scene's transform nodes
  40651. * @param toRemove defines the transform node to remove
  40652. * @returns the index where the transform node was in the transform node list
  40653. */
  40654. removeTransformNode(toRemove: TransformNode): number;
  40655. /**
  40656. * Remove a skeleton for the list of scene's skeletons
  40657. * @param toRemove defines the skeleton to remove
  40658. * @returns the index where the skeleton was in the skeleton list
  40659. */
  40660. removeSkeleton(toRemove: Skeleton): number;
  40661. /**
  40662. * Remove a morph target for the list of scene's morph targets
  40663. * @param toRemove defines the morph target to remove
  40664. * @returns the index where the morph target was in the morph target list
  40665. */
  40666. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40667. /**
  40668. * Remove a light for the list of scene's lights
  40669. * @param toRemove defines the light to remove
  40670. * @returns the index where the light was in the light list
  40671. */
  40672. removeLight(toRemove: Light): number;
  40673. /**
  40674. * Remove a camera for the list of scene's cameras
  40675. * @param toRemove defines the camera to remove
  40676. * @returns the index where the camera was in the camera list
  40677. */
  40678. removeCamera(toRemove: Camera): number;
  40679. /**
  40680. * Remove a particle system for the list of scene's particle systems
  40681. * @param toRemove defines the particle system to remove
  40682. * @returns the index where the particle system was in the particle system list
  40683. */
  40684. removeParticleSystem(toRemove: IParticleSystem): number;
  40685. /**
  40686. * Remove a animation for the list of scene's animations
  40687. * @param toRemove defines the animation to remove
  40688. * @returns the index where the animation was in the animation list
  40689. */
  40690. removeAnimation(toRemove: Animation): number;
  40691. /**
  40692. * Will stop the animation of the given target
  40693. * @param target - the target
  40694. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40695. * @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)
  40696. */
  40697. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40698. /**
  40699. * Removes the given animation group from this scene.
  40700. * @param toRemove The animation group to remove
  40701. * @returns The index of the removed animation group
  40702. */
  40703. removeAnimationGroup(toRemove: AnimationGroup): number;
  40704. /**
  40705. * Removes the given multi-material from this scene.
  40706. * @param toRemove The multi-material to remove
  40707. * @returns The index of the removed multi-material
  40708. */
  40709. removeMultiMaterial(toRemove: MultiMaterial): number;
  40710. /**
  40711. * Removes the given material from this scene.
  40712. * @param toRemove The material to remove
  40713. * @returns The index of the removed material
  40714. */
  40715. removeMaterial(toRemove: Material): number;
  40716. /**
  40717. * Removes the given action manager from this scene.
  40718. * @param toRemove The action manager to remove
  40719. * @returns The index of the removed action manager
  40720. */
  40721. removeActionManager(toRemove: AbstractActionManager): number;
  40722. /**
  40723. * Removes the given texture from this scene.
  40724. * @param toRemove The texture to remove
  40725. * @returns The index of the removed texture
  40726. */
  40727. removeTexture(toRemove: BaseTexture): number;
  40728. /**
  40729. * Adds the given light to this scene
  40730. * @param newLight The light to add
  40731. */
  40732. addLight(newLight: Light): void;
  40733. /**
  40734. * Sorts the list list based on light priorities
  40735. */
  40736. sortLightsByPriority(): void;
  40737. /**
  40738. * Adds the given camera to this scene
  40739. * @param newCamera The camera to add
  40740. */
  40741. addCamera(newCamera: Camera): void;
  40742. /**
  40743. * Adds the given skeleton to this scene
  40744. * @param newSkeleton The skeleton to add
  40745. */
  40746. addSkeleton(newSkeleton: Skeleton): void;
  40747. /**
  40748. * Adds the given particle system to this scene
  40749. * @param newParticleSystem The particle system to add
  40750. */
  40751. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40752. /**
  40753. * Adds the given animation to this scene
  40754. * @param newAnimation The animation to add
  40755. */
  40756. addAnimation(newAnimation: Animation): void;
  40757. /**
  40758. * Adds the given animation group to this scene.
  40759. * @param newAnimationGroup The animation group to add
  40760. */
  40761. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40762. /**
  40763. * Adds the given multi-material to this scene
  40764. * @param newMultiMaterial The multi-material to add
  40765. */
  40766. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40767. /**
  40768. * Adds the given material to this scene
  40769. * @param newMaterial The material to add
  40770. */
  40771. addMaterial(newMaterial: Material): void;
  40772. /**
  40773. * Adds the given morph target to this scene
  40774. * @param newMorphTargetManager The morph target to add
  40775. */
  40776. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40777. /**
  40778. * Adds the given geometry to this scene
  40779. * @param newGeometry The geometry to add
  40780. */
  40781. addGeometry(newGeometry: Geometry): void;
  40782. /**
  40783. * Adds the given action manager to this scene
  40784. * @param newActionManager The action manager to add
  40785. */
  40786. addActionManager(newActionManager: AbstractActionManager): void;
  40787. /**
  40788. * Adds the given texture to this scene.
  40789. * @param newTexture The texture to add
  40790. */
  40791. addTexture(newTexture: BaseTexture): void;
  40792. /**
  40793. * Switch active camera
  40794. * @param newCamera defines the new active camera
  40795. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40796. */
  40797. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40798. /**
  40799. * sets the active camera of the scene using its ID
  40800. * @param id defines the camera's ID
  40801. * @return the new active camera or null if none found.
  40802. */
  40803. setActiveCameraByID(id: string): Nullable<Camera>;
  40804. /**
  40805. * sets the active camera of the scene using its name
  40806. * @param name defines the camera's name
  40807. * @returns the new active camera or null if none found.
  40808. */
  40809. setActiveCameraByName(name: string): Nullable<Camera>;
  40810. /**
  40811. * get an animation group using its name
  40812. * @param name defines the material's name
  40813. * @return the animation group or null if none found.
  40814. */
  40815. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40816. /**
  40817. * Get a material using its unique id
  40818. * @param uniqueId defines the material's unique id
  40819. * @return the material or null if none found.
  40820. */
  40821. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40822. /**
  40823. * get a material using its id
  40824. * @param id defines the material's ID
  40825. * @return the material or null if none found.
  40826. */
  40827. getMaterialByID(id: string): Nullable<Material>;
  40828. /**
  40829. * Gets a the last added material using a given id
  40830. * @param id defines the material's ID
  40831. * @return the last material with the given id or null if none found.
  40832. */
  40833. getLastMaterialByID(id: string): Nullable<Material>;
  40834. /**
  40835. * Gets a material using its name
  40836. * @param name defines the material's name
  40837. * @return the material or null if none found.
  40838. */
  40839. getMaterialByName(name: string): Nullable<Material>;
  40840. /**
  40841. * Get a texture using its unique id
  40842. * @param uniqueId defines the texture's unique id
  40843. * @return the texture or null if none found.
  40844. */
  40845. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40846. /**
  40847. * Gets a camera using its id
  40848. * @param id defines the id to look for
  40849. * @returns the camera or null if not found
  40850. */
  40851. getCameraByID(id: string): Nullable<Camera>;
  40852. /**
  40853. * Gets a camera using its unique id
  40854. * @param uniqueId defines the unique id to look for
  40855. * @returns the camera or null if not found
  40856. */
  40857. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40858. /**
  40859. * Gets a camera using its name
  40860. * @param name defines the camera's name
  40861. * @return the camera or null if none found.
  40862. */
  40863. getCameraByName(name: string): Nullable<Camera>;
  40864. /**
  40865. * Gets a bone using its id
  40866. * @param id defines the bone's id
  40867. * @return the bone or null if not found
  40868. */
  40869. getBoneByID(id: string): Nullable<Bone>;
  40870. /**
  40871. * Gets a bone using its id
  40872. * @param name defines the bone's name
  40873. * @return the bone or null if not found
  40874. */
  40875. getBoneByName(name: string): Nullable<Bone>;
  40876. /**
  40877. * Gets a light node using its name
  40878. * @param name defines the the light's name
  40879. * @return the light or null if none found.
  40880. */
  40881. getLightByName(name: string): Nullable<Light>;
  40882. /**
  40883. * Gets a light node using its id
  40884. * @param id defines the light's id
  40885. * @return the light or null if none found.
  40886. */
  40887. getLightByID(id: string): Nullable<Light>;
  40888. /**
  40889. * Gets a light node using its scene-generated unique ID
  40890. * @param uniqueId defines the light's unique id
  40891. * @return the light or null if none found.
  40892. */
  40893. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40894. /**
  40895. * Gets a particle system by id
  40896. * @param id defines the particle system id
  40897. * @return the corresponding system or null if none found
  40898. */
  40899. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40900. /**
  40901. * Gets a geometry using its ID
  40902. * @param id defines the geometry's id
  40903. * @return the geometry or null if none found.
  40904. */
  40905. getGeometryByID(id: string): Nullable<Geometry>;
  40906. private _getGeometryByUniqueID;
  40907. /**
  40908. * Add a new geometry to this scene
  40909. * @param geometry defines the geometry to be added to the scene.
  40910. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40911. * @return a boolean defining if the geometry was added or not
  40912. */
  40913. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40914. /**
  40915. * Removes an existing geometry
  40916. * @param geometry defines the geometry to be removed from the scene
  40917. * @return a boolean defining if the geometry was removed or not
  40918. */
  40919. removeGeometry(geometry: Geometry): boolean;
  40920. /**
  40921. * Gets the list of geometries attached to the scene
  40922. * @returns an array of Geometry
  40923. */
  40924. getGeometries(): Geometry[];
  40925. /**
  40926. * Gets the first added mesh found of a given ID
  40927. * @param id defines the id to search for
  40928. * @return the mesh found or null if not found at all
  40929. */
  40930. getMeshByID(id: string): Nullable<AbstractMesh>;
  40931. /**
  40932. * Gets a list of meshes using their id
  40933. * @param id defines the id to search for
  40934. * @returns a list of meshes
  40935. */
  40936. getMeshesByID(id: string): Array<AbstractMesh>;
  40937. /**
  40938. * Gets the first added transform node found of a given ID
  40939. * @param id defines the id to search for
  40940. * @return the found transform node or null if not found at all.
  40941. */
  40942. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40943. /**
  40944. * Gets a transform node with its auto-generated unique id
  40945. * @param uniqueId efines the unique id to search for
  40946. * @return the found transform node or null if not found at all.
  40947. */
  40948. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40949. /**
  40950. * Gets a list of transform nodes using their id
  40951. * @param id defines the id to search for
  40952. * @returns a list of transform nodes
  40953. */
  40954. getTransformNodesByID(id: string): Array<TransformNode>;
  40955. /**
  40956. * Gets a mesh with its auto-generated unique id
  40957. * @param uniqueId defines the unique id to search for
  40958. * @return the found mesh or null if not found at all.
  40959. */
  40960. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40961. /**
  40962. * Gets a the last added mesh using a given id
  40963. * @param id defines the id to search for
  40964. * @return the found mesh or null if not found at all.
  40965. */
  40966. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40967. /**
  40968. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40969. * @param id defines the id to search for
  40970. * @return the found node or null if not found at all
  40971. */
  40972. getLastEntryByID(id: string): Nullable<Node>;
  40973. /**
  40974. * Gets a node (Mesh, Camera, Light) using a given id
  40975. * @param id defines the id to search for
  40976. * @return the found node or null if not found at all
  40977. */
  40978. getNodeByID(id: string): Nullable<Node>;
  40979. /**
  40980. * Gets a node (Mesh, Camera, Light) using a given name
  40981. * @param name defines the name to search for
  40982. * @return the found node or null if not found at all.
  40983. */
  40984. getNodeByName(name: string): Nullable<Node>;
  40985. /**
  40986. * Gets a mesh using a given name
  40987. * @param name defines the name to search for
  40988. * @return the found mesh or null if not found at all.
  40989. */
  40990. getMeshByName(name: string): Nullable<AbstractMesh>;
  40991. /**
  40992. * Gets a transform node using a given name
  40993. * @param name defines the name to search for
  40994. * @return the found transform node or null if not found at all.
  40995. */
  40996. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40997. /**
  40998. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40999. * @param id defines the id to search for
  41000. * @return the found skeleton or null if not found at all.
  41001. */
  41002. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41003. /**
  41004. * Gets a skeleton using a given auto generated unique id
  41005. * @param uniqueId defines the unique id to search for
  41006. * @return the found skeleton or null if not found at all.
  41007. */
  41008. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41009. /**
  41010. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41011. * @param id defines the id to search for
  41012. * @return the found skeleton or null if not found at all.
  41013. */
  41014. getSkeletonById(id: string): Nullable<Skeleton>;
  41015. /**
  41016. * Gets a skeleton using a given name
  41017. * @param name defines the name to search for
  41018. * @return the found skeleton or null if not found at all.
  41019. */
  41020. getSkeletonByName(name: string): Nullable<Skeleton>;
  41021. /**
  41022. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41023. * @param id defines the id to search for
  41024. * @return the found morph target manager or null if not found at all.
  41025. */
  41026. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41027. /**
  41028. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41029. * @param id defines the id to search for
  41030. * @return the found morph target or null if not found at all.
  41031. */
  41032. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41033. /**
  41034. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41035. * @param name defines the name to search for
  41036. * @return the found morph target or null if not found at all.
  41037. */
  41038. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41039. /**
  41040. * Gets a post process using a given name (if many are found, this function will pick the first one)
  41041. * @param name defines the name to search for
  41042. * @return the found post process or null if not found at all.
  41043. */
  41044. getPostProcessByName(name: string): Nullable<PostProcess>;
  41045. /**
  41046. * Gets a boolean indicating if the given mesh is active
  41047. * @param mesh defines the mesh to look for
  41048. * @returns true if the mesh is in the active list
  41049. */
  41050. isActiveMesh(mesh: AbstractMesh): boolean;
  41051. /**
  41052. * Return a unique id as a string which can serve as an identifier for the scene
  41053. */
  41054. get uid(): string;
  41055. /**
  41056. * Add an externaly attached data from its key.
  41057. * This method call will fail and return false, if such key already exists.
  41058. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41059. * @param key the unique key that identifies the data
  41060. * @param data the data object to associate to the key for this Engine instance
  41061. * @return true if no such key were already present and the data was added successfully, false otherwise
  41062. */
  41063. addExternalData<T>(key: string, data: T): boolean;
  41064. /**
  41065. * Get an externaly attached data from its key
  41066. * @param key the unique key that identifies the data
  41067. * @return the associated data, if present (can be null), or undefined if not present
  41068. */
  41069. getExternalData<T>(key: string): Nullable<T>;
  41070. /**
  41071. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41072. * @param key the unique key that identifies the data
  41073. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41074. * @return the associated data, can be null if the factory returned null.
  41075. */
  41076. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41077. /**
  41078. * Remove an externaly attached data from the Engine instance
  41079. * @param key the unique key that identifies the data
  41080. * @return true if the data was successfully removed, false if it doesn't exist
  41081. */
  41082. removeExternalData(key: string): boolean;
  41083. private _evaluateSubMesh;
  41084. /**
  41085. * Clear the processed materials smart array preventing retention point in material dispose.
  41086. */
  41087. freeProcessedMaterials(): void;
  41088. private _preventFreeActiveMeshesAndRenderingGroups;
  41089. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41090. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41091. * when disposing several meshes in a row or a hierarchy of meshes.
  41092. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41093. */
  41094. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41095. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41096. /**
  41097. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41098. */
  41099. freeActiveMeshes(): void;
  41100. /**
  41101. * Clear the info related to rendering groups preventing retention points during dispose.
  41102. */
  41103. freeRenderingGroups(): void;
  41104. /** @hidden */
  41105. _isInIntermediateRendering(): boolean;
  41106. /**
  41107. * Lambda returning the list of potentially active meshes.
  41108. */
  41109. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41110. /**
  41111. * Lambda returning the list of potentially active sub meshes.
  41112. */
  41113. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41114. /**
  41115. * Lambda returning the list of potentially intersecting sub meshes.
  41116. */
  41117. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41118. /**
  41119. * Lambda returning the list of potentially colliding sub meshes.
  41120. */
  41121. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41122. private _activeMeshesFrozen;
  41123. private _skipEvaluateActiveMeshesCompletely;
  41124. /**
  41125. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41126. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41127. * @returns the current scene
  41128. */
  41129. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41130. /**
  41131. * Use this function to restart evaluating active meshes on every frame
  41132. * @returns the current scene
  41133. */
  41134. unfreezeActiveMeshes(): Scene;
  41135. private _evaluateActiveMeshes;
  41136. private _activeMesh;
  41137. /**
  41138. * Update the transform matrix to update from the current active camera
  41139. * @param force defines a boolean used to force the update even if cache is up to date
  41140. */
  41141. updateTransformMatrix(force?: boolean): void;
  41142. private _bindFrameBuffer;
  41143. /** @hidden */
  41144. _allowPostProcessClearColor: boolean;
  41145. /** @hidden */
  41146. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41147. private _processSubCameras;
  41148. private _checkIntersections;
  41149. /** @hidden */
  41150. _advancePhysicsEngineStep(step: number): void;
  41151. /**
  41152. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41153. */
  41154. getDeterministicFrameTime: () => number;
  41155. /** @hidden */
  41156. _animate(): void;
  41157. /** Execute all animations (for a frame) */
  41158. animate(): void;
  41159. /**
  41160. * Render the scene
  41161. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41162. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41163. */
  41164. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41165. /**
  41166. * Freeze all materials
  41167. * A frozen material will not be updatable but should be faster to render
  41168. */
  41169. freezeMaterials(): void;
  41170. /**
  41171. * Unfreeze all materials
  41172. * A frozen material will not be updatable but should be faster to render
  41173. */
  41174. unfreezeMaterials(): void;
  41175. /**
  41176. * Releases all held ressources
  41177. */
  41178. dispose(): void;
  41179. /**
  41180. * Gets if the scene is already disposed
  41181. */
  41182. get isDisposed(): boolean;
  41183. /**
  41184. * Call this function to reduce memory footprint of the scene.
  41185. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41186. */
  41187. clearCachedVertexData(): void;
  41188. /**
  41189. * This function will remove the local cached buffer data from texture.
  41190. * It will save memory but will prevent the texture from being rebuilt
  41191. */
  41192. cleanCachedTextureBuffer(): void;
  41193. /**
  41194. * Get the world extend vectors with an optional filter
  41195. *
  41196. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41197. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41198. */
  41199. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41200. min: Vector3;
  41201. max: Vector3;
  41202. };
  41203. /**
  41204. * Creates a ray that can be used to pick in the scene
  41205. * @param x defines the x coordinate of the origin (on-screen)
  41206. * @param y defines the y coordinate of the origin (on-screen)
  41207. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41208. * @param camera defines the camera to use for the picking
  41209. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41210. * @returns a Ray
  41211. */
  41212. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41213. /**
  41214. * Creates a ray that can be used to pick in the scene
  41215. * @param x defines the x coordinate of the origin (on-screen)
  41216. * @param y defines the y coordinate of the origin (on-screen)
  41217. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41218. * @param result defines the ray where to store the picking ray
  41219. * @param camera defines the camera to use for the picking
  41220. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41221. * @returns the current scene
  41222. */
  41223. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41224. /**
  41225. * Creates a ray that can be used to pick in the scene
  41226. * @param x defines the x coordinate of the origin (on-screen)
  41227. * @param y defines the y coordinate of the origin (on-screen)
  41228. * @param camera defines the camera to use for the picking
  41229. * @returns a Ray
  41230. */
  41231. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41232. /**
  41233. * Creates a ray that can be used to pick in the scene
  41234. * @param x defines the x coordinate of the origin (on-screen)
  41235. * @param y defines the y coordinate of the origin (on-screen)
  41236. * @param result defines the ray where to store the picking ray
  41237. * @param camera defines the camera to use for the picking
  41238. * @returns the current scene
  41239. */
  41240. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41241. /** Launch a ray to try to pick a mesh in the scene
  41242. * @param x position on screen
  41243. * @param y position on screen
  41244. * @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
  41245. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41246. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41248. * @returns a PickingInfo
  41249. */
  41250. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41251. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41252. * @param x position on screen
  41253. * @param y position on screen
  41254. * @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
  41255. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41256. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41257. * @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)
  41258. */
  41259. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41260. /** Use the given ray to pick a mesh in the scene
  41261. * @param ray The ray to use to pick meshes
  41262. * @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
  41263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41265. * @returns a PickingInfo
  41266. */
  41267. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41268. /**
  41269. * Launch a ray to try to pick a mesh in the scene
  41270. * @param x X position on screen
  41271. * @param y Y position on screen
  41272. * @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
  41273. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41275. * @returns an array of PickingInfo
  41276. */
  41277. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41278. /**
  41279. * Launch a ray to try to pick a mesh in the scene
  41280. * @param ray Ray to use
  41281. * @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
  41282. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41283. * @returns an array of PickingInfo
  41284. */
  41285. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41286. /**
  41287. * Force the value of meshUnderPointer
  41288. * @param mesh defines the mesh to use
  41289. * @param pointerId optional pointer id when using more than one pointer
  41290. */
  41291. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41292. /**
  41293. * Gets the mesh under the pointer
  41294. * @returns a Mesh or null if no mesh is under the pointer
  41295. */
  41296. getPointerOverMesh(): Nullable<AbstractMesh>;
  41297. /** @hidden */
  41298. _rebuildGeometries(): void;
  41299. /** @hidden */
  41300. _rebuildTextures(): void;
  41301. private _getByTags;
  41302. /**
  41303. * Get a list of meshes by tags
  41304. * @param tagsQuery defines the tags query to use
  41305. * @param forEach defines a predicate used to filter results
  41306. * @returns an array of Mesh
  41307. */
  41308. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41309. /**
  41310. * Get a list of cameras by tags
  41311. * @param tagsQuery defines the tags query to use
  41312. * @param forEach defines a predicate used to filter results
  41313. * @returns an array of Camera
  41314. */
  41315. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41316. /**
  41317. * Get a list of lights by tags
  41318. * @param tagsQuery defines the tags query to use
  41319. * @param forEach defines a predicate used to filter results
  41320. * @returns an array of Light
  41321. */
  41322. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41323. /**
  41324. * Get a list of materials by tags
  41325. * @param tagsQuery defines the tags query to use
  41326. * @param forEach defines a predicate used to filter results
  41327. * @returns an array of Material
  41328. */
  41329. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41330. /**
  41331. * Get a list of transform nodes by tags
  41332. * @param tagsQuery defines the tags query to use
  41333. * @param forEach defines a predicate used to filter results
  41334. * @returns an array of TransformNode
  41335. */
  41336. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41337. /**
  41338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41339. * This allowed control for front to back rendering or reversly depending of the special needs.
  41340. *
  41341. * @param renderingGroupId The rendering group id corresponding to its index
  41342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41345. */
  41346. 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;
  41347. /**
  41348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41349. *
  41350. * @param renderingGroupId The rendering group id corresponding to its index
  41351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41352. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41353. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41354. */
  41355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41356. /**
  41357. * Gets the current auto clear configuration for one rendering group of the rendering
  41358. * manager.
  41359. * @param index the rendering group index to get the information for
  41360. * @returns The auto clear setup for the requested rendering group
  41361. */
  41362. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41363. private _blockMaterialDirtyMechanism;
  41364. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41365. get blockMaterialDirtyMechanism(): boolean;
  41366. set blockMaterialDirtyMechanism(value: boolean);
  41367. /**
  41368. * Will flag all materials as dirty to trigger new shader compilation
  41369. * @param flag defines the flag used to specify which material part must be marked as dirty
  41370. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41371. */
  41372. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41373. /** @hidden */
  41374. _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;
  41375. /** @hidden */
  41376. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41377. /** @hidden */
  41378. _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;
  41379. /** @hidden */
  41380. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41381. /** @hidden */
  41382. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41383. /** @hidden */
  41384. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. /**
  41389. * Set of assets to keep when moving a scene into an asset container.
  41390. */
  41391. export class KeepAssets extends AbstractScene {
  41392. }
  41393. /**
  41394. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41395. */
  41396. export class InstantiatedEntries {
  41397. /**
  41398. * List of new root nodes (eg. nodes with no parent)
  41399. */
  41400. rootNodes: TransformNode[];
  41401. /**
  41402. * List of new skeletons
  41403. */
  41404. skeletons: Skeleton[];
  41405. /**
  41406. * List of new animation groups
  41407. */
  41408. animationGroups: AnimationGroup[];
  41409. }
  41410. /**
  41411. * Container with a set of assets that can be added or removed from a scene.
  41412. */
  41413. export class AssetContainer extends AbstractScene {
  41414. private _wasAddedToScene;
  41415. /**
  41416. * The scene the AssetContainer belongs to.
  41417. */
  41418. scene: Scene;
  41419. /**
  41420. * Instantiates an AssetContainer.
  41421. * @param scene The scene the AssetContainer belongs to.
  41422. */
  41423. constructor(scene: Scene);
  41424. /**
  41425. * Instantiate or clone all meshes and add the new ones to the scene.
  41426. * Skeletons and animation groups will all be cloned
  41427. * @param nameFunction defines an optional function used to get new names for clones
  41428. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41429. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41430. */
  41431. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41432. /**
  41433. * Adds all the assets from the container to the scene.
  41434. */
  41435. addAllToScene(): void;
  41436. /**
  41437. * Removes all the assets in the container from the scene
  41438. */
  41439. removeAllFromScene(): void;
  41440. /**
  41441. * Disposes all the assets in the container
  41442. */
  41443. dispose(): void;
  41444. private _moveAssets;
  41445. /**
  41446. * Removes all the assets contained in the scene and adds them to the container.
  41447. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41448. */
  41449. moveAllFromScene(keepAssets?: KeepAssets): void;
  41450. /**
  41451. * 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.
  41452. * @returns the root mesh
  41453. */
  41454. createRootMesh(): Mesh;
  41455. /**
  41456. * Merge animations (direct and animation groups) from this asset container into a scene
  41457. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41458. * @param animatables set of animatables to retarget to a node from the scene
  41459. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41460. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41461. */
  41462. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41463. }
  41464. }
  41465. declare module BABYLON {
  41466. /**
  41467. * Defines how the parser contract is defined.
  41468. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41469. */
  41470. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41471. /**
  41472. * Defines how the individual parser contract is defined.
  41473. * These parser can parse an individual asset
  41474. */
  41475. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41476. /**
  41477. * Base class of the scene acting as a container for the different elements composing a scene.
  41478. * This class is dynamically extended by the different components of the scene increasing
  41479. * flexibility and reducing coupling
  41480. */
  41481. export abstract class AbstractScene {
  41482. /**
  41483. * Stores the list of available parsers in the application.
  41484. */
  41485. private static _BabylonFileParsers;
  41486. /**
  41487. * Stores the list of available individual parsers in the application.
  41488. */
  41489. private static _IndividualBabylonFileParsers;
  41490. /**
  41491. * Adds a parser in the list of available ones
  41492. * @param name Defines the name of the parser
  41493. * @param parser Defines the parser to add
  41494. */
  41495. static AddParser(name: string, parser: BabylonFileParser): void;
  41496. /**
  41497. * Gets a general parser from the list of avaialble ones
  41498. * @param name Defines the name of the parser
  41499. * @returns the requested parser or null
  41500. */
  41501. static GetParser(name: string): Nullable<BabylonFileParser>;
  41502. /**
  41503. * Adds n individual parser in the list of available ones
  41504. * @param name Defines the name of the parser
  41505. * @param parser Defines the parser to add
  41506. */
  41507. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41508. /**
  41509. * Gets an individual parser from the list of avaialble ones
  41510. * @param name Defines the name of the parser
  41511. * @returns the requested parser or null
  41512. */
  41513. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41514. /**
  41515. * Parser json data and populate both a scene and its associated container object
  41516. * @param jsonData Defines the data to parse
  41517. * @param scene Defines the scene to parse the data for
  41518. * @param container Defines the container attached to the parsing sequence
  41519. * @param rootUrl Defines the root url of the data
  41520. */
  41521. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41522. /**
  41523. * Gets the list of root nodes (ie. nodes with no parent)
  41524. */
  41525. rootNodes: Node[];
  41526. /** All of the cameras added to this scene
  41527. * @see https://doc.babylonjs.com/babylon101/cameras
  41528. */
  41529. cameras: Camera[];
  41530. /**
  41531. * All of the lights added to this scene
  41532. * @see https://doc.babylonjs.com/babylon101/lights
  41533. */
  41534. lights: Light[];
  41535. /**
  41536. * All of the (abstract) meshes added to this scene
  41537. */
  41538. meshes: AbstractMesh[];
  41539. /**
  41540. * The list of skeletons added to the scene
  41541. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41542. */
  41543. skeletons: Skeleton[];
  41544. /**
  41545. * All of the particle systems added to this scene
  41546. * @see https://doc.babylonjs.com/babylon101/particles
  41547. */
  41548. particleSystems: IParticleSystem[];
  41549. /**
  41550. * Gets a list of Animations associated with the scene
  41551. */
  41552. animations: Animation[];
  41553. /**
  41554. * All of the animation groups added to this scene
  41555. * @see https://doc.babylonjs.com/how_to/group
  41556. */
  41557. animationGroups: AnimationGroup[];
  41558. /**
  41559. * All of the multi-materials added to this scene
  41560. * @see https://doc.babylonjs.com/how_to/multi_materials
  41561. */
  41562. multiMaterials: MultiMaterial[];
  41563. /**
  41564. * All of the materials added to this scene
  41565. * In the context of a Scene, it is not supposed to be modified manually.
  41566. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41567. * Note also that the order of the Material within the array is not significant and might change.
  41568. * @see https://doc.babylonjs.com/babylon101/materials
  41569. */
  41570. materials: Material[];
  41571. /**
  41572. * The list of morph target managers added to the scene
  41573. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41574. */
  41575. morphTargetManagers: MorphTargetManager[];
  41576. /**
  41577. * The list of geometries used in the scene.
  41578. */
  41579. geometries: Geometry[];
  41580. /**
  41581. * All of the tranform nodes added to this scene
  41582. * In the context of a Scene, it is not supposed to be modified manually.
  41583. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41584. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41585. * @see https://doc.babylonjs.com/how_to/transformnode
  41586. */
  41587. transformNodes: TransformNode[];
  41588. /**
  41589. * ActionManagers available on the scene.
  41590. */
  41591. actionManagers: AbstractActionManager[];
  41592. /**
  41593. * Textures to keep.
  41594. */
  41595. textures: BaseTexture[];
  41596. /** @hidden */
  41597. protected _environmentTexture: Nullable<BaseTexture>;
  41598. /**
  41599. * Texture used in all pbr material as the reflection texture.
  41600. * As in the majority of the scene they are the same (exception for multi room and so on),
  41601. * this is easier to reference from here than from all the materials.
  41602. */
  41603. get environmentTexture(): Nullable<BaseTexture>;
  41604. set environmentTexture(value: Nullable<BaseTexture>);
  41605. /**
  41606. * The list of postprocesses added to the scene
  41607. */
  41608. postProcesses: PostProcess[];
  41609. /**
  41610. * @returns all meshes, lights, cameras, transformNodes and bones
  41611. */
  41612. getNodes(): Array<Node>;
  41613. }
  41614. }
  41615. declare module BABYLON {
  41616. /**
  41617. * Interface used to define options for Sound class
  41618. */
  41619. export interface ISoundOptions {
  41620. /**
  41621. * Does the sound autoplay once loaded.
  41622. */
  41623. autoplay?: boolean;
  41624. /**
  41625. * Does the sound loop after it finishes playing once.
  41626. */
  41627. loop?: boolean;
  41628. /**
  41629. * Sound's volume
  41630. */
  41631. volume?: number;
  41632. /**
  41633. * Is it a spatial sound?
  41634. */
  41635. spatialSound?: boolean;
  41636. /**
  41637. * Maximum distance to hear that sound
  41638. */
  41639. maxDistance?: number;
  41640. /**
  41641. * Uses user defined attenuation function
  41642. */
  41643. useCustomAttenuation?: boolean;
  41644. /**
  41645. * Define the roll off factor of spatial sounds.
  41646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41647. */
  41648. rolloffFactor?: number;
  41649. /**
  41650. * Define the reference distance the sound should be heard perfectly.
  41651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41652. */
  41653. refDistance?: number;
  41654. /**
  41655. * Define the distance attenuation model the sound will follow.
  41656. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41657. */
  41658. distanceModel?: string;
  41659. /**
  41660. * Defines the playback speed (1 by default)
  41661. */
  41662. playbackRate?: number;
  41663. /**
  41664. * Defines if the sound is from a streaming source
  41665. */
  41666. streaming?: boolean;
  41667. /**
  41668. * Defines an optional length (in seconds) inside the sound file
  41669. */
  41670. length?: number;
  41671. /**
  41672. * Defines an optional offset (in seconds) inside the sound file
  41673. */
  41674. offset?: number;
  41675. /**
  41676. * If true, URLs will not be required to state the audio file codec to use.
  41677. */
  41678. skipCodecCheck?: boolean;
  41679. }
  41680. /**
  41681. * Defines a sound that can be played in the application.
  41682. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41684. */
  41685. export class Sound {
  41686. /**
  41687. * The name of the sound in the scene.
  41688. */
  41689. name: string;
  41690. /**
  41691. * Does the sound autoplay once loaded.
  41692. */
  41693. autoplay: boolean;
  41694. /**
  41695. * Does the sound loop after it finishes playing once.
  41696. */
  41697. loop: boolean;
  41698. /**
  41699. * Does the sound use a custom attenuation curve to simulate the falloff
  41700. * happening when the source gets further away from the camera.
  41701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41702. */
  41703. useCustomAttenuation: boolean;
  41704. /**
  41705. * The sound track id this sound belongs to.
  41706. */
  41707. soundTrackId: number;
  41708. /**
  41709. * Is this sound currently played.
  41710. */
  41711. isPlaying: boolean;
  41712. /**
  41713. * Is this sound currently paused.
  41714. */
  41715. isPaused: boolean;
  41716. /**
  41717. * Does this sound enables spatial sound.
  41718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41719. */
  41720. spatialSound: boolean;
  41721. /**
  41722. * Define the reference distance the sound should be heard perfectly.
  41723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41724. */
  41725. refDistance: number;
  41726. /**
  41727. * Define the roll off factor of spatial sounds.
  41728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41729. */
  41730. rolloffFactor: number;
  41731. /**
  41732. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41734. */
  41735. maxDistance: number;
  41736. /**
  41737. * Define the distance attenuation model the sound will follow.
  41738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41739. */
  41740. distanceModel: string;
  41741. /**
  41742. * @hidden
  41743. * Back Compat
  41744. **/
  41745. onended: () => any;
  41746. /**
  41747. * Gets or sets an object used to store user defined information for the sound.
  41748. */
  41749. metadata: any;
  41750. /**
  41751. * Observable event when the current playing sound finishes.
  41752. */
  41753. onEndedObservable: Observable<Sound>;
  41754. private _panningModel;
  41755. private _playbackRate;
  41756. private _streaming;
  41757. private _startTime;
  41758. private _startOffset;
  41759. private _position;
  41760. /** @hidden */
  41761. _positionInEmitterSpace: boolean;
  41762. private _localDirection;
  41763. private _volume;
  41764. private _isReadyToPlay;
  41765. private _isDirectional;
  41766. private _readyToPlayCallback;
  41767. private _audioBuffer;
  41768. private _soundSource;
  41769. private _streamingSource;
  41770. private _soundPanner;
  41771. private _soundGain;
  41772. private _inputAudioNode;
  41773. private _outputAudioNode;
  41774. private _coneInnerAngle;
  41775. private _coneOuterAngle;
  41776. private _coneOuterGain;
  41777. private _scene;
  41778. private _connectedTransformNode;
  41779. private _customAttenuationFunction;
  41780. private _registerFunc;
  41781. private _isOutputConnected;
  41782. private _htmlAudioElement;
  41783. private _urlType;
  41784. private _length?;
  41785. private _offset?;
  41786. /** @hidden */
  41787. static _SceneComponentInitialization: (scene: Scene) => void;
  41788. /**
  41789. * Create a sound and attach it to a scene
  41790. * @param name Name of your sound
  41791. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41792. * @param scene defines the scene the sound belongs to
  41793. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41794. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41795. */
  41796. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41797. /**
  41798. * Release the sound and its associated resources
  41799. */
  41800. dispose(): void;
  41801. /**
  41802. * Gets if the sounds is ready to be played or not.
  41803. * @returns true if ready, otherwise false
  41804. */
  41805. isReady(): boolean;
  41806. private _soundLoaded;
  41807. /**
  41808. * Sets the data of the sound from an audiobuffer
  41809. * @param audioBuffer The audioBuffer containing the data
  41810. */
  41811. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41812. /**
  41813. * Updates the current sounds options such as maxdistance, loop...
  41814. * @param options A JSON object containing values named as the object properties
  41815. */
  41816. updateOptions(options: ISoundOptions): void;
  41817. private _createSpatialParameters;
  41818. private _updateSpatialParameters;
  41819. /**
  41820. * Switch the panning model to HRTF:
  41821. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41823. */
  41824. switchPanningModelToHRTF(): void;
  41825. /**
  41826. * Switch the panning model to Equal Power:
  41827. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41829. */
  41830. switchPanningModelToEqualPower(): void;
  41831. private _switchPanningModel;
  41832. /**
  41833. * Connect this sound to a sound track audio node like gain...
  41834. * @param soundTrackAudioNode the sound track audio node to connect to
  41835. */
  41836. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41837. /**
  41838. * Transform this sound into a directional source
  41839. * @param coneInnerAngle Size of the inner cone in degree
  41840. * @param coneOuterAngle Size of the outer cone in degree
  41841. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41842. */
  41843. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41844. /**
  41845. * Gets or sets the inner angle for the directional cone.
  41846. */
  41847. get directionalConeInnerAngle(): number;
  41848. /**
  41849. * Gets or sets the inner angle for the directional cone.
  41850. */
  41851. set directionalConeInnerAngle(value: number);
  41852. /**
  41853. * Gets or sets the outer angle for the directional cone.
  41854. */
  41855. get directionalConeOuterAngle(): number;
  41856. /**
  41857. * Gets or sets the outer angle for the directional cone.
  41858. */
  41859. set directionalConeOuterAngle(value: number);
  41860. /**
  41861. * Sets the position of the emitter if spatial sound is enabled
  41862. * @param newPosition Defines the new posisiton
  41863. */
  41864. setPosition(newPosition: Vector3): void;
  41865. /**
  41866. * Sets the local direction of the emitter if spatial sound is enabled
  41867. * @param newLocalDirection Defines the new local direction
  41868. */
  41869. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41870. private _updateDirection;
  41871. /** @hidden */
  41872. updateDistanceFromListener(): void;
  41873. /**
  41874. * Sets a new custom attenuation function for the sound.
  41875. * @param callback Defines the function used for the attenuation
  41876. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41877. */
  41878. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41879. /**
  41880. * Play the sound
  41881. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41882. * @param offset (optional) Start the sound at a specific time in seconds
  41883. * @param length (optional) Sound duration (in seconds)
  41884. */
  41885. play(time?: number, offset?: number, length?: number): void;
  41886. private _onended;
  41887. /**
  41888. * Stop the sound
  41889. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41890. */
  41891. stop(time?: number): void;
  41892. /**
  41893. * Put the sound in pause
  41894. */
  41895. pause(): void;
  41896. /**
  41897. * Sets a dedicated volume for this sounds
  41898. * @param newVolume Define the new volume of the sound
  41899. * @param time Define time for gradual change to new volume
  41900. */
  41901. setVolume(newVolume: number, time?: number): void;
  41902. /**
  41903. * Set the sound play back rate
  41904. * @param newPlaybackRate Define the playback rate the sound should be played at
  41905. */
  41906. setPlaybackRate(newPlaybackRate: number): void;
  41907. /**
  41908. * Gets the volume of the sound.
  41909. * @returns the volume of the sound
  41910. */
  41911. getVolume(): number;
  41912. /**
  41913. * Attach the sound to a dedicated mesh
  41914. * @param transformNode The transform node to connect the sound with
  41915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41916. */
  41917. attachToMesh(transformNode: TransformNode): void;
  41918. /**
  41919. * Detach the sound from the previously attached mesh
  41920. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41921. */
  41922. detachFromMesh(): void;
  41923. private _onRegisterAfterWorldMatrixUpdate;
  41924. /**
  41925. * Clone the current sound in the scene.
  41926. * @returns the new sound clone
  41927. */
  41928. clone(): Nullable<Sound>;
  41929. /**
  41930. * Gets the current underlying audio buffer containing the data
  41931. * @returns the audio buffer
  41932. */
  41933. getAudioBuffer(): Nullable<AudioBuffer>;
  41934. /**
  41935. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41936. * @returns the source node
  41937. */
  41938. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41939. /**
  41940. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41941. * @returns the gain node
  41942. */
  41943. getSoundGain(): Nullable<GainNode>;
  41944. /**
  41945. * Serializes the Sound in a JSON representation
  41946. * @returns the JSON representation of the sound
  41947. */
  41948. serialize(): any;
  41949. /**
  41950. * Parse a JSON representation of a sound to innstantiate in a given scene
  41951. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41952. * @param scene Define the scene the new parsed sound should be created in
  41953. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41954. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41955. * @returns the newly parsed sound
  41956. */
  41957. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * This defines an action helpful to play a defined sound on a triggered action.
  41963. */
  41964. export class PlaySoundAction extends Action {
  41965. private _sound;
  41966. /**
  41967. * Instantiate the action
  41968. * @param triggerOptions defines the trigger options
  41969. * @param sound defines the sound to play
  41970. * @param condition defines the trigger related conditions
  41971. */
  41972. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41973. /** @hidden */
  41974. _prepare(): void;
  41975. /**
  41976. * Execute the action and play the sound.
  41977. */
  41978. execute(): void;
  41979. /**
  41980. * Serializes the actions and its related information.
  41981. * @param parent defines the object to serialize in
  41982. * @returns the serialized object
  41983. */
  41984. serialize(parent: any): any;
  41985. }
  41986. /**
  41987. * This defines an action helpful to stop a defined sound on a triggered action.
  41988. */
  41989. export class StopSoundAction extends Action {
  41990. private _sound;
  41991. /**
  41992. * Instantiate the action
  41993. * @param triggerOptions defines the trigger options
  41994. * @param sound defines the sound to stop
  41995. * @param condition defines the trigger related conditions
  41996. */
  41997. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41998. /** @hidden */
  41999. _prepare(): void;
  42000. /**
  42001. * Execute the action and stop the sound.
  42002. */
  42003. execute(): void;
  42004. /**
  42005. * Serializes the actions and its related information.
  42006. * @param parent defines the object to serialize in
  42007. * @returns the serialized object
  42008. */
  42009. serialize(parent: any): any;
  42010. }
  42011. }
  42012. declare module BABYLON {
  42013. /**
  42014. * This defines an action responsible to change the value of a property
  42015. * by interpolating between its current value and the newly set one once triggered.
  42016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42017. */
  42018. export class InterpolateValueAction extends Action {
  42019. /**
  42020. * Defines the path of the property where the value should be interpolated
  42021. */
  42022. propertyPath: string;
  42023. /**
  42024. * Defines the target value at the end of the interpolation.
  42025. */
  42026. value: any;
  42027. /**
  42028. * Defines the time it will take for the property to interpolate to the value.
  42029. */
  42030. duration: number;
  42031. /**
  42032. * Defines if the other scene animations should be stopped when the action has been triggered
  42033. */
  42034. stopOtherAnimations?: boolean;
  42035. /**
  42036. * Defines a callback raised once the interpolation animation has been done.
  42037. */
  42038. onInterpolationDone?: () => void;
  42039. /**
  42040. * Observable triggered once the interpolation animation has been done.
  42041. */
  42042. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42043. private _target;
  42044. private _effectiveTarget;
  42045. private _property;
  42046. /**
  42047. * Instantiate the action
  42048. * @param triggerOptions defines the trigger options
  42049. * @param target defines the object containing the value to interpolate
  42050. * @param propertyPath defines the path to the property in the target object
  42051. * @param value defines the target value at the end of the interpolation
  42052. * @param duration deines the time it will take for the property to interpolate to the value.
  42053. * @param condition defines the trigger related conditions
  42054. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42055. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42056. */
  42057. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42058. /** @hidden */
  42059. _prepare(): void;
  42060. /**
  42061. * Execute the action starts the value interpolation.
  42062. */
  42063. execute(): void;
  42064. /**
  42065. * Serializes the actions and its related information.
  42066. * @param parent defines the object to serialize in
  42067. * @returns the serialized object
  42068. */
  42069. serialize(parent: any): any;
  42070. }
  42071. }
  42072. declare module BABYLON {
  42073. /**
  42074. * Options allowed during the creation of a sound track.
  42075. */
  42076. export interface ISoundTrackOptions {
  42077. /**
  42078. * The volume the sound track should take during creation
  42079. */
  42080. volume?: number;
  42081. /**
  42082. * Define if the sound track is the main sound track of the scene
  42083. */
  42084. mainTrack?: boolean;
  42085. }
  42086. /**
  42087. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42088. * It will be also used in a future release to apply effects on a specific track.
  42089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42090. */
  42091. export class SoundTrack {
  42092. /**
  42093. * The unique identifier of the sound track in the scene.
  42094. */
  42095. id: number;
  42096. /**
  42097. * The list of sounds included in the sound track.
  42098. */
  42099. soundCollection: Array<Sound>;
  42100. private _outputAudioNode;
  42101. private _scene;
  42102. private _connectedAnalyser;
  42103. private _options;
  42104. private _isInitialized;
  42105. /**
  42106. * Creates a new sound track.
  42107. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42108. * @param scene Define the scene the sound track belongs to
  42109. * @param options
  42110. */
  42111. constructor(scene: Scene, options?: ISoundTrackOptions);
  42112. private _initializeSoundTrackAudioGraph;
  42113. /**
  42114. * Release the sound track and its associated resources
  42115. */
  42116. dispose(): void;
  42117. /**
  42118. * Adds a sound to this sound track
  42119. * @param sound define the cound to add
  42120. * @ignoreNaming
  42121. */
  42122. AddSound(sound: Sound): void;
  42123. /**
  42124. * Removes a sound to this sound track
  42125. * @param sound define the cound to remove
  42126. * @ignoreNaming
  42127. */
  42128. RemoveSound(sound: Sound): void;
  42129. /**
  42130. * Set a global volume for the full sound track.
  42131. * @param newVolume Define the new volume of the sound track
  42132. */
  42133. setVolume(newVolume: number): void;
  42134. /**
  42135. * Switch the panning model to HRTF:
  42136. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42138. */
  42139. switchPanningModelToHRTF(): void;
  42140. /**
  42141. * Switch the panning model to Equal Power:
  42142. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42144. */
  42145. switchPanningModelToEqualPower(): void;
  42146. /**
  42147. * Connect the sound track to an audio analyser allowing some amazing
  42148. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42150. * @param analyser The analyser to connect to the engine
  42151. */
  42152. connectToAnalyser(analyser: Analyser): void;
  42153. }
  42154. }
  42155. declare module BABYLON {
  42156. interface AbstractScene {
  42157. /**
  42158. * The list of sounds used in the scene.
  42159. */
  42160. sounds: Nullable<Array<Sound>>;
  42161. }
  42162. interface Scene {
  42163. /**
  42164. * @hidden
  42165. * Backing field
  42166. */
  42167. _mainSoundTrack: SoundTrack;
  42168. /**
  42169. * The main sound track played by the scene.
  42170. * It cotains your primary collection of sounds.
  42171. */
  42172. mainSoundTrack: SoundTrack;
  42173. /**
  42174. * The list of sound tracks added to the scene
  42175. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42176. */
  42177. soundTracks: Nullable<Array<SoundTrack>>;
  42178. /**
  42179. * Gets a sound using a given name
  42180. * @param name defines the name to search for
  42181. * @return the found sound or null if not found at all.
  42182. */
  42183. getSoundByName(name: string): Nullable<Sound>;
  42184. /**
  42185. * Gets or sets if audio support is enabled
  42186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42187. */
  42188. audioEnabled: boolean;
  42189. /**
  42190. * Gets or sets if audio will be output to headphones
  42191. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42192. */
  42193. headphone: boolean;
  42194. /**
  42195. * Gets or sets custom audio listener position provider
  42196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42197. */
  42198. audioListenerPositionProvider: Nullable<() => Vector3>;
  42199. /**
  42200. * Gets or sets a refresh rate when using 3D audio positioning
  42201. */
  42202. audioPositioningRefreshRate: number;
  42203. }
  42204. /**
  42205. * Defines the sound scene component responsible to manage any sounds
  42206. * in a given scene.
  42207. */
  42208. export class AudioSceneComponent implements ISceneSerializableComponent {
  42209. private static _CameraDirectionLH;
  42210. private static _CameraDirectionRH;
  42211. /**
  42212. * The component name helpfull to identify the component in the list of scene components.
  42213. */
  42214. readonly name: string;
  42215. /**
  42216. * The scene the component belongs to.
  42217. */
  42218. scene: Scene;
  42219. private _audioEnabled;
  42220. /**
  42221. * Gets whether audio is enabled or not.
  42222. * Please use related enable/disable method to switch state.
  42223. */
  42224. get audioEnabled(): boolean;
  42225. private _headphone;
  42226. /**
  42227. * Gets whether audio is outputing to headphone or not.
  42228. * Please use the according Switch methods to change output.
  42229. */
  42230. get headphone(): boolean;
  42231. /**
  42232. * Gets or sets a refresh rate when using 3D audio positioning
  42233. */
  42234. audioPositioningRefreshRate: number;
  42235. private _audioListenerPositionProvider;
  42236. /**
  42237. * Gets the current audio listener position provider
  42238. */
  42239. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42240. /**
  42241. * Sets a custom listener position for all sounds in the scene
  42242. * By default, this is the position of the first active camera
  42243. */
  42244. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42245. /**
  42246. * Creates a new instance of the component for the given scene
  42247. * @param scene Defines the scene to register the component in
  42248. */
  42249. constructor(scene: Scene);
  42250. /**
  42251. * Registers the component in a given scene
  42252. */
  42253. register(): void;
  42254. /**
  42255. * Rebuilds the elements related to this component in case of
  42256. * context lost for instance.
  42257. */
  42258. rebuild(): void;
  42259. /**
  42260. * Serializes the component data to the specified json object
  42261. * @param serializationObject The object to serialize to
  42262. */
  42263. serialize(serializationObject: any): void;
  42264. /**
  42265. * Adds all the elements from the container to the scene
  42266. * @param container the container holding the elements
  42267. */
  42268. addFromContainer(container: AbstractScene): void;
  42269. /**
  42270. * Removes all the elements in the container from the scene
  42271. * @param container contains the elements to remove
  42272. * @param dispose if the removed element should be disposed (default: false)
  42273. */
  42274. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42275. /**
  42276. * Disposes the component and the associated ressources.
  42277. */
  42278. dispose(): void;
  42279. /**
  42280. * Disables audio in the associated scene.
  42281. */
  42282. disableAudio(): void;
  42283. /**
  42284. * Enables audio in the associated scene.
  42285. */
  42286. enableAudio(): void;
  42287. /**
  42288. * Switch audio to headphone output.
  42289. */
  42290. switchAudioModeForHeadphones(): void;
  42291. /**
  42292. * Switch audio to normal speakers.
  42293. */
  42294. switchAudioModeForNormalSpeakers(): void;
  42295. private _cachedCameraDirection;
  42296. private _cachedCameraPosition;
  42297. private _lastCheck;
  42298. private _afterRender;
  42299. }
  42300. }
  42301. declare module BABYLON {
  42302. /**
  42303. * Wraps one or more Sound objects and selects one with random weight for playback.
  42304. */
  42305. export class WeightedSound {
  42306. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42307. loop: boolean;
  42308. private _coneInnerAngle;
  42309. private _coneOuterAngle;
  42310. private _volume;
  42311. /** A Sound is currently playing. */
  42312. isPlaying: boolean;
  42313. /** A Sound is currently paused. */
  42314. isPaused: boolean;
  42315. private _sounds;
  42316. private _weights;
  42317. private _currentIndex?;
  42318. /**
  42319. * Creates a new WeightedSound from the list of sounds given.
  42320. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42321. * @param sounds Array of Sounds that will be selected from.
  42322. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42323. */
  42324. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42325. /**
  42326. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42327. */
  42328. get directionalConeInnerAngle(): number;
  42329. /**
  42330. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42331. */
  42332. set directionalConeInnerAngle(value: number);
  42333. /**
  42334. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42335. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42336. */
  42337. get directionalConeOuterAngle(): number;
  42338. /**
  42339. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42340. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42341. */
  42342. set directionalConeOuterAngle(value: number);
  42343. /**
  42344. * Playback volume.
  42345. */
  42346. get volume(): number;
  42347. /**
  42348. * Playback volume.
  42349. */
  42350. set volume(value: number);
  42351. private _onended;
  42352. /**
  42353. * Suspend playback
  42354. */
  42355. pause(): void;
  42356. /**
  42357. * Stop playback
  42358. */
  42359. stop(): void;
  42360. /**
  42361. * Start playback.
  42362. * @param startOffset Position the clip head at a specific time in seconds.
  42363. */
  42364. play(startOffset?: number): void;
  42365. }
  42366. }
  42367. declare module BABYLON {
  42368. /**
  42369. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42370. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42371. */
  42372. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42373. /**
  42374. * Gets the name of the behavior.
  42375. */
  42376. get name(): string;
  42377. /**
  42378. * The easing function used by animations
  42379. */
  42380. static EasingFunction: BackEase;
  42381. /**
  42382. * The easing mode used by animations
  42383. */
  42384. static EasingMode: number;
  42385. /**
  42386. * The duration of the animation, in milliseconds
  42387. */
  42388. transitionDuration: number;
  42389. /**
  42390. * Length of the distance animated by the transition when lower radius is reached
  42391. */
  42392. lowerRadiusTransitionRange: number;
  42393. /**
  42394. * Length of the distance animated by the transition when upper radius is reached
  42395. */
  42396. upperRadiusTransitionRange: number;
  42397. private _autoTransitionRange;
  42398. /**
  42399. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42400. */
  42401. get autoTransitionRange(): boolean;
  42402. /**
  42403. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42404. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42405. */
  42406. set autoTransitionRange(value: boolean);
  42407. private _attachedCamera;
  42408. private _onAfterCheckInputsObserver;
  42409. private _onMeshTargetChangedObserver;
  42410. /**
  42411. * Initializes the behavior.
  42412. */
  42413. init(): void;
  42414. /**
  42415. * Attaches the behavior to its arc rotate camera.
  42416. * @param camera Defines the camera to attach the behavior to
  42417. */
  42418. attach(camera: ArcRotateCamera): void;
  42419. /**
  42420. * Detaches the behavior from its current arc rotate camera.
  42421. */
  42422. detach(): void;
  42423. private _radiusIsAnimating;
  42424. private _radiusBounceTransition;
  42425. private _animatables;
  42426. private _cachedWheelPrecision;
  42427. /**
  42428. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42429. * @param radiusLimit The limit to check against.
  42430. * @return Bool to indicate if at limit.
  42431. */
  42432. private _isRadiusAtLimit;
  42433. /**
  42434. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42435. * @param radiusDelta The delta by which to animate to. Can be negative.
  42436. */
  42437. private _applyBoundRadiusAnimation;
  42438. /**
  42439. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42440. */
  42441. protected _clearAnimationLocks(): void;
  42442. /**
  42443. * Stops and removes all animations that have been applied to the camera
  42444. */
  42445. stopAllAnimations(): void;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /**
  42450. * 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.
  42451. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42452. */
  42453. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42454. /**
  42455. * Gets the name of the behavior.
  42456. */
  42457. get name(): string;
  42458. private _mode;
  42459. private _radiusScale;
  42460. private _positionScale;
  42461. private _defaultElevation;
  42462. private _elevationReturnTime;
  42463. private _elevationReturnWaitTime;
  42464. private _zoomStopsAnimation;
  42465. private _framingTime;
  42466. /**
  42467. * The easing function used by animations
  42468. */
  42469. static EasingFunction: ExponentialEase;
  42470. /**
  42471. * The easing mode used by animations
  42472. */
  42473. static EasingMode: number;
  42474. /**
  42475. * Sets the current mode used by the behavior
  42476. */
  42477. set mode(mode: number);
  42478. /**
  42479. * Gets current mode used by the behavior.
  42480. */
  42481. get mode(): number;
  42482. /**
  42483. * Sets the scale applied to the radius (1 by default)
  42484. */
  42485. set radiusScale(radius: number);
  42486. /**
  42487. * Gets the scale applied to the radius
  42488. */
  42489. get radiusScale(): number;
  42490. /**
  42491. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42492. */
  42493. set positionScale(scale: number);
  42494. /**
  42495. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42496. */
  42497. get positionScale(): number;
  42498. /**
  42499. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42500. * behaviour is triggered, in radians.
  42501. */
  42502. set defaultElevation(elevation: number);
  42503. /**
  42504. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42505. * behaviour is triggered, in radians.
  42506. */
  42507. get defaultElevation(): number;
  42508. /**
  42509. * Sets the time (in milliseconds) taken to return to the default beta position.
  42510. * Negative value indicates camera should not return to default.
  42511. */
  42512. set elevationReturnTime(speed: number);
  42513. /**
  42514. * Gets the time (in milliseconds) taken to return to the default beta position.
  42515. * Negative value indicates camera should not return to default.
  42516. */
  42517. get elevationReturnTime(): number;
  42518. /**
  42519. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42520. */
  42521. set elevationReturnWaitTime(time: number);
  42522. /**
  42523. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42524. */
  42525. get elevationReturnWaitTime(): number;
  42526. /**
  42527. * Sets the flag that indicates if user zooming should stop animation.
  42528. */
  42529. set zoomStopsAnimation(flag: boolean);
  42530. /**
  42531. * Gets the flag that indicates if user zooming should stop animation.
  42532. */
  42533. get zoomStopsAnimation(): boolean;
  42534. /**
  42535. * Sets the transition time when framing the mesh, in milliseconds
  42536. */
  42537. set framingTime(time: number);
  42538. /**
  42539. * Gets the transition time when framing the mesh, in milliseconds
  42540. */
  42541. get framingTime(): number;
  42542. /**
  42543. * Define if the behavior should automatically change the configured
  42544. * camera limits and sensibilities.
  42545. */
  42546. autoCorrectCameraLimitsAndSensibility: boolean;
  42547. private _onPrePointerObservableObserver;
  42548. private _onAfterCheckInputsObserver;
  42549. private _onMeshTargetChangedObserver;
  42550. private _attachedCamera;
  42551. private _isPointerDown;
  42552. private _lastInteractionTime;
  42553. /**
  42554. * Initializes the behavior.
  42555. */
  42556. init(): void;
  42557. /**
  42558. * Attaches the behavior to its arc rotate camera.
  42559. * @param camera Defines the camera to attach the behavior to
  42560. */
  42561. attach(camera: ArcRotateCamera): void;
  42562. /**
  42563. * Detaches the behavior from its current arc rotate camera.
  42564. */
  42565. detach(): void;
  42566. private _animatables;
  42567. private _betaIsAnimating;
  42568. private _betaTransition;
  42569. private _radiusTransition;
  42570. private _vectorTransition;
  42571. /**
  42572. * Targets the given mesh and updates zoom level accordingly.
  42573. * @param mesh The mesh to target.
  42574. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42575. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42576. */
  42577. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42578. /**
  42579. * Targets the given mesh with its children and updates zoom level accordingly.
  42580. * @param mesh The mesh to target.
  42581. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42582. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42583. */
  42584. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42585. /**
  42586. * Targets the given meshes with their children and updates zoom level accordingly.
  42587. * @param meshes The mesh to target.
  42588. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42589. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42590. */
  42591. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42592. /**
  42593. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42594. * @param minimumWorld Determines the smaller position of the bounding box extend
  42595. * @param maximumWorld Determines the bigger position of the bounding box extend
  42596. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42597. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42598. */
  42599. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42600. /**
  42601. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42602. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42603. * frustum width.
  42604. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42605. * to fully enclose the mesh in the viewing frustum.
  42606. */
  42607. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42608. /**
  42609. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42610. * is automatically returned to its default position (expected to be above ground plane).
  42611. */
  42612. private _maintainCameraAboveGround;
  42613. /**
  42614. * Returns the frustum slope based on the canvas ratio and camera FOV
  42615. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42616. */
  42617. private _getFrustumSlope;
  42618. /**
  42619. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42620. */
  42621. private _clearAnimationLocks;
  42622. /**
  42623. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42624. */
  42625. private _applyUserInteraction;
  42626. /**
  42627. * Stops and removes all animations that have been applied to the camera
  42628. */
  42629. stopAllAnimations(): void;
  42630. /**
  42631. * Gets a value indicating if the user is moving the camera
  42632. */
  42633. get isUserIsMoving(): boolean;
  42634. /**
  42635. * The camera can move all the way towards the mesh.
  42636. */
  42637. static IgnoreBoundsSizeMode: number;
  42638. /**
  42639. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42640. */
  42641. static FitFrustumSidesMode: number;
  42642. }
  42643. }
  42644. declare module BABYLON {
  42645. /**
  42646. * Base class for Camera Pointer Inputs.
  42647. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42648. * for example usage.
  42649. */
  42650. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42651. /**
  42652. * Defines the camera the input is attached to.
  42653. */
  42654. abstract camera: Camera;
  42655. /**
  42656. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42657. */
  42658. protected _altKey: boolean;
  42659. protected _ctrlKey: boolean;
  42660. protected _metaKey: boolean;
  42661. protected _shiftKey: boolean;
  42662. /**
  42663. * Which mouse buttons were pressed at time of last mouse event.
  42664. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42665. */
  42666. protected _buttonsPressed: number;
  42667. /**
  42668. * Defines the buttons associated with the input to handle camera move.
  42669. */
  42670. buttons: number[];
  42671. /**
  42672. * Attach the input controls to a specific dom element to get the input from.
  42673. * @param element Defines the element the controls should be listened from
  42674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42675. */
  42676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42677. /**
  42678. * Detach the current controls from the specified dom element.
  42679. * @param element Defines the element to stop listening the inputs from
  42680. */
  42681. detachControl(element: Nullable<HTMLElement>): void;
  42682. /**
  42683. * Gets the class name of the current input.
  42684. * @returns the class name
  42685. */
  42686. getClassName(): string;
  42687. /**
  42688. * Get the friendly name associated with the input class.
  42689. * @returns the input friendly name
  42690. */
  42691. getSimpleName(): string;
  42692. /**
  42693. * Called on pointer POINTERDOUBLETAP event.
  42694. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42695. */
  42696. protected onDoubleTap(type: string): void;
  42697. /**
  42698. * Called on pointer POINTERMOVE event if only a single touch is active.
  42699. * Override this method to provide functionality.
  42700. */
  42701. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42702. /**
  42703. * Called on pointer POINTERMOVE event if multiple touches are active.
  42704. * Override this method to provide functionality.
  42705. */
  42706. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42707. /**
  42708. * Called on JS contextmenu event.
  42709. * Override this method to provide functionality.
  42710. */
  42711. protected onContextMenu(evt: PointerEvent): void;
  42712. /**
  42713. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42714. * press.
  42715. * Override this method to provide functionality.
  42716. */
  42717. protected onButtonDown(evt: PointerEvent): void;
  42718. /**
  42719. * Called each time a new POINTERUP event occurs. Ie, for each button
  42720. * release.
  42721. * Override this method to provide functionality.
  42722. */
  42723. protected onButtonUp(evt: PointerEvent): void;
  42724. /**
  42725. * Called when window becomes inactive.
  42726. * Override this method to provide functionality.
  42727. */
  42728. protected onLostFocus(): void;
  42729. private _pointerInput;
  42730. private _observer;
  42731. private _onLostFocus;
  42732. private pointA;
  42733. private pointB;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * Manage the pointers inputs to control an arc rotate camera.
  42739. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42740. */
  42741. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42742. /**
  42743. * Defines the camera the input is attached to.
  42744. */
  42745. camera: ArcRotateCamera;
  42746. /**
  42747. * Gets the class name of the current input.
  42748. * @returns the class name
  42749. */
  42750. getClassName(): string;
  42751. /**
  42752. * Defines the buttons associated with the input to handle camera move.
  42753. */
  42754. buttons: number[];
  42755. /**
  42756. * Defines the pointer angular sensibility along the X axis or how fast is
  42757. * the camera rotating.
  42758. */
  42759. angularSensibilityX: number;
  42760. /**
  42761. * Defines the pointer angular sensibility along the Y axis or how fast is
  42762. * the camera rotating.
  42763. */
  42764. angularSensibilityY: number;
  42765. /**
  42766. * Defines the pointer pinch precision or how fast is the camera zooming.
  42767. */
  42768. pinchPrecision: number;
  42769. /**
  42770. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42771. * from 0.
  42772. * It defines the percentage of current camera.radius to use as delta when
  42773. * pinch zoom is used.
  42774. */
  42775. pinchDeltaPercentage: number;
  42776. /**
  42777. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42778. * that any object in the plane at the camera's target point will scale
  42779. * perfectly with finger motion.
  42780. * Overrides pinchDeltaPercentage and pinchPrecision.
  42781. */
  42782. useNaturalPinchZoom: boolean;
  42783. /**
  42784. * Defines the pointer panning sensibility or how fast is the camera moving.
  42785. */
  42786. panningSensibility: number;
  42787. /**
  42788. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42789. */
  42790. multiTouchPanning: boolean;
  42791. /**
  42792. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42793. * zoom (pinch) through multitouch.
  42794. */
  42795. multiTouchPanAndZoom: boolean;
  42796. /**
  42797. * Revers pinch action direction.
  42798. */
  42799. pinchInwards: boolean;
  42800. private _isPanClick;
  42801. private _twoFingerActivityCount;
  42802. private _isPinching;
  42803. /**
  42804. * Called on pointer POINTERMOVE event if only a single touch is active.
  42805. */
  42806. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42807. /**
  42808. * Called on pointer POINTERDOUBLETAP event.
  42809. */
  42810. protected onDoubleTap(type: string): void;
  42811. /**
  42812. * Called on pointer POINTERMOVE event if multiple touches are active.
  42813. */
  42814. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42815. /**
  42816. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42817. * press.
  42818. */
  42819. protected onButtonDown(evt: PointerEvent): void;
  42820. /**
  42821. * Called each time a new POINTERUP event occurs. Ie, for each button
  42822. * release.
  42823. */
  42824. protected onButtonUp(evt: PointerEvent): void;
  42825. /**
  42826. * Called when window becomes inactive.
  42827. */
  42828. protected onLostFocus(): void;
  42829. }
  42830. }
  42831. declare module BABYLON {
  42832. /**
  42833. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42834. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42835. */
  42836. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42837. /**
  42838. * Defines the camera the input is attached to.
  42839. */
  42840. camera: ArcRotateCamera;
  42841. /**
  42842. * Defines the list of key codes associated with the up action (increase alpha)
  42843. */
  42844. keysUp: number[];
  42845. /**
  42846. * Defines the list of key codes associated with the down action (decrease alpha)
  42847. */
  42848. keysDown: number[];
  42849. /**
  42850. * Defines the list of key codes associated with the left action (increase beta)
  42851. */
  42852. keysLeft: number[];
  42853. /**
  42854. * Defines the list of key codes associated with the right action (decrease beta)
  42855. */
  42856. keysRight: number[];
  42857. /**
  42858. * Defines the list of key codes associated with the reset action.
  42859. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42860. */
  42861. keysReset: number[];
  42862. /**
  42863. * Defines the panning sensibility of the inputs.
  42864. * (How fast is the camera panning)
  42865. */
  42866. panningSensibility: number;
  42867. /**
  42868. * Defines the zooming sensibility of the inputs.
  42869. * (How fast is the camera zooming)
  42870. */
  42871. zoomingSensibility: number;
  42872. /**
  42873. * Defines whether maintaining the alt key down switch the movement mode from
  42874. * orientation to zoom.
  42875. */
  42876. useAltToZoom: boolean;
  42877. /**
  42878. * Rotation speed of the camera
  42879. */
  42880. angularSpeed: number;
  42881. private _keys;
  42882. private _ctrlPressed;
  42883. private _altPressed;
  42884. private _onCanvasBlurObserver;
  42885. private _onKeyboardObserver;
  42886. private _engine;
  42887. private _scene;
  42888. /**
  42889. * Attach the input controls to a specific dom element to get the input from.
  42890. * @param element Defines the element the controls should be listened from
  42891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42892. */
  42893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42894. /**
  42895. * Detach the current controls from the specified dom element.
  42896. * @param element Defines the element to stop listening the inputs from
  42897. */
  42898. detachControl(element: Nullable<HTMLElement>): void;
  42899. /**
  42900. * Update the current camera state depending on the inputs that have been used this frame.
  42901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42902. */
  42903. checkInputs(): void;
  42904. /**
  42905. * Gets the class name of the current intput.
  42906. * @returns the class name
  42907. */
  42908. getClassName(): string;
  42909. /**
  42910. * Get the friendly name associated with the input class.
  42911. * @returns the input friendly name
  42912. */
  42913. getSimpleName(): string;
  42914. }
  42915. }
  42916. declare module BABYLON {
  42917. /**
  42918. * Manage the mouse wheel inputs to control an arc rotate camera.
  42919. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42920. */
  42921. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42922. /**
  42923. * Defines the camera the input is attached to.
  42924. */
  42925. camera: ArcRotateCamera;
  42926. /**
  42927. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42928. */
  42929. wheelPrecision: number;
  42930. /**
  42931. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42932. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42933. */
  42934. wheelDeltaPercentage: number;
  42935. private _wheel;
  42936. private _observer;
  42937. private computeDeltaFromMouseWheelLegacyEvent;
  42938. /**
  42939. * Attach the input controls to a specific dom element to get the input from.
  42940. * @param element Defines the element the controls should be listened from
  42941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42942. */
  42943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42944. /**
  42945. * Detach the current controls from the specified dom element.
  42946. * @param element Defines the element to stop listening the inputs from
  42947. */
  42948. detachControl(element: Nullable<HTMLElement>): void;
  42949. /**
  42950. * Gets the class name of the current intput.
  42951. * @returns the class name
  42952. */
  42953. getClassName(): string;
  42954. /**
  42955. * Get the friendly name associated with the input class.
  42956. * @returns the input friendly name
  42957. */
  42958. getSimpleName(): string;
  42959. }
  42960. }
  42961. declare module BABYLON {
  42962. /**
  42963. * Default Inputs manager for the ArcRotateCamera.
  42964. * It groups all the default supported inputs for ease of use.
  42965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42966. */
  42967. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42968. /**
  42969. * Instantiates a new ArcRotateCameraInputsManager.
  42970. * @param camera Defines the camera the inputs belong to
  42971. */
  42972. constructor(camera: ArcRotateCamera);
  42973. /**
  42974. * Add mouse wheel input support to the input manager.
  42975. * @returns the current input manager
  42976. */
  42977. addMouseWheel(): ArcRotateCameraInputsManager;
  42978. /**
  42979. * Add pointers input support to the input manager.
  42980. * @returns the current input manager
  42981. */
  42982. addPointers(): ArcRotateCameraInputsManager;
  42983. /**
  42984. * Add keyboard input support to the input manager.
  42985. * @returns the current input manager
  42986. */
  42987. addKeyboard(): ArcRotateCameraInputsManager;
  42988. }
  42989. }
  42990. declare module BABYLON {
  42991. /**
  42992. * This represents an orbital type of camera.
  42993. *
  42994. * 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.
  42995. * 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.
  42996. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42997. */
  42998. export class ArcRotateCamera extends TargetCamera {
  42999. /**
  43000. * Defines the rotation angle of the camera along the longitudinal axis.
  43001. */
  43002. alpha: number;
  43003. /**
  43004. * Defines the rotation angle of the camera along the latitudinal axis.
  43005. */
  43006. beta: number;
  43007. /**
  43008. * Defines the radius of the camera from it s target point.
  43009. */
  43010. radius: number;
  43011. protected _target: Vector3;
  43012. protected _targetHost: Nullable<AbstractMesh>;
  43013. /**
  43014. * Defines the target point of the camera.
  43015. * The camera looks towards it form the radius distance.
  43016. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  43017. */
  43018. get target(): Vector3;
  43019. set target(value: Vector3);
  43020. /**
  43021. * Define the current local position of the camera in the scene
  43022. */
  43023. get position(): Vector3;
  43024. set position(newPosition: Vector3);
  43025. protected _upToYMatrix: Matrix;
  43026. protected _YToUpMatrix: Matrix;
  43027. /**
  43028. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43029. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43030. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43031. */
  43032. set upVector(vec: Vector3);
  43033. get upVector(): Vector3;
  43034. /**
  43035. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43036. */
  43037. setMatUp(): void;
  43038. /**
  43039. * Current inertia value on the longitudinal axis.
  43040. * The bigger this number the longer it will take for the camera to stop.
  43041. */
  43042. inertialAlphaOffset: number;
  43043. /**
  43044. * Current inertia value on the latitudinal axis.
  43045. * The bigger this number the longer it will take for the camera to stop.
  43046. */
  43047. inertialBetaOffset: number;
  43048. /**
  43049. * Current inertia value on the radius axis.
  43050. * The bigger this number the longer it will take for the camera to stop.
  43051. */
  43052. inertialRadiusOffset: number;
  43053. /**
  43054. * Minimum allowed angle on the longitudinal axis.
  43055. * This can help limiting how the Camera is able to move in the scene.
  43056. */
  43057. lowerAlphaLimit: Nullable<number>;
  43058. /**
  43059. * Maximum allowed angle on the longitudinal axis.
  43060. * This can help limiting how the Camera is able to move in the scene.
  43061. */
  43062. upperAlphaLimit: Nullable<number>;
  43063. /**
  43064. * Minimum allowed angle on the latitudinal axis.
  43065. * This can help limiting how the Camera is able to move in the scene.
  43066. */
  43067. lowerBetaLimit: number;
  43068. /**
  43069. * Maximum allowed angle on the latitudinal axis.
  43070. * This can help limiting how the Camera is able to move in the scene.
  43071. */
  43072. upperBetaLimit: number;
  43073. /**
  43074. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43075. * This can help limiting how the Camera is able to move in the scene.
  43076. */
  43077. lowerRadiusLimit: Nullable<number>;
  43078. /**
  43079. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43080. * This can help limiting how the Camera is able to move in the scene.
  43081. */
  43082. upperRadiusLimit: Nullable<number>;
  43083. /**
  43084. * Defines the current inertia value used during panning of the camera along the X axis.
  43085. */
  43086. inertialPanningX: number;
  43087. /**
  43088. * Defines the current inertia value used during panning of the camera along the Y axis.
  43089. */
  43090. inertialPanningY: number;
  43091. /**
  43092. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43093. * Basically if your fingers moves away from more than this distance you will be considered
  43094. * in pinch mode.
  43095. */
  43096. pinchToPanMaxDistance: number;
  43097. /**
  43098. * Defines the maximum distance the camera can pan.
  43099. * This could help keeping the cammera always in your scene.
  43100. */
  43101. panningDistanceLimit: Nullable<number>;
  43102. /**
  43103. * Defines the target of the camera before paning.
  43104. */
  43105. panningOriginTarget: Vector3;
  43106. /**
  43107. * Defines the value of the inertia used during panning.
  43108. * 0 would mean stop inertia and one would mean no decelleration at all.
  43109. */
  43110. panningInertia: number;
  43111. /**
  43112. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43113. */
  43114. get angularSensibilityX(): number;
  43115. set angularSensibilityX(value: number);
  43116. /**
  43117. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43118. */
  43119. get angularSensibilityY(): number;
  43120. set angularSensibilityY(value: number);
  43121. /**
  43122. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43123. */
  43124. get pinchPrecision(): number;
  43125. set pinchPrecision(value: number);
  43126. /**
  43127. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43128. * It will be used instead of pinchDeltaPrecision if different from 0.
  43129. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43130. */
  43131. get pinchDeltaPercentage(): number;
  43132. set pinchDeltaPercentage(value: number);
  43133. /**
  43134. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43135. * and pinch delta percentage.
  43136. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43137. * that any object in the plane at the camera's target point will scale
  43138. * perfectly with finger motion.
  43139. */
  43140. get useNaturalPinchZoom(): boolean;
  43141. set useNaturalPinchZoom(value: boolean);
  43142. /**
  43143. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43144. */
  43145. get panningSensibility(): number;
  43146. set panningSensibility(value: number);
  43147. /**
  43148. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43149. */
  43150. get keysUp(): number[];
  43151. set keysUp(value: number[]);
  43152. /**
  43153. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43154. */
  43155. get keysDown(): number[];
  43156. set keysDown(value: number[]);
  43157. /**
  43158. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43159. */
  43160. get keysLeft(): number[];
  43161. set keysLeft(value: number[]);
  43162. /**
  43163. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43164. */
  43165. get keysRight(): number[];
  43166. set keysRight(value: number[]);
  43167. /**
  43168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43169. */
  43170. get wheelPrecision(): number;
  43171. set wheelPrecision(value: number);
  43172. /**
  43173. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43174. * It will be used instead of pinchDeltaPrecision if different from 0.
  43175. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43176. */
  43177. get wheelDeltaPercentage(): number;
  43178. set wheelDeltaPercentage(value: number);
  43179. /**
  43180. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43181. */
  43182. zoomOnFactor: number;
  43183. /**
  43184. * Defines a screen offset for the camera position.
  43185. */
  43186. targetScreenOffset: Vector2;
  43187. /**
  43188. * Allows the camera to be completely reversed.
  43189. * If false the camera can not arrive upside down.
  43190. */
  43191. allowUpsideDown: boolean;
  43192. /**
  43193. * Define if double tap/click is used to restore the previously saved state of the camera.
  43194. */
  43195. useInputToRestoreState: boolean;
  43196. /** @hidden */
  43197. _viewMatrix: Matrix;
  43198. /** @hidden */
  43199. _useCtrlForPanning: boolean;
  43200. /** @hidden */
  43201. _panningMouseButton: number;
  43202. /**
  43203. * Defines the input associated to the camera.
  43204. */
  43205. inputs: ArcRotateCameraInputsManager;
  43206. /** @hidden */
  43207. _reset: () => void;
  43208. /**
  43209. * Defines the allowed panning axis.
  43210. */
  43211. panningAxis: Vector3;
  43212. protected _localDirection: Vector3;
  43213. protected _transformedDirection: Vector3;
  43214. private _bouncingBehavior;
  43215. /**
  43216. * Gets the bouncing behavior of the camera if it has been enabled.
  43217. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43218. */
  43219. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43220. /**
  43221. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43222. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43223. */
  43224. get useBouncingBehavior(): boolean;
  43225. set useBouncingBehavior(value: boolean);
  43226. private _framingBehavior;
  43227. /**
  43228. * Gets the framing behavior of the camera if it has been enabled.
  43229. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43230. */
  43231. get framingBehavior(): Nullable<FramingBehavior>;
  43232. /**
  43233. * Defines if the framing behavior of the camera is enabled on the camera.
  43234. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43235. */
  43236. get useFramingBehavior(): boolean;
  43237. set useFramingBehavior(value: boolean);
  43238. private _autoRotationBehavior;
  43239. /**
  43240. * Gets the auto rotation behavior of the camera if it has been enabled.
  43241. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43242. */
  43243. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43244. /**
  43245. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43246. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43247. */
  43248. get useAutoRotationBehavior(): boolean;
  43249. set useAutoRotationBehavior(value: boolean);
  43250. /**
  43251. * Observable triggered when the mesh target has been changed on the camera.
  43252. */
  43253. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43254. /**
  43255. * Event raised when the camera is colliding with a mesh.
  43256. */
  43257. onCollide: (collidedMesh: AbstractMesh) => void;
  43258. /**
  43259. * Defines whether the camera should check collision with the objects oh the scene.
  43260. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43261. */
  43262. checkCollisions: boolean;
  43263. /**
  43264. * Defines the collision radius of the camera.
  43265. * This simulates a sphere around the camera.
  43266. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43267. */
  43268. collisionRadius: Vector3;
  43269. protected _collider: Collider;
  43270. protected _previousPosition: Vector3;
  43271. protected _collisionVelocity: Vector3;
  43272. protected _newPosition: Vector3;
  43273. protected _previousAlpha: number;
  43274. protected _previousBeta: number;
  43275. protected _previousRadius: number;
  43276. protected _collisionTriggered: boolean;
  43277. protected _targetBoundingCenter: Nullable<Vector3>;
  43278. private _computationVector;
  43279. /**
  43280. * Instantiates a new ArcRotateCamera in a given scene
  43281. * @param name Defines the name of the camera
  43282. * @param alpha Defines the camera rotation along the logitudinal axis
  43283. * @param beta Defines the camera rotation along the latitudinal axis
  43284. * @param radius Defines the camera distance from its target
  43285. * @param target Defines the camera target
  43286. * @param scene Defines the scene the camera belongs to
  43287. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43288. */
  43289. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43290. /** @hidden */
  43291. _initCache(): void;
  43292. /** @hidden */
  43293. _updateCache(ignoreParentClass?: boolean): void;
  43294. protected _getTargetPosition(): Vector3;
  43295. private _storedAlpha;
  43296. private _storedBeta;
  43297. private _storedRadius;
  43298. private _storedTarget;
  43299. private _storedTargetScreenOffset;
  43300. /**
  43301. * Stores the current state of the camera (alpha, beta, radius and target)
  43302. * @returns the camera itself
  43303. */
  43304. storeState(): Camera;
  43305. /**
  43306. * @hidden
  43307. * Restored camera state. You must call storeState() first
  43308. */
  43309. _restoreStateValues(): boolean;
  43310. /** @hidden */
  43311. _isSynchronizedViewMatrix(): boolean;
  43312. /**
  43313. * Attached controls to the current camera.
  43314. * @param element Defines the element the controls should be listened from
  43315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43316. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43317. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43318. */
  43319. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43320. /**
  43321. * Detach the current controls from the camera.
  43322. * The camera will stop reacting to inputs.
  43323. * @param element Defines the element to stop listening the inputs from
  43324. */
  43325. detachControl(element: HTMLElement): void;
  43326. /** @hidden */
  43327. _checkInputs(): void;
  43328. protected _checkLimits(): void;
  43329. /**
  43330. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43331. */
  43332. rebuildAnglesAndRadius(): void;
  43333. /**
  43334. * Use a position to define the current camera related information like alpha, beta and radius
  43335. * @param position Defines the position to set the camera at
  43336. */
  43337. setPosition(position: Vector3): void;
  43338. /**
  43339. * Defines the target the camera should look at.
  43340. * This will automatically adapt alpha beta and radius to fit within the new target.
  43341. * @param target Defines the new target as a Vector or a mesh
  43342. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43343. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43344. */
  43345. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43346. /** @hidden */
  43347. _getViewMatrix(): Matrix;
  43348. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43349. /**
  43350. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43351. * @param meshes Defines the mesh to zoom on
  43352. * @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)
  43353. */
  43354. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43355. /**
  43356. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43357. * The target will be changed but the radius
  43358. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43359. * @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)
  43360. */
  43361. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43362. min: Vector3;
  43363. max: Vector3;
  43364. distance: number;
  43365. }, doNotUpdateMaxZ?: boolean): void;
  43366. /**
  43367. * @override
  43368. * Override Camera.createRigCamera
  43369. */
  43370. createRigCamera(name: string, cameraIndex: number): Camera;
  43371. /**
  43372. * @hidden
  43373. * @override
  43374. * Override Camera._updateRigCameras
  43375. */
  43376. _updateRigCameras(): void;
  43377. /**
  43378. * Destroy the camera and release the current resources hold by it.
  43379. */
  43380. dispose(): void;
  43381. /**
  43382. * Gets the current object class name.
  43383. * @return the class name
  43384. */
  43385. getClassName(): string;
  43386. }
  43387. }
  43388. declare module BABYLON {
  43389. /**
  43390. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43391. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43392. */
  43393. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43394. /**
  43395. * Gets the name of the behavior.
  43396. */
  43397. get name(): string;
  43398. private _zoomStopsAnimation;
  43399. private _idleRotationSpeed;
  43400. private _idleRotationWaitTime;
  43401. private _idleRotationSpinupTime;
  43402. /**
  43403. * Sets the flag that indicates if user zooming should stop animation.
  43404. */
  43405. set zoomStopsAnimation(flag: boolean);
  43406. /**
  43407. * Gets the flag that indicates if user zooming should stop animation.
  43408. */
  43409. get zoomStopsAnimation(): boolean;
  43410. /**
  43411. * Sets the default speed at which the camera rotates around the model.
  43412. */
  43413. set idleRotationSpeed(speed: number);
  43414. /**
  43415. * Gets the default speed at which the camera rotates around the model.
  43416. */
  43417. get idleRotationSpeed(): number;
  43418. /**
  43419. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43420. */
  43421. set idleRotationWaitTime(time: number);
  43422. /**
  43423. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43424. */
  43425. get idleRotationWaitTime(): number;
  43426. /**
  43427. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43428. */
  43429. set idleRotationSpinupTime(time: number);
  43430. /**
  43431. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43432. */
  43433. get idleRotationSpinupTime(): number;
  43434. /**
  43435. * Gets a value indicating if the camera is currently rotating because of this behavior
  43436. */
  43437. get rotationInProgress(): boolean;
  43438. private _onPrePointerObservableObserver;
  43439. private _onAfterCheckInputsObserver;
  43440. private _attachedCamera;
  43441. private _isPointerDown;
  43442. private _lastFrameTime;
  43443. private _lastInteractionTime;
  43444. private _cameraRotationSpeed;
  43445. /**
  43446. * Initializes the behavior.
  43447. */
  43448. init(): void;
  43449. /**
  43450. * Attaches the behavior to its arc rotate camera.
  43451. * @param camera Defines the camera to attach the behavior to
  43452. */
  43453. attach(camera: ArcRotateCamera): void;
  43454. /**
  43455. * Detaches the behavior from its current arc rotate camera.
  43456. */
  43457. detach(): void;
  43458. /**
  43459. * Returns true if user is scrolling.
  43460. * @return true if user is scrolling.
  43461. */
  43462. private _userIsZooming;
  43463. private _lastFrameRadius;
  43464. private _shouldAnimationStopForInteraction;
  43465. /**
  43466. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43467. */
  43468. private _applyUserInteraction;
  43469. private _userIsMoving;
  43470. }
  43471. }
  43472. declare module BABYLON {
  43473. /**
  43474. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43475. */
  43476. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43477. private ui;
  43478. /**
  43479. * The name of the behavior
  43480. */
  43481. name: string;
  43482. /**
  43483. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43484. */
  43485. distanceAwayFromFace: number;
  43486. /**
  43487. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43488. */
  43489. distanceAwayFromBottomOfFace: number;
  43490. private _faceVectors;
  43491. private _target;
  43492. private _scene;
  43493. private _onRenderObserver;
  43494. private _tmpMatrix;
  43495. private _tmpVector;
  43496. /**
  43497. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43498. * @param ui The transform node that should be attched to the mesh
  43499. */
  43500. constructor(ui: TransformNode);
  43501. /**
  43502. * Initializes the behavior
  43503. */
  43504. init(): void;
  43505. private _closestFace;
  43506. private _zeroVector;
  43507. private _lookAtTmpMatrix;
  43508. private _lookAtToRef;
  43509. /**
  43510. * Attaches the AttachToBoxBehavior to the passed in mesh
  43511. * @param target The mesh that the specified node will be attached to
  43512. */
  43513. attach(target: Mesh): void;
  43514. /**
  43515. * Detaches the behavior from the mesh
  43516. */
  43517. detach(): void;
  43518. }
  43519. }
  43520. declare module BABYLON {
  43521. /**
  43522. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43523. */
  43524. export class FadeInOutBehavior implements Behavior<Mesh> {
  43525. /**
  43526. * Time in milliseconds to delay before fading in (Default: 0)
  43527. */
  43528. delay: number;
  43529. /**
  43530. * Time in milliseconds for the mesh to fade in (Default: 300)
  43531. */
  43532. fadeInTime: number;
  43533. private _millisecondsPerFrame;
  43534. private _hovered;
  43535. private _hoverValue;
  43536. private _ownerNode;
  43537. /**
  43538. * Instatiates the FadeInOutBehavior
  43539. */
  43540. constructor();
  43541. /**
  43542. * The name of the behavior
  43543. */
  43544. get name(): string;
  43545. /**
  43546. * Initializes the behavior
  43547. */
  43548. init(): void;
  43549. /**
  43550. * Attaches the fade behavior on the passed in mesh
  43551. * @param ownerNode The mesh that will be faded in/out once attached
  43552. */
  43553. attach(ownerNode: Mesh): void;
  43554. /**
  43555. * Detaches the behavior from the mesh
  43556. */
  43557. detach(): void;
  43558. /**
  43559. * Triggers the mesh to begin fading in or out
  43560. * @param value if the object should fade in or out (true to fade in)
  43561. */
  43562. fadeIn(value: boolean): void;
  43563. private _update;
  43564. private _setAllVisibility;
  43565. }
  43566. }
  43567. declare module BABYLON {
  43568. /**
  43569. * Class containing a set of static utilities functions for managing Pivots
  43570. * @hidden
  43571. */
  43572. export class PivotTools {
  43573. private static _PivotCached;
  43574. private static _OldPivotPoint;
  43575. private static _PivotTranslation;
  43576. private static _PivotTmpVector;
  43577. private static _PivotPostMultiplyPivotMatrix;
  43578. /** @hidden */
  43579. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43580. /** @hidden */
  43581. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43582. }
  43583. }
  43584. declare module BABYLON {
  43585. /**
  43586. * Class containing static functions to help procedurally build meshes
  43587. */
  43588. export class PlaneBuilder {
  43589. /**
  43590. * Creates a plane mesh
  43591. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43592. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43593. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43595. * * 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
  43596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43597. * @param name defines the name of the mesh
  43598. * @param options defines the options used to create the mesh
  43599. * @param scene defines the hosting scene
  43600. * @returns the plane mesh
  43601. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43602. */
  43603. static CreatePlane(name: string, options: {
  43604. size?: number;
  43605. width?: number;
  43606. height?: number;
  43607. sideOrientation?: number;
  43608. frontUVs?: Vector4;
  43609. backUVs?: Vector4;
  43610. updatable?: boolean;
  43611. sourcePlane?: Plane;
  43612. }, scene?: Nullable<Scene>): Mesh;
  43613. }
  43614. }
  43615. declare module BABYLON {
  43616. /**
  43617. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43618. */
  43619. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43620. private static _AnyMouseID;
  43621. /**
  43622. * Abstract mesh the behavior is set on
  43623. */
  43624. attachedNode: AbstractMesh;
  43625. private _dragPlane;
  43626. private _scene;
  43627. private _pointerObserver;
  43628. private _beforeRenderObserver;
  43629. private static _planeScene;
  43630. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43631. /**
  43632. * 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)
  43633. */
  43634. maxDragAngle: number;
  43635. /**
  43636. * @hidden
  43637. */
  43638. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43639. /**
  43640. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43641. */
  43642. currentDraggingPointerID: number;
  43643. /**
  43644. * The last position where the pointer hit the drag plane in world space
  43645. */
  43646. lastDragPosition: Vector3;
  43647. /**
  43648. * If the behavior is currently in a dragging state
  43649. */
  43650. dragging: boolean;
  43651. /**
  43652. * 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)
  43653. */
  43654. dragDeltaRatio: number;
  43655. /**
  43656. * If the drag plane orientation should be updated during the dragging (Default: true)
  43657. */
  43658. updateDragPlane: boolean;
  43659. private _debugMode;
  43660. private _moving;
  43661. /**
  43662. * Fires each time the attached mesh is dragged with the pointer
  43663. * * delta between last drag position and current drag position in world space
  43664. * * dragDistance along the drag axis
  43665. * * dragPlaneNormal normal of the current drag plane used during the drag
  43666. * * dragPlanePoint in world space where the drag intersects the drag plane
  43667. */
  43668. onDragObservable: Observable<{
  43669. delta: Vector3;
  43670. dragPlanePoint: Vector3;
  43671. dragPlaneNormal: Vector3;
  43672. dragDistance: number;
  43673. pointerId: number;
  43674. }>;
  43675. /**
  43676. * Fires each time a drag begins (eg. mouse down on mesh)
  43677. */
  43678. onDragStartObservable: Observable<{
  43679. dragPlanePoint: Vector3;
  43680. pointerId: number;
  43681. }>;
  43682. /**
  43683. * Fires each time a drag ends (eg. mouse release after drag)
  43684. */
  43685. onDragEndObservable: Observable<{
  43686. dragPlanePoint: Vector3;
  43687. pointerId: number;
  43688. }>;
  43689. /**
  43690. * If the attached mesh should be moved when dragged
  43691. */
  43692. moveAttached: boolean;
  43693. /**
  43694. * If the drag behavior will react to drag events (Default: true)
  43695. */
  43696. enabled: boolean;
  43697. /**
  43698. * If pointer events should start and release the drag (Default: true)
  43699. */
  43700. startAndReleaseDragOnPointerEvents: boolean;
  43701. /**
  43702. * If camera controls should be detached during the drag
  43703. */
  43704. detachCameraControls: boolean;
  43705. /**
  43706. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43707. */
  43708. useObjectOrientationForDragging: boolean;
  43709. private _options;
  43710. /**
  43711. * Gets the options used by the behavior
  43712. */
  43713. get options(): {
  43714. dragAxis?: Vector3;
  43715. dragPlaneNormal?: Vector3;
  43716. };
  43717. /**
  43718. * Sets the options used by the behavior
  43719. */
  43720. set options(options: {
  43721. dragAxis?: Vector3;
  43722. dragPlaneNormal?: Vector3;
  43723. });
  43724. /**
  43725. * Creates a pointer drag behavior that can be attached to a mesh
  43726. * @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)
  43727. */
  43728. constructor(options?: {
  43729. dragAxis?: Vector3;
  43730. dragPlaneNormal?: Vector3;
  43731. });
  43732. /**
  43733. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43734. */
  43735. validateDrag: (targetPosition: Vector3) => boolean;
  43736. /**
  43737. * The name of the behavior
  43738. */
  43739. get name(): string;
  43740. /**
  43741. * Initializes the behavior
  43742. */
  43743. init(): void;
  43744. private _tmpVector;
  43745. private _alternatePickedPoint;
  43746. private _worldDragAxis;
  43747. private _targetPosition;
  43748. private _attachedElement;
  43749. /**
  43750. * Attaches the drag behavior the passed in mesh
  43751. * @param ownerNode The mesh that will be dragged around once attached
  43752. * @param predicate Predicate to use for pick filtering
  43753. */
  43754. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43755. /**
  43756. * Force relase the drag action by code.
  43757. */
  43758. releaseDrag(): void;
  43759. private _startDragRay;
  43760. private _lastPointerRay;
  43761. /**
  43762. * Simulates the start of a pointer drag event on the behavior
  43763. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43764. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43765. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43766. */
  43767. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43768. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43769. private _dragDelta;
  43770. protected _moveDrag(ray: Ray): void;
  43771. private _pickWithRayOnDragPlane;
  43772. private _pointA;
  43773. private _pointC;
  43774. private _localAxis;
  43775. private _lookAt;
  43776. private _updateDragPlanePosition;
  43777. /**
  43778. * Detaches the behavior from the mesh
  43779. */
  43780. detach(): void;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43786. */
  43787. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43788. private _dragBehaviorA;
  43789. private _dragBehaviorB;
  43790. private _startDistance;
  43791. private _initialScale;
  43792. private _targetScale;
  43793. private _ownerNode;
  43794. private _sceneRenderObserver;
  43795. /**
  43796. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43797. */
  43798. constructor();
  43799. /**
  43800. * The name of the behavior
  43801. */
  43802. get name(): string;
  43803. /**
  43804. * Initializes the behavior
  43805. */
  43806. init(): void;
  43807. private _getCurrentDistance;
  43808. /**
  43809. * Attaches the scale behavior the passed in mesh
  43810. * @param ownerNode The mesh that will be scaled around once attached
  43811. */
  43812. attach(ownerNode: Mesh): void;
  43813. /**
  43814. * Detaches the behavior from the mesh
  43815. */
  43816. detach(): void;
  43817. }
  43818. }
  43819. declare module BABYLON {
  43820. /**
  43821. * 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
  43822. */
  43823. export class SixDofDragBehavior implements Behavior<Mesh> {
  43824. private static _virtualScene;
  43825. private _ownerNode;
  43826. private _sceneRenderObserver;
  43827. private _scene;
  43828. private _targetPosition;
  43829. private _virtualOriginMesh;
  43830. private _virtualDragMesh;
  43831. private _pointerObserver;
  43832. private _moving;
  43833. private _startingOrientation;
  43834. private _attachedElement;
  43835. /**
  43836. * 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)
  43837. */
  43838. private zDragFactor;
  43839. /**
  43840. * If the object should rotate to face the drag origin
  43841. */
  43842. rotateDraggedObject: boolean;
  43843. /**
  43844. * If the behavior is currently in a dragging state
  43845. */
  43846. dragging: boolean;
  43847. /**
  43848. * 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)
  43849. */
  43850. dragDeltaRatio: number;
  43851. /**
  43852. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43853. */
  43854. currentDraggingPointerID: number;
  43855. /**
  43856. * If camera controls should be detached during the drag
  43857. */
  43858. detachCameraControls: boolean;
  43859. /**
  43860. * Fires each time a drag starts
  43861. */
  43862. onDragStartObservable: Observable<{}>;
  43863. /**
  43864. * Fires each time a drag ends (eg. mouse release after drag)
  43865. */
  43866. onDragEndObservable: Observable<{}>;
  43867. /**
  43868. * 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
  43869. */
  43870. constructor();
  43871. /**
  43872. * The name of the behavior
  43873. */
  43874. get name(): string;
  43875. /**
  43876. * Initializes the behavior
  43877. */
  43878. init(): void;
  43879. /**
  43880. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43881. */
  43882. private get _pointerCamera();
  43883. /**
  43884. * Attaches the scale behavior the passed in mesh
  43885. * @param ownerNode The mesh that will be scaled around once attached
  43886. */
  43887. attach(ownerNode: Mesh): void;
  43888. /**
  43889. * Detaches the behavior from the mesh
  43890. */
  43891. detach(): void;
  43892. }
  43893. }
  43894. declare module BABYLON {
  43895. /**
  43896. * Class used to apply inverse kinematics to bones
  43897. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43898. */
  43899. export class BoneIKController {
  43900. private static _tmpVecs;
  43901. private static _tmpQuat;
  43902. private static _tmpMats;
  43903. /**
  43904. * Gets or sets the target mesh
  43905. */
  43906. targetMesh: AbstractMesh;
  43907. /** Gets or sets the mesh used as pole */
  43908. poleTargetMesh: AbstractMesh;
  43909. /**
  43910. * Gets or sets the bone used as pole
  43911. */
  43912. poleTargetBone: Nullable<Bone>;
  43913. /**
  43914. * Gets or sets the target position
  43915. */
  43916. targetPosition: Vector3;
  43917. /**
  43918. * Gets or sets the pole target position
  43919. */
  43920. poleTargetPosition: Vector3;
  43921. /**
  43922. * Gets or sets the pole target local offset
  43923. */
  43924. poleTargetLocalOffset: Vector3;
  43925. /**
  43926. * Gets or sets the pole angle
  43927. */
  43928. poleAngle: number;
  43929. /**
  43930. * Gets or sets the mesh associated with the controller
  43931. */
  43932. mesh: AbstractMesh;
  43933. /**
  43934. * 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)
  43935. */
  43936. slerpAmount: number;
  43937. private _bone1Quat;
  43938. private _bone1Mat;
  43939. private _bone2Ang;
  43940. private _bone1;
  43941. private _bone2;
  43942. private _bone1Length;
  43943. private _bone2Length;
  43944. private _maxAngle;
  43945. private _maxReach;
  43946. private _rightHandedSystem;
  43947. private _bendAxis;
  43948. private _slerping;
  43949. private _adjustRoll;
  43950. /**
  43951. * Gets or sets maximum allowed angle
  43952. */
  43953. get maxAngle(): number;
  43954. set maxAngle(value: number);
  43955. /**
  43956. * Creates a new BoneIKController
  43957. * @param mesh defines the mesh to control
  43958. * @param bone defines the bone to control
  43959. * @param options defines options to set up the controller
  43960. */
  43961. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43962. targetMesh?: AbstractMesh;
  43963. poleTargetMesh?: AbstractMesh;
  43964. poleTargetBone?: Bone;
  43965. poleTargetLocalOffset?: Vector3;
  43966. poleAngle?: number;
  43967. bendAxis?: Vector3;
  43968. maxAngle?: number;
  43969. slerpAmount?: number;
  43970. });
  43971. private _setMaxAngle;
  43972. /**
  43973. * Force the controller to update the bones
  43974. */
  43975. update(): void;
  43976. }
  43977. }
  43978. declare module BABYLON {
  43979. /**
  43980. * Class used to make a bone look toward a point in space
  43981. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43982. */
  43983. export class BoneLookController {
  43984. private static _tmpVecs;
  43985. private static _tmpQuat;
  43986. private static _tmpMats;
  43987. /**
  43988. * The target Vector3 that the bone will look at
  43989. */
  43990. target: Vector3;
  43991. /**
  43992. * The mesh that the bone is attached to
  43993. */
  43994. mesh: AbstractMesh;
  43995. /**
  43996. * The bone that will be looking to the target
  43997. */
  43998. bone: Bone;
  43999. /**
  44000. * The up axis of the coordinate system that is used when the bone is rotated
  44001. */
  44002. upAxis: Vector3;
  44003. /**
  44004. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44005. */
  44006. upAxisSpace: Space;
  44007. /**
  44008. * Used to make an adjustment to the yaw of the bone
  44009. */
  44010. adjustYaw: number;
  44011. /**
  44012. * Used to make an adjustment to the pitch of the bone
  44013. */
  44014. adjustPitch: number;
  44015. /**
  44016. * Used to make an adjustment to the roll of the bone
  44017. */
  44018. adjustRoll: number;
  44019. /**
  44020. * 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)
  44021. */
  44022. slerpAmount: number;
  44023. private _minYaw;
  44024. private _maxYaw;
  44025. private _minPitch;
  44026. private _maxPitch;
  44027. private _minYawSin;
  44028. private _minYawCos;
  44029. private _maxYawSin;
  44030. private _maxYawCos;
  44031. private _midYawConstraint;
  44032. private _minPitchTan;
  44033. private _maxPitchTan;
  44034. private _boneQuat;
  44035. private _slerping;
  44036. private _transformYawPitch;
  44037. private _transformYawPitchInv;
  44038. private _firstFrameSkipped;
  44039. private _yawRange;
  44040. private _fowardAxis;
  44041. /**
  44042. * Gets or sets the minimum yaw angle that the bone can look to
  44043. */
  44044. get minYaw(): number;
  44045. set minYaw(value: number);
  44046. /**
  44047. * Gets or sets the maximum yaw angle that the bone can look to
  44048. */
  44049. get maxYaw(): number;
  44050. set maxYaw(value: number);
  44051. /**
  44052. * Gets or sets the minimum pitch angle that the bone can look to
  44053. */
  44054. get minPitch(): number;
  44055. set minPitch(value: number);
  44056. /**
  44057. * Gets or sets the maximum pitch angle that the bone can look to
  44058. */
  44059. get maxPitch(): number;
  44060. set maxPitch(value: number);
  44061. /**
  44062. * Create a BoneLookController
  44063. * @param mesh the mesh that the bone belongs to
  44064. * @param bone the bone that will be looking to the target
  44065. * @param target the target Vector3 to look at
  44066. * @param options optional settings:
  44067. * * maxYaw: the maximum angle the bone will yaw to
  44068. * * minYaw: the minimum angle the bone will yaw to
  44069. * * maxPitch: the maximum angle the bone will pitch to
  44070. * * minPitch: the minimum angle the bone will yaw to
  44071. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44072. * * upAxis: the up axis of the coordinate system
  44073. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44074. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44075. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44076. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44077. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44078. * * adjustRoll: used to make an adjustment to the roll of the bone
  44079. **/
  44080. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44081. maxYaw?: number;
  44082. minYaw?: number;
  44083. maxPitch?: number;
  44084. minPitch?: number;
  44085. slerpAmount?: number;
  44086. upAxis?: Vector3;
  44087. upAxisSpace?: Space;
  44088. yawAxis?: Vector3;
  44089. pitchAxis?: Vector3;
  44090. adjustYaw?: number;
  44091. adjustPitch?: number;
  44092. adjustRoll?: number;
  44093. });
  44094. /**
  44095. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44096. */
  44097. update(): void;
  44098. private _getAngleDiff;
  44099. private _getAngleBetween;
  44100. private _isAngleBetween;
  44101. }
  44102. }
  44103. declare module BABYLON {
  44104. /**
  44105. * Manage the gamepad inputs to control an arc rotate camera.
  44106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44107. */
  44108. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44109. /**
  44110. * Defines the camera the input is attached to.
  44111. */
  44112. camera: ArcRotateCamera;
  44113. /**
  44114. * Defines the gamepad the input is gathering event from.
  44115. */
  44116. gamepad: Nullable<Gamepad>;
  44117. /**
  44118. * Defines the gamepad rotation sensiblity.
  44119. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44120. */
  44121. gamepadRotationSensibility: number;
  44122. /**
  44123. * Defines the gamepad move sensiblity.
  44124. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44125. */
  44126. gamepadMoveSensibility: number;
  44127. private _yAxisScale;
  44128. /**
  44129. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44130. */
  44131. get invertYAxis(): boolean;
  44132. set invertYAxis(value: boolean);
  44133. private _onGamepadConnectedObserver;
  44134. private _onGamepadDisconnectedObserver;
  44135. /**
  44136. * Attach the input controls to a specific dom element to get the input from.
  44137. * @param element Defines the element the controls should be listened from
  44138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44139. */
  44140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44141. /**
  44142. * Detach the current controls from the specified dom element.
  44143. * @param element Defines the element to stop listening the inputs from
  44144. */
  44145. detachControl(element: Nullable<HTMLElement>): void;
  44146. /**
  44147. * Update the current camera state depending on the inputs that have been used this frame.
  44148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44149. */
  44150. checkInputs(): void;
  44151. /**
  44152. * Gets the class name of the current intput.
  44153. * @returns the class name
  44154. */
  44155. getClassName(): string;
  44156. /**
  44157. * Get the friendly name associated with the input class.
  44158. * @returns the input friendly name
  44159. */
  44160. getSimpleName(): string;
  44161. }
  44162. }
  44163. declare module BABYLON {
  44164. interface ArcRotateCameraInputsManager {
  44165. /**
  44166. * Add orientation input support to the input manager.
  44167. * @returns the current input manager
  44168. */
  44169. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44170. }
  44171. /**
  44172. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44173. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44174. */
  44175. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44176. /**
  44177. * Defines the camera the input is attached to.
  44178. */
  44179. camera: ArcRotateCamera;
  44180. /**
  44181. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44182. */
  44183. alphaCorrection: number;
  44184. /**
  44185. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44186. */
  44187. gammaCorrection: number;
  44188. private _alpha;
  44189. private _gamma;
  44190. private _dirty;
  44191. private _deviceOrientationHandler;
  44192. /**
  44193. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44194. */
  44195. constructor();
  44196. /**
  44197. * Attach the input controls to a specific dom element to get the input from.
  44198. * @param element Defines the element the controls should be listened from
  44199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44200. */
  44201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44202. /** @hidden */
  44203. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44204. /**
  44205. * Update the current camera state depending on the inputs that have been used this frame.
  44206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44207. */
  44208. checkInputs(): void;
  44209. /**
  44210. * Detach the current controls from the specified dom element.
  44211. * @param element Defines the element to stop listening the inputs from
  44212. */
  44213. detachControl(element: Nullable<HTMLElement>): void;
  44214. /**
  44215. * Gets the class name of the current intput.
  44216. * @returns the class name
  44217. */
  44218. getClassName(): string;
  44219. /**
  44220. * Get the friendly name associated with the input class.
  44221. * @returns the input friendly name
  44222. */
  44223. getSimpleName(): string;
  44224. }
  44225. }
  44226. declare module BABYLON {
  44227. /**
  44228. * Listen to mouse events to control the camera.
  44229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44230. */
  44231. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44232. /**
  44233. * Defines the camera the input is attached to.
  44234. */
  44235. camera: FlyCamera;
  44236. /**
  44237. * Defines if touch is enabled. (Default is true.)
  44238. */
  44239. touchEnabled: boolean;
  44240. /**
  44241. * Defines the buttons associated with the input to handle camera rotation.
  44242. */
  44243. buttons: number[];
  44244. /**
  44245. * Assign buttons for Yaw control.
  44246. */
  44247. buttonsYaw: number[];
  44248. /**
  44249. * Assign buttons for Pitch control.
  44250. */
  44251. buttonsPitch: number[];
  44252. /**
  44253. * Assign buttons for Roll control.
  44254. */
  44255. buttonsRoll: number[];
  44256. /**
  44257. * Detect if any button is being pressed while mouse is moved.
  44258. * -1 = Mouse locked.
  44259. * 0 = Left button.
  44260. * 1 = Middle Button.
  44261. * 2 = Right Button.
  44262. */
  44263. activeButton: number;
  44264. /**
  44265. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44266. * Higher values reduce its sensitivity.
  44267. */
  44268. angularSensibility: number;
  44269. private _mousemoveCallback;
  44270. private _observer;
  44271. private _rollObserver;
  44272. private previousPosition;
  44273. private noPreventDefault;
  44274. private element;
  44275. /**
  44276. * Listen to mouse events to control the camera.
  44277. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44278. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44279. */
  44280. constructor(touchEnabled?: boolean);
  44281. /**
  44282. * Attach the mouse control to the HTML DOM element.
  44283. * @param element Defines the element that listens to the input events.
  44284. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44285. */
  44286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44287. /**
  44288. * Detach the current controls from the specified dom element.
  44289. * @param element Defines the element to stop listening the inputs from
  44290. */
  44291. detachControl(element: Nullable<HTMLElement>): void;
  44292. /**
  44293. * Gets the class name of the current input.
  44294. * @returns the class name.
  44295. */
  44296. getClassName(): string;
  44297. /**
  44298. * Get the friendly name associated with the input class.
  44299. * @returns the input's friendly name.
  44300. */
  44301. getSimpleName(): string;
  44302. private _pointerInput;
  44303. private _onMouseMove;
  44304. /**
  44305. * Rotate camera by mouse offset.
  44306. */
  44307. private rotateCamera;
  44308. }
  44309. }
  44310. declare module BABYLON {
  44311. /**
  44312. * Default Inputs manager for the FlyCamera.
  44313. * It groups all the default supported inputs for ease of use.
  44314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44315. */
  44316. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44317. /**
  44318. * Instantiates a new FlyCameraInputsManager.
  44319. * @param camera Defines the camera the inputs belong to.
  44320. */
  44321. constructor(camera: FlyCamera);
  44322. /**
  44323. * Add keyboard input support to the input manager.
  44324. * @returns the new FlyCameraKeyboardMoveInput().
  44325. */
  44326. addKeyboard(): FlyCameraInputsManager;
  44327. /**
  44328. * Add mouse input support to the input manager.
  44329. * @param touchEnabled Enable touch screen support.
  44330. * @returns the new FlyCameraMouseInput().
  44331. */
  44332. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44333. }
  44334. }
  44335. declare module BABYLON {
  44336. /**
  44337. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44338. * such as in a 3D Space Shooter or a Flight Simulator.
  44339. */
  44340. export class FlyCamera extends TargetCamera {
  44341. /**
  44342. * Define the collision ellipsoid of the camera.
  44343. * This is helpful for simulating a camera body, like a player's body.
  44344. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44345. */
  44346. ellipsoid: Vector3;
  44347. /**
  44348. * Define an offset for the position of the ellipsoid around the camera.
  44349. * This can be helpful if the camera is attached away from the player's body center,
  44350. * such as at its head.
  44351. */
  44352. ellipsoidOffset: Vector3;
  44353. /**
  44354. * Enable or disable collisions of the camera with the rest of the scene objects.
  44355. */
  44356. checkCollisions: boolean;
  44357. /**
  44358. * Enable or disable gravity on the camera.
  44359. */
  44360. applyGravity: boolean;
  44361. /**
  44362. * Define the current direction the camera is moving to.
  44363. */
  44364. cameraDirection: Vector3;
  44365. /**
  44366. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44367. * This overrides and empties cameraRotation.
  44368. */
  44369. rotationQuaternion: Quaternion;
  44370. /**
  44371. * Track Roll to maintain the wanted Rolling when looking around.
  44372. */
  44373. _trackRoll: number;
  44374. /**
  44375. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44376. */
  44377. rollCorrect: number;
  44378. /**
  44379. * Mimic a banked turn, Rolling the camera when Yawing.
  44380. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44381. */
  44382. bankedTurn: boolean;
  44383. /**
  44384. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44385. */
  44386. bankedTurnLimit: number;
  44387. /**
  44388. * Value of 0 disables the banked Roll.
  44389. * Value of 1 is equal to the Yaw angle in radians.
  44390. */
  44391. bankedTurnMultiplier: number;
  44392. /**
  44393. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44394. */
  44395. inputs: FlyCameraInputsManager;
  44396. /**
  44397. * Gets the input sensibility for mouse input.
  44398. * Higher values reduce sensitivity.
  44399. */
  44400. get angularSensibility(): number;
  44401. /**
  44402. * Sets the input sensibility for a mouse input.
  44403. * Higher values reduce sensitivity.
  44404. */
  44405. set angularSensibility(value: number);
  44406. /**
  44407. * Get the keys for camera movement forward.
  44408. */
  44409. get keysForward(): number[];
  44410. /**
  44411. * Set the keys for camera movement forward.
  44412. */
  44413. set keysForward(value: number[]);
  44414. /**
  44415. * Get the keys for camera movement backward.
  44416. */
  44417. get keysBackward(): number[];
  44418. set keysBackward(value: number[]);
  44419. /**
  44420. * Get the keys for camera movement up.
  44421. */
  44422. get keysUp(): number[];
  44423. /**
  44424. * Set the keys for camera movement up.
  44425. */
  44426. set keysUp(value: number[]);
  44427. /**
  44428. * Get the keys for camera movement down.
  44429. */
  44430. get keysDown(): number[];
  44431. /**
  44432. * Set the keys for camera movement down.
  44433. */
  44434. set keysDown(value: number[]);
  44435. /**
  44436. * Get the keys for camera movement left.
  44437. */
  44438. get keysLeft(): number[];
  44439. /**
  44440. * Set the keys for camera movement left.
  44441. */
  44442. set keysLeft(value: number[]);
  44443. /**
  44444. * Set the keys for camera movement right.
  44445. */
  44446. get keysRight(): number[];
  44447. /**
  44448. * Set the keys for camera movement right.
  44449. */
  44450. set keysRight(value: number[]);
  44451. /**
  44452. * Event raised when the camera collides with a mesh in the scene.
  44453. */
  44454. onCollide: (collidedMesh: AbstractMesh) => void;
  44455. private _collider;
  44456. private _needMoveForGravity;
  44457. private _oldPosition;
  44458. private _diffPosition;
  44459. private _newPosition;
  44460. /** @hidden */
  44461. _localDirection: Vector3;
  44462. /** @hidden */
  44463. _transformedDirection: Vector3;
  44464. /**
  44465. * Instantiates a FlyCamera.
  44466. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44467. * such as in a 3D Space Shooter or a Flight Simulator.
  44468. * @param name Define the name of the camera in the scene.
  44469. * @param position Define the starting position of the camera in the scene.
  44470. * @param scene Define the scene the camera belongs to.
  44471. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44472. */
  44473. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44474. /**
  44475. * Attach a control to the HTML DOM element.
  44476. * @param element Defines the element that listens to the input events.
  44477. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44478. */
  44479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44480. /**
  44481. * Detach a control from the HTML DOM element.
  44482. * The camera will stop reacting to that input.
  44483. * @param element Defines the element that listens to the input events.
  44484. */
  44485. detachControl(element: HTMLElement): void;
  44486. private _collisionMask;
  44487. /**
  44488. * Get the mask that the camera ignores in collision events.
  44489. */
  44490. get collisionMask(): number;
  44491. /**
  44492. * Set the mask that the camera ignores in collision events.
  44493. */
  44494. set collisionMask(mask: number);
  44495. /** @hidden */
  44496. _collideWithWorld(displacement: Vector3): void;
  44497. /** @hidden */
  44498. private _onCollisionPositionChange;
  44499. /** @hidden */
  44500. _checkInputs(): void;
  44501. /** @hidden */
  44502. _decideIfNeedsToMove(): boolean;
  44503. /** @hidden */
  44504. _updatePosition(): void;
  44505. /**
  44506. * Restore the Roll to its target value at the rate specified.
  44507. * @param rate - Higher means slower restoring.
  44508. * @hidden
  44509. */
  44510. restoreRoll(rate: number): void;
  44511. /**
  44512. * Destroy the camera and release the current resources held by it.
  44513. */
  44514. dispose(): void;
  44515. /**
  44516. * Get the current object class name.
  44517. * @returns the class name.
  44518. */
  44519. getClassName(): string;
  44520. }
  44521. }
  44522. declare module BABYLON {
  44523. /**
  44524. * Listen to keyboard events to control the camera.
  44525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44526. */
  44527. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44528. /**
  44529. * Defines the camera the input is attached to.
  44530. */
  44531. camera: FlyCamera;
  44532. /**
  44533. * The list of keyboard keys used to control the forward move of the camera.
  44534. */
  44535. keysForward: number[];
  44536. /**
  44537. * The list of keyboard keys used to control the backward move of the camera.
  44538. */
  44539. keysBackward: number[];
  44540. /**
  44541. * The list of keyboard keys used to control the forward move of the camera.
  44542. */
  44543. keysUp: number[];
  44544. /**
  44545. * The list of keyboard keys used to control the backward move of the camera.
  44546. */
  44547. keysDown: number[];
  44548. /**
  44549. * The list of keyboard keys used to control the right strafe move of the camera.
  44550. */
  44551. keysRight: number[];
  44552. /**
  44553. * The list of keyboard keys used to control the left strafe move of the camera.
  44554. */
  44555. keysLeft: number[];
  44556. private _keys;
  44557. private _onCanvasBlurObserver;
  44558. private _onKeyboardObserver;
  44559. private _engine;
  44560. private _scene;
  44561. /**
  44562. * Attach the input controls to a specific dom element to get the input from.
  44563. * @param element Defines the element the controls should be listened from
  44564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44565. */
  44566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44567. /**
  44568. * Detach the current controls from the specified dom element.
  44569. * @param element Defines the element to stop listening the inputs from
  44570. */
  44571. detachControl(element: Nullable<HTMLElement>): void;
  44572. /**
  44573. * Gets the class name of the current intput.
  44574. * @returns the class name
  44575. */
  44576. getClassName(): string;
  44577. /** @hidden */
  44578. _onLostFocus(e: FocusEvent): void;
  44579. /**
  44580. * Get the friendly name associated with the input class.
  44581. * @returns the input friendly name
  44582. */
  44583. getSimpleName(): string;
  44584. /**
  44585. * Update the current camera state depending on the inputs that have been used this frame.
  44586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44587. */
  44588. checkInputs(): void;
  44589. }
  44590. }
  44591. declare module BABYLON {
  44592. /**
  44593. * Manage the mouse wheel inputs to control a follow camera.
  44594. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44595. */
  44596. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44597. /**
  44598. * Defines the camera the input is attached to.
  44599. */
  44600. camera: FollowCamera;
  44601. /**
  44602. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44603. */
  44604. axisControlRadius: boolean;
  44605. /**
  44606. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44607. */
  44608. axisControlHeight: boolean;
  44609. /**
  44610. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44611. */
  44612. axisControlRotation: boolean;
  44613. /**
  44614. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44615. * relation to mouseWheel events.
  44616. */
  44617. wheelPrecision: number;
  44618. /**
  44619. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44620. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44621. */
  44622. wheelDeltaPercentage: number;
  44623. private _wheel;
  44624. private _observer;
  44625. /**
  44626. * Attach the input controls to a specific dom element to get the input from.
  44627. * @param element Defines the element the controls should be listened from
  44628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44629. */
  44630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44631. /**
  44632. * Detach the current controls from the specified dom element.
  44633. * @param element Defines the element to stop listening the inputs from
  44634. */
  44635. detachControl(element: Nullable<HTMLElement>): void;
  44636. /**
  44637. * Gets the class name of the current intput.
  44638. * @returns the class name
  44639. */
  44640. getClassName(): string;
  44641. /**
  44642. * Get the friendly name associated with the input class.
  44643. * @returns the input friendly name
  44644. */
  44645. getSimpleName(): string;
  44646. }
  44647. }
  44648. declare module BABYLON {
  44649. /**
  44650. * Manage the pointers inputs to control an follow camera.
  44651. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44652. */
  44653. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44654. /**
  44655. * Defines the camera the input is attached to.
  44656. */
  44657. camera: FollowCamera;
  44658. /**
  44659. * Gets the class name of the current input.
  44660. * @returns the class name
  44661. */
  44662. getClassName(): string;
  44663. /**
  44664. * Defines the pointer angular sensibility along the X axis or how fast is
  44665. * the camera rotating.
  44666. * A negative number will reverse the axis direction.
  44667. */
  44668. angularSensibilityX: number;
  44669. /**
  44670. * Defines the pointer angular sensibility along the Y axis or how fast is
  44671. * the camera rotating.
  44672. * A negative number will reverse the axis direction.
  44673. */
  44674. angularSensibilityY: number;
  44675. /**
  44676. * Defines the pointer pinch precision or how fast is the camera zooming.
  44677. * A negative number will reverse the axis direction.
  44678. */
  44679. pinchPrecision: number;
  44680. /**
  44681. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44682. * from 0.
  44683. * It defines the percentage of current camera.radius to use as delta when
  44684. * pinch zoom is used.
  44685. */
  44686. pinchDeltaPercentage: number;
  44687. /**
  44688. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44689. */
  44690. axisXControlRadius: boolean;
  44691. /**
  44692. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44693. */
  44694. axisXControlHeight: boolean;
  44695. /**
  44696. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44697. */
  44698. axisXControlRotation: boolean;
  44699. /**
  44700. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44701. */
  44702. axisYControlRadius: boolean;
  44703. /**
  44704. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44705. */
  44706. axisYControlHeight: boolean;
  44707. /**
  44708. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44709. */
  44710. axisYControlRotation: boolean;
  44711. /**
  44712. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44713. */
  44714. axisPinchControlRadius: boolean;
  44715. /**
  44716. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44717. */
  44718. axisPinchControlHeight: boolean;
  44719. /**
  44720. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44721. */
  44722. axisPinchControlRotation: boolean;
  44723. /**
  44724. * Log error messages if basic misconfiguration has occurred.
  44725. */
  44726. warningEnable: boolean;
  44727. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44728. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44729. private _warningCounter;
  44730. private _warning;
  44731. }
  44732. }
  44733. declare module BABYLON {
  44734. /**
  44735. * Default Inputs manager for the FollowCamera.
  44736. * It groups all the default supported inputs for ease of use.
  44737. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44738. */
  44739. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44740. /**
  44741. * Instantiates a new FollowCameraInputsManager.
  44742. * @param camera Defines the camera the inputs belong to
  44743. */
  44744. constructor(camera: FollowCamera);
  44745. /**
  44746. * Add keyboard input support to the input manager.
  44747. * @returns the current input manager
  44748. */
  44749. addKeyboard(): FollowCameraInputsManager;
  44750. /**
  44751. * Add mouse wheel input support to the input manager.
  44752. * @returns the current input manager
  44753. */
  44754. addMouseWheel(): FollowCameraInputsManager;
  44755. /**
  44756. * Add pointers input support to the input manager.
  44757. * @returns the current input manager
  44758. */
  44759. addPointers(): FollowCameraInputsManager;
  44760. /**
  44761. * Add orientation input support to the input manager.
  44762. * @returns the current input manager
  44763. */
  44764. addVRDeviceOrientation(): FollowCameraInputsManager;
  44765. }
  44766. }
  44767. declare module BABYLON {
  44768. /**
  44769. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44770. * an arc rotate version arcFollowCamera are available.
  44771. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44772. */
  44773. export class FollowCamera extends TargetCamera {
  44774. /**
  44775. * Distance the follow camera should follow an object at
  44776. */
  44777. radius: number;
  44778. /**
  44779. * Minimum allowed distance of the camera to the axis of rotation
  44780. * (The camera can not get closer).
  44781. * This can help limiting how the Camera is able to move in the scene.
  44782. */
  44783. lowerRadiusLimit: Nullable<number>;
  44784. /**
  44785. * Maximum allowed distance of the camera to the axis of rotation
  44786. * (The camera can not get further).
  44787. * This can help limiting how the Camera is able to move in the scene.
  44788. */
  44789. upperRadiusLimit: Nullable<number>;
  44790. /**
  44791. * Define a rotation offset between the camera and the object it follows
  44792. */
  44793. rotationOffset: number;
  44794. /**
  44795. * Minimum allowed angle to camera position relative to target object.
  44796. * This can help limiting how the Camera is able to move in the scene.
  44797. */
  44798. lowerRotationOffsetLimit: Nullable<number>;
  44799. /**
  44800. * Maximum allowed angle to camera position relative to target object.
  44801. * This can help limiting how the Camera is able to move in the scene.
  44802. */
  44803. upperRotationOffsetLimit: Nullable<number>;
  44804. /**
  44805. * Define a height offset between the camera and the object it follows.
  44806. * It can help following an object from the top (like a car chaing a plane)
  44807. */
  44808. heightOffset: number;
  44809. /**
  44810. * Minimum allowed height of camera position relative to target object.
  44811. * This can help limiting how the Camera is able to move in the scene.
  44812. */
  44813. lowerHeightOffsetLimit: Nullable<number>;
  44814. /**
  44815. * Maximum allowed height of camera position relative to target object.
  44816. * This can help limiting how the Camera is able to move in the scene.
  44817. */
  44818. upperHeightOffsetLimit: Nullable<number>;
  44819. /**
  44820. * Define how fast the camera can accelerate to follow it s target.
  44821. */
  44822. cameraAcceleration: number;
  44823. /**
  44824. * Define the speed limit of the camera following an object.
  44825. */
  44826. maxCameraSpeed: number;
  44827. /**
  44828. * Define the target of the camera.
  44829. */
  44830. lockedTarget: Nullable<AbstractMesh>;
  44831. /**
  44832. * Defines the input associated with the camera.
  44833. */
  44834. inputs: FollowCameraInputsManager;
  44835. /**
  44836. * Instantiates the follow camera.
  44837. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44838. * @param name Define the name of the camera in the scene
  44839. * @param position Define the position of the camera
  44840. * @param scene Define the scene the camera belong to
  44841. * @param lockedTarget Define the target of the camera
  44842. */
  44843. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44844. private _follow;
  44845. /**
  44846. * Attached controls to the current camera.
  44847. * @param element Defines the element the controls should be listened from
  44848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44849. */
  44850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44851. /**
  44852. * Detach the current controls from the camera.
  44853. * The camera will stop reacting to inputs.
  44854. * @param element Defines the element to stop listening the inputs from
  44855. */
  44856. detachControl(element: HTMLElement): void;
  44857. /** @hidden */
  44858. _checkInputs(): void;
  44859. private _checkLimits;
  44860. /**
  44861. * Gets the camera class name.
  44862. * @returns the class name
  44863. */
  44864. getClassName(): string;
  44865. }
  44866. /**
  44867. * Arc Rotate version of the follow camera.
  44868. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44869. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44870. */
  44871. export class ArcFollowCamera extends TargetCamera {
  44872. /** The longitudinal angle of the camera */
  44873. alpha: number;
  44874. /** The latitudinal angle of the camera */
  44875. beta: number;
  44876. /** The radius of the camera from its target */
  44877. radius: number;
  44878. private _cartesianCoordinates;
  44879. /** Define the camera target (the mesh it should follow) */
  44880. private _meshTarget;
  44881. /**
  44882. * Instantiates a new ArcFollowCamera
  44883. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44884. * @param name Define the name of the camera
  44885. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44886. * @param beta Define the rotation angle of the camera around the elevation axis
  44887. * @param radius Define the radius of the camera from its target point
  44888. * @param target Define the target of the camera
  44889. * @param scene Define the scene the camera belongs to
  44890. */
  44891. constructor(name: string,
  44892. /** The longitudinal angle of the camera */
  44893. alpha: number,
  44894. /** The latitudinal angle of the camera */
  44895. beta: number,
  44896. /** The radius of the camera from its target */
  44897. radius: number,
  44898. /** Define the camera target (the mesh it should follow) */
  44899. target: Nullable<AbstractMesh>, scene: Scene);
  44900. private _follow;
  44901. /** @hidden */
  44902. _checkInputs(): void;
  44903. /**
  44904. * Returns the class name of the object.
  44905. * It is mostly used internally for serialization purposes.
  44906. */
  44907. getClassName(): string;
  44908. }
  44909. }
  44910. declare module BABYLON {
  44911. /**
  44912. * Manage the keyboard inputs to control the movement of a follow camera.
  44913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44914. */
  44915. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44916. /**
  44917. * Defines the camera the input is attached to.
  44918. */
  44919. camera: FollowCamera;
  44920. /**
  44921. * Defines the list of key codes associated with the up action (increase heightOffset)
  44922. */
  44923. keysHeightOffsetIncr: number[];
  44924. /**
  44925. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44926. */
  44927. keysHeightOffsetDecr: number[];
  44928. /**
  44929. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44930. */
  44931. keysHeightOffsetModifierAlt: boolean;
  44932. /**
  44933. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44934. */
  44935. keysHeightOffsetModifierCtrl: boolean;
  44936. /**
  44937. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44938. */
  44939. keysHeightOffsetModifierShift: boolean;
  44940. /**
  44941. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44942. */
  44943. keysRotationOffsetIncr: number[];
  44944. /**
  44945. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44946. */
  44947. keysRotationOffsetDecr: number[];
  44948. /**
  44949. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44950. */
  44951. keysRotationOffsetModifierAlt: boolean;
  44952. /**
  44953. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44954. */
  44955. keysRotationOffsetModifierCtrl: boolean;
  44956. /**
  44957. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44958. */
  44959. keysRotationOffsetModifierShift: boolean;
  44960. /**
  44961. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44962. */
  44963. keysRadiusIncr: number[];
  44964. /**
  44965. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44966. */
  44967. keysRadiusDecr: number[];
  44968. /**
  44969. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44970. */
  44971. keysRadiusModifierAlt: boolean;
  44972. /**
  44973. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44974. */
  44975. keysRadiusModifierCtrl: boolean;
  44976. /**
  44977. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44978. */
  44979. keysRadiusModifierShift: boolean;
  44980. /**
  44981. * Defines the rate of change of heightOffset.
  44982. */
  44983. heightSensibility: number;
  44984. /**
  44985. * Defines the rate of change of rotationOffset.
  44986. */
  44987. rotationSensibility: number;
  44988. /**
  44989. * Defines the rate of change of radius.
  44990. */
  44991. radiusSensibility: number;
  44992. private _keys;
  44993. private _ctrlPressed;
  44994. private _altPressed;
  44995. private _shiftPressed;
  44996. private _onCanvasBlurObserver;
  44997. private _onKeyboardObserver;
  44998. private _engine;
  44999. private _scene;
  45000. /**
  45001. * Attach the input controls to a specific dom element to get the input from.
  45002. * @param element Defines the element the controls should be listened from
  45003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45004. */
  45005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45006. /**
  45007. * Detach the current controls from the specified dom element.
  45008. * @param element Defines the element to stop listening the inputs from
  45009. */
  45010. detachControl(element: Nullable<HTMLElement>): void;
  45011. /**
  45012. * Update the current camera state depending on the inputs that have been used this frame.
  45013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45014. */
  45015. checkInputs(): void;
  45016. /**
  45017. * Gets the class name of the current input.
  45018. * @returns the class name
  45019. */
  45020. getClassName(): string;
  45021. /**
  45022. * Get the friendly name associated with the input class.
  45023. * @returns the input friendly name
  45024. */
  45025. getSimpleName(): string;
  45026. /**
  45027. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45028. * allow modification of the heightOffset value.
  45029. */
  45030. private _modifierHeightOffset;
  45031. /**
  45032. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45033. * allow modification of the rotationOffset value.
  45034. */
  45035. private _modifierRotationOffset;
  45036. /**
  45037. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45038. * allow modification of the radius value.
  45039. */
  45040. private _modifierRadius;
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. interface FreeCameraInputsManager {
  45045. /**
  45046. * @hidden
  45047. */
  45048. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45049. /**
  45050. * Add orientation input support to the input manager.
  45051. * @returns the current input manager
  45052. */
  45053. addDeviceOrientation(): FreeCameraInputsManager;
  45054. }
  45055. /**
  45056. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45057. * Screen rotation is taken into account.
  45058. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45059. */
  45060. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45061. private _camera;
  45062. private _screenOrientationAngle;
  45063. private _constantTranform;
  45064. private _screenQuaternion;
  45065. private _alpha;
  45066. private _beta;
  45067. private _gamma;
  45068. /**
  45069. * Can be used to detect if a device orientation sensor is available on a device
  45070. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45071. * @returns a promise that will resolve on orientation change
  45072. */
  45073. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45074. /**
  45075. * @hidden
  45076. */
  45077. _onDeviceOrientationChangedObservable: Observable<void>;
  45078. /**
  45079. * Instantiates a new input
  45080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45081. */
  45082. constructor();
  45083. /**
  45084. * Define the camera controlled by the input.
  45085. */
  45086. get camera(): FreeCamera;
  45087. set camera(camera: FreeCamera);
  45088. /**
  45089. * Attach the input controls to a specific dom element to get the input from.
  45090. * @param element Defines the element the controls should be listened from
  45091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45092. */
  45093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45094. private _orientationChanged;
  45095. private _deviceOrientation;
  45096. /**
  45097. * Detach the current controls from the specified dom element.
  45098. * @param element Defines the element to stop listening the inputs from
  45099. */
  45100. detachControl(element: Nullable<HTMLElement>): void;
  45101. /**
  45102. * Update the current camera state depending on the inputs that have been used this frame.
  45103. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45104. */
  45105. checkInputs(): void;
  45106. /**
  45107. * Gets the class name of the current intput.
  45108. * @returns the class name
  45109. */
  45110. getClassName(): string;
  45111. /**
  45112. * Get the friendly name associated with the input class.
  45113. * @returns the input friendly name
  45114. */
  45115. getSimpleName(): string;
  45116. }
  45117. }
  45118. declare module BABYLON {
  45119. /**
  45120. * Manage the gamepad inputs to control a free camera.
  45121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45122. */
  45123. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45124. /**
  45125. * Define the camera the input is attached to.
  45126. */
  45127. camera: FreeCamera;
  45128. /**
  45129. * Define the Gamepad controlling the input
  45130. */
  45131. gamepad: Nullable<Gamepad>;
  45132. /**
  45133. * Defines the gamepad rotation sensiblity.
  45134. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45135. */
  45136. gamepadAngularSensibility: number;
  45137. /**
  45138. * Defines the gamepad move sensiblity.
  45139. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45140. */
  45141. gamepadMoveSensibility: number;
  45142. private _yAxisScale;
  45143. /**
  45144. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45145. */
  45146. get invertYAxis(): boolean;
  45147. set invertYAxis(value: boolean);
  45148. private _onGamepadConnectedObserver;
  45149. private _onGamepadDisconnectedObserver;
  45150. private _cameraTransform;
  45151. private _deltaTransform;
  45152. private _vector3;
  45153. private _vector2;
  45154. /**
  45155. * Attach the input controls to a specific dom element to get the input from.
  45156. * @param element Defines the element the controls should be listened from
  45157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45158. */
  45159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45160. /**
  45161. * Detach the current controls from the specified dom element.
  45162. * @param element Defines the element to stop listening the inputs from
  45163. */
  45164. detachControl(element: Nullable<HTMLElement>): void;
  45165. /**
  45166. * Update the current camera state depending on the inputs that have been used this frame.
  45167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45168. */
  45169. checkInputs(): void;
  45170. /**
  45171. * Gets the class name of the current intput.
  45172. * @returns the class name
  45173. */
  45174. getClassName(): string;
  45175. /**
  45176. * Get the friendly name associated with the input class.
  45177. * @returns the input friendly name
  45178. */
  45179. getSimpleName(): string;
  45180. }
  45181. }
  45182. declare module BABYLON {
  45183. /**
  45184. * Defines the potential axis of a Joystick
  45185. */
  45186. export enum JoystickAxis {
  45187. /** X axis */
  45188. X = 0,
  45189. /** Y axis */
  45190. Y = 1,
  45191. /** Z axis */
  45192. Z = 2
  45193. }
  45194. /**
  45195. * Represents the different customization options available
  45196. * for VirtualJoystick
  45197. */
  45198. interface VirtualJoystickCustomizations {
  45199. /**
  45200. * Size of the joystick's puck
  45201. */
  45202. puckSize: number;
  45203. /**
  45204. * Size of the joystick's container
  45205. */
  45206. containerSize: number;
  45207. /**
  45208. * Color of the joystick && puck
  45209. */
  45210. color: string;
  45211. /**
  45212. * Image URL for the joystick's puck
  45213. */
  45214. puckImage?: string;
  45215. /**
  45216. * Image URL for the joystick's container
  45217. */
  45218. containerImage?: string;
  45219. /**
  45220. * Defines the unmoving position of the joystick container
  45221. */
  45222. position?: {
  45223. x: number;
  45224. y: number;
  45225. };
  45226. /**
  45227. * Defines whether or not the joystick container is always visible
  45228. */
  45229. alwaysVisible: boolean;
  45230. /**
  45231. * Defines whether or not to limit the movement of the puck to the joystick's container
  45232. */
  45233. limitToContainer: boolean;
  45234. }
  45235. /**
  45236. * Class used to define virtual joystick (used in touch mode)
  45237. */
  45238. export class VirtualJoystick {
  45239. /**
  45240. * Gets or sets a boolean indicating that left and right values must be inverted
  45241. */
  45242. reverseLeftRight: boolean;
  45243. /**
  45244. * Gets or sets a boolean indicating that up and down values must be inverted
  45245. */
  45246. reverseUpDown: boolean;
  45247. /**
  45248. * Gets the offset value for the position (ie. the change of the position value)
  45249. */
  45250. deltaPosition: Vector3;
  45251. /**
  45252. * Gets a boolean indicating if the virtual joystick was pressed
  45253. */
  45254. pressed: boolean;
  45255. /**
  45256. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45257. */
  45258. static Canvas: Nullable<HTMLCanvasElement>;
  45259. /**
  45260. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45261. */
  45262. limitToContainer: boolean;
  45263. private static _globalJoystickIndex;
  45264. private static _alwaysVisibleSticks;
  45265. private static vjCanvasContext;
  45266. private static vjCanvasWidth;
  45267. private static vjCanvasHeight;
  45268. private static halfWidth;
  45269. private static _GetDefaultOptions;
  45270. private _action;
  45271. private _axisTargetedByLeftAndRight;
  45272. private _axisTargetedByUpAndDown;
  45273. private _joystickSensibility;
  45274. private _inversedSensibility;
  45275. private _joystickPointerID;
  45276. private _joystickColor;
  45277. private _joystickPointerPos;
  45278. private _joystickPreviousPointerPos;
  45279. private _joystickPointerStartPos;
  45280. private _deltaJoystickVector;
  45281. private _leftJoystick;
  45282. private _touches;
  45283. private _joystickPosition;
  45284. private _alwaysVisible;
  45285. private _puckImage;
  45286. private _containerImage;
  45287. private _joystickPuckSize;
  45288. private _joystickContainerSize;
  45289. private _clearPuckSize;
  45290. private _clearContainerSize;
  45291. private _clearPuckSizeOffset;
  45292. private _clearContainerSizeOffset;
  45293. private _onPointerDownHandlerRef;
  45294. private _onPointerMoveHandlerRef;
  45295. private _onPointerUpHandlerRef;
  45296. private _onResize;
  45297. /**
  45298. * Creates a new virtual joystick
  45299. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45300. * @param customizations Defines the options we want to customize the VirtualJoystick
  45301. */
  45302. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45303. /**
  45304. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45305. * @param newJoystickSensibility defines the new sensibility
  45306. */
  45307. setJoystickSensibility(newJoystickSensibility: number): void;
  45308. private _onPointerDown;
  45309. private _onPointerMove;
  45310. private _onPointerUp;
  45311. /**
  45312. * Change the color of the virtual joystick
  45313. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45314. */
  45315. setJoystickColor(newColor: string): void;
  45316. /**
  45317. * Size of the joystick's container
  45318. */
  45319. set containerSize(newSize: number);
  45320. get containerSize(): number;
  45321. /**
  45322. * Size of the joystick's puck
  45323. */
  45324. set puckSize(newSize: number);
  45325. get puckSize(): number;
  45326. /**
  45327. * Clears the set position of the joystick
  45328. */
  45329. clearPosition(): void;
  45330. /**
  45331. * Defines whether or not the joystick container is always visible
  45332. */
  45333. set alwaysVisible(value: boolean);
  45334. get alwaysVisible(): boolean;
  45335. /**
  45336. * Sets the constant position of the Joystick container
  45337. * @param x X axis coordinate
  45338. * @param y Y axis coordinate
  45339. */
  45340. setPosition(x: number, y: number): void;
  45341. /**
  45342. * Defines a callback to call when the joystick is touched
  45343. * @param action defines the callback
  45344. */
  45345. setActionOnTouch(action: () => any): void;
  45346. /**
  45347. * Defines which axis you'd like to control for left & right
  45348. * @param axis defines the axis to use
  45349. */
  45350. setAxisForLeftRight(axis: JoystickAxis): void;
  45351. /**
  45352. * Defines which axis you'd like to control for up & down
  45353. * @param axis defines the axis to use
  45354. */
  45355. setAxisForUpDown(axis: JoystickAxis): void;
  45356. /**
  45357. * Clears the canvas from the previous puck / container draw
  45358. */
  45359. private _clearPreviousDraw;
  45360. /**
  45361. * Loads `urlPath` to be used for the container's image
  45362. * @param urlPath defines the urlPath of an image to use
  45363. */
  45364. setContainerImage(urlPath: string): void;
  45365. /**
  45366. * Loads `urlPath` to be used for the puck's image
  45367. * @param urlPath defines the urlPath of an image to use
  45368. */
  45369. setPuckImage(urlPath: string): void;
  45370. /**
  45371. * Draws the Virtual Joystick's container
  45372. */
  45373. private _drawContainer;
  45374. /**
  45375. * Draws the Virtual Joystick's puck
  45376. */
  45377. private _drawPuck;
  45378. private _drawVirtualJoystick;
  45379. /**
  45380. * Release internal HTML canvas
  45381. */
  45382. releaseCanvas(): void;
  45383. }
  45384. }
  45385. declare module BABYLON {
  45386. interface FreeCameraInputsManager {
  45387. /**
  45388. * Add virtual joystick input support to the input manager.
  45389. * @returns the current input manager
  45390. */
  45391. addVirtualJoystick(): FreeCameraInputsManager;
  45392. }
  45393. /**
  45394. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45395. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45396. */
  45397. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45398. /**
  45399. * Defines the camera the input is attached to.
  45400. */
  45401. camera: FreeCamera;
  45402. private _leftjoystick;
  45403. private _rightjoystick;
  45404. /**
  45405. * Gets the left stick of the virtual joystick.
  45406. * @returns The virtual Joystick
  45407. */
  45408. getLeftJoystick(): VirtualJoystick;
  45409. /**
  45410. * Gets the right stick of the virtual joystick.
  45411. * @returns The virtual Joystick
  45412. */
  45413. getRightJoystick(): VirtualJoystick;
  45414. /**
  45415. * Update the current camera state depending on the inputs that have been used this frame.
  45416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45417. */
  45418. checkInputs(): void;
  45419. /**
  45420. * Attach the input controls to a specific dom element to get the input from.
  45421. * @param element Defines the element the controls should be listened from
  45422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45423. */
  45424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45425. /**
  45426. * Detach the current controls from the specified dom element.
  45427. * @param element Defines the element to stop listening the inputs from
  45428. */
  45429. detachControl(element: Nullable<HTMLElement>): void;
  45430. /**
  45431. * Gets the class name of the current intput.
  45432. * @returns the class name
  45433. */
  45434. getClassName(): string;
  45435. /**
  45436. * Get the friendly name associated with the input class.
  45437. * @returns the input friendly name
  45438. */
  45439. getSimpleName(): string;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * This represents a FPS type of camera controlled by touch.
  45445. * This is like a universal camera minus the Gamepad controls.
  45446. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45447. */
  45448. export class TouchCamera extends FreeCamera {
  45449. /**
  45450. * Defines the touch sensibility for rotation.
  45451. * The higher the faster.
  45452. */
  45453. get touchAngularSensibility(): number;
  45454. set touchAngularSensibility(value: number);
  45455. /**
  45456. * Defines the touch sensibility for move.
  45457. * The higher the faster.
  45458. */
  45459. get touchMoveSensibility(): number;
  45460. set touchMoveSensibility(value: number);
  45461. /**
  45462. * Instantiates a new touch camera.
  45463. * This represents a FPS type of camera controlled by touch.
  45464. * This is like a universal camera minus the Gamepad controls.
  45465. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45466. * @param name Define the name of the camera in the scene
  45467. * @param position Define the start position of the camera in the scene
  45468. * @param scene Define the scene the camera belongs to
  45469. */
  45470. constructor(name: string, position: Vector3, scene: Scene);
  45471. /**
  45472. * Gets the current object class name.
  45473. * @return the class name
  45474. */
  45475. getClassName(): string;
  45476. /** @hidden */
  45477. _setupInputs(): void;
  45478. }
  45479. }
  45480. declare module BABYLON {
  45481. /**
  45482. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45483. * being tilted forward or back and left or right.
  45484. */
  45485. export class DeviceOrientationCamera extends FreeCamera {
  45486. private _initialQuaternion;
  45487. private _quaternionCache;
  45488. private _tmpDragQuaternion;
  45489. private _disablePointerInputWhenUsingDeviceOrientation;
  45490. /**
  45491. * Creates a new device orientation camera
  45492. * @param name The name of the camera
  45493. * @param position The start position camera
  45494. * @param scene The scene the camera belongs to
  45495. */
  45496. constructor(name: string, position: Vector3, scene: Scene);
  45497. /**
  45498. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45499. */
  45500. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45501. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45502. private _dragFactor;
  45503. /**
  45504. * Enabled turning on the y axis when the orientation sensor is active
  45505. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45506. */
  45507. enableHorizontalDragging(dragFactor?: number): void;
  45508. /**
  45509. * Gets the current instance class name ("DeviceOrientationCamera").
  45510. * This helps avoiding instanceof at run time.
  45511. * @returns the class name
  45512. */
  45513. getClassName(): string;
  45514. /**
  45515. * @hidden
  45516. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45517. */
  45518. _checkInputs(): void;
  45519. /**
  45520. * Reset the camera to its default orientation on the specified axis only.
  45521. * @param axis The axis to reset
  45522. */
  45523. resetToCurrentRotation(axis?: Axis): void;
  45524. }
  45525. }
  45526. declare module BABYLON {
  45527. /**
  45528. * Defines supported buttons for XBox360 compatible gamepads
  45529. */
  45530. export enum Xbox360Button {
  45531. /** A */
  45532. A = 0,
  45533. /** B */
  45534. B = 1,
  45535. /** X */
  45536. X = 2,
  45537. /** Y */
  45538. Y = 3,
  45539. /** Left button */
  45540. LB = 4,
  45541. /** Right button */
  45542. RB = 5,
  45543. /** Back */
  45544. Back = 8,
  45545. /** Start */
  45546. Start = 9,
  45547. /** Left stick */
  45548. LeftStick = 10,
  45549. /** Right stick */
  45550. RightStick = 11
  45551. }
  45552. /** Defines values for XBox360 DPad */
  45553. export enum Xbox360Dpad {
  45554. /** Up */
  45555. Up = 12,
  45556. /** Down */
  45557. Down = 13,
  45558. /** Left */
  45559. Left = 14,
  45560. /** Right */
  45561. Right = 15
  45562. }
  45563. /**
  45564. * Defines a XBox360 gamepad
  45565. */
  45566. export class Xbox360Pad extends Gamepad {
  45567. private _leftTrigger;
  45568. private _rightTrigger;
  45569. private _onlefttriggerchanged;
  45570. private _onrighttriggerchanged;
  45571. private _onbuttondown;
  45572. private _onbuttonup;
  45573. private _ondpaddown;
  45574. private _ondpadup;
  45575. /** Observable raised when a button is pressed */
  45576. onButtonDownObservable: Observable<Xbox360Button>;
  45577. /** Observable raised when a button is released */
  45578. onButtonUpObservable: Observable<Xbox360Button>;
  45579. /** Observable raised when a pad is pressed */
  45580. onPadDownObservable: Observable<Xbox360Dpad>;
  45581. /** Observable raised when a pad is released */
  45582. onPadUpObservable: Observable<Xbox360Dpad>;
  45583. private _buttonA;
  45584. private _buttonB;
  45585. private _buttonX;
  45586. private _buttonY;
  45587. private _buttonBack;
  45588. private _buttonStart;
  45589. private _buttonLB;
  45590. private _buttonRB;
  45591. private _buttonLeftStick;
  45592. private _buttonRightStick;
  45593. private _dPadUp;
  45594. private _dPadDown;
  45595. private _dPadLeft;
  45596. private _dPadRight;
  45597. private _isXboxOnePad;
  45598. /**
  45599. * Creates a new XBox360 gamepad object
  45600. * @param id defines the id of this gamepad
  45601. * @param index defines its index
  45602. * @param gamepad defines the internal HTML gamepad object
  45603. * @param xboxOne defines if it is a XBox One gamepad
  45604. */
  45605. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45606. /**
  45607. * Defines the callback to call when left trigger is pressed
  45608. * @param callback defines the callback to use
  45609. */
  45610. onlefttriggerchanged(callback: (value: number) => void): void;
  45611. /**
  45612. * Defines the callback to call when right trigger is pressed
  45613. * @param callback defines the callback to use
  45614. */
  45615. onrighttriggerchanged(callback: (value: number) => void): void;
  45616. /**
  45617. * Gets the left trigger value
  45618. */
  45619. get leftTrigger(): number;
  45620. /**
  45621. * Sets the left trigger value
  45622. */
  45623. set leftTrigger(newValue: number);
  45624. /**
  45625. * Gets the right trigger value
  45626. */
  45627. get rightTrigger(): number;
  45628. /**
  45629. * Sets the right trigger value
  45630. */
  45631. set rightTrigger(newValue: number);
  45632. /**
  45633. * Defines the callback to call when a button is pressed
  45634. * @param callback defines the callback to use
  45635. */
  45636. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45637. /**
  45638. * Defines the callback to call when a button is released
  45639. * @param callback defines the callback to use
  45640. */
  45641. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45642. /**
  45643. * Defines the callback to call when a pad is pressed
  45644. * @param callback defines the callback to use
  45645. */
  45646. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45647. /**
  45648. * Defines the callback to call when a pad is released
  45649. * @param callback defines the callback to use
  45650. */
  45651. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45652. private _setButtonValue;
  45653. private _setDPadValue;
  45654. /**
  45655. * Gets the value of the `A` button
  45656. */
  45657. get buttonA(): number;
  45658. /**
  45659. * Sets the value of the `A` button
  45660. */
  45661. set buttonA(value: number);
  45662. /**
  45663. * Gets the value of the `B` button
  45664. */
  45665. get buttonB(): number;
  45666. /**
  45667. * Sets the value of the `B` button
  45668. */
  45669. set buttonB(value: number);
  45670. /**
  45671. * Gets the value of the `X` button
  45672. */
  45673. get buttonX(): number;
  45674. /**
  45675. * Sets the value of the `X` button
  45676. */
  45677. set buttonX(value: number);
  45678. /**
  45679. * Gets the value of the `Y` button
  45680. */
  45681. get buttonY(): number;
  45682. /**
  45683. * Sets the value of the `Y` button
  45684. */
  45685. set buttonY(value: number);
  45686. /**
  45687. * Gets the value of the `Start` button
  45688. */
  45689. get buttonStart(): number;
  45690. /**
  45691. * Sets the value of the `Start` button
  45692. */
  45693. set buttonStart(value: number);
  45694. /**
  45695. * Gets the value of the `Back` button
  45696. */
  45697. get buttonBack(): number;
  45698. /**
  45699. * Sets the value of the `Back` button
  45700. */
  45701. set buttonBack(value: number);
  45702. /**
  45703. * Gets the value of the `Left` button
  45704. */
  45705. get buttonLB(): number;
  45706. /**
  45707. * Sets the value of the `Left` button
  45708. */
  45709. set buttonLB(value: number);
  45710. /**
  45711. * Gets the value of the `Right` button
  45712. */
  45713. get buttonRB(): number;
  45714. /**
  45715. * Sets the value of the `Right` button
  45716. */
  45717. set buttonRB(value: number);
  45718. /**
  45719. * Gets the value of the Left joystick
  45720. */
  45721. get buttonLeftStick(): number;
  45722. /**
  45723. * Sets the value of the Left joystick
  45724. */
  45725. set buttonLeftStick(value: number);
  45726. /**
  45727. * Gets the value of the Right joystick
  45728. */
  45729. get buttonRightStick(): number;
  45730. /**
  45731. * Sets the value of the Right joystick
  45732. */
  45733. set buttonRightStick(value: number);
  45734. /**
  45735. * Gets the value of D-pad up
  45736. */
  45737. get dPadUp(): number;
  45738. /**
  45739. * Sets the value of D-pad up
  45740. */
  45741. set dPadUp(value: number);
  45742. /**
  45743. * Gets the value of D-pad down
  45744. */
  45745. get dPadDown(): number;
  45746. /**
  45747. * Sets the value of D-pad down
  45748. */
  45749. set dPadDown(value: number);
  45750. /**
  45751. * Gets the value of D-pad left
  45752. */
  45753. get dPadLeft(): number;
  45754. /**
  45755. * Sets the value of D-pad left
  45756. */
  45757. set dPadLeft(value: number);
  45758. /**
  45759. * Gets the value of D-pad right
  45760. */
  45761. get dPadRight(): number;
  45762. /**
  45763. * Sets the value of D-pad right
  45764. */
  45765. set dPadRight(value: number);
  45766. /**
  45767. * Force the gamepad to synchronize with device values
  45768. */
  45769. update(): void;
  45770. /**
  45771. * Disposes the gamepad
  45772. */
  45773. dispose(): void;
  45774. }
  45775. }
  45776. declare module BABYLON {
  45777. /**
  45778. * Defines supported buttons for DualShock compatible gamepads
  45779. */
  45780. export enum DualShockButton {
  45781. /** Cross */
  45782. Cross = 0,
  45783. /** Circle */
  45784. Circle = 1,
  45785. /** Square */
  45786. Square = 2,
  45787. /** Triangle */
  45788. Triangle = 3,
  45789. /** L1 */
  45790. L1 = 4,
  45791. /** R1 */
  45792. R1 = 5,
  45793. /** Share */
  45794. Share = 8,
  45795. /** Options */
  45796. Options = 9,
  45797. /** Left stick */
  45798. LeftStick = 10,
  45799. /** Right stick */
  45800. RightStick = 11
  45801. }
  45802. /** Defines values for DualShock DPad */
  45803. export enum DualShockDpad {
  45804. /** Up */
  45805. Up = 12,
  45806. /** Down */
  45807. Down = 13,
  45808. /** Left */
  45809. Left = 14,
  45810. /** Right */
  45811. Right = 15
  45812. }
  45813. /**
  45814. * Defines a DualShock gamepad
  45815. */
  45816. export class DualShockPad extends Gamepad {
  45817. private _leftTrigger;
  45818. private _rightTrigger;
  45819. private _onlefttriggerchanged;
  45820. private _onrighttriggerchanged;
  45821. private _onbuttondown;
  45822. private _onbuttonup;
  45823. private _ondpaddown;
  45824. private _ondpadup;
  45825. /** Observable raised when a button is pressed */
  45826. onButtonDownObservable: Observable<DualShockButton>;
  45827. /** Observable raised when a button is released */
  45828. onButtonUpObservable: Observable<DualShockButton>;
  45829. /** Observable raised when a pad is pressed */
  45830. onPadDownObservable: Observable<DualShockDpad>;
  45831. /** Observable raised when a pad is released */
  45832. onPadUpObservable: Observable<DualShockDpad>;
  45833. private _buttonCross;
  45834. private _buttonCircle;
  45835. private _buttonSquare;
  45836. private _buttonTriangle;
  45837. private _buttonShare;
  45838. private _buttonOptions;
  45839. private _buttonL1;
  45840. private _buttonR1;
  45841. private _buttonLeftStick;
  45842. private _buttonRightStick;
  45843. private _dPadUp;
  45844. private _dPadDown;
  45845. private _dPadLeft;
  45846. private _dPadRight;
  45847. /**
  45848. * Creates a new DualShock gamepad object
  45849. * @param id defines the id of this gamepad
  45850. * @param index defines its index
  45851. * @param gamepad defines the internal HTML gamepad object
  45852. */
  45853. constructor(id: string, index: number, gamepad: any);
  45854. /**
  45855. * Defines the callback to call when left trigger is pressed
  45856. * @param callback defines the callback to use
  45857. */
  45858. onlefttriggerchanged(callback: (value: number) => void): void;
  45859. /**
  45860. * Defines the callback to call when right trigger is pressed
  45861. * @param callback defines the callback to use
  45862. */
  45863. onrighttriggerchanged(callback: (value: number) => void): void;
  45864. /**
  45865. * Gets the left trigger value
  45866. */
  45867. get leftTrigger(): number;
  45868. /**
  45869. * Sets the left trigger value
  45870. */
  45871. set leftTrigger(newValue: number);
  45872. /**
  45873. * Gets the right trigger value
  45874. */
  45875. get rightTrigger(): number;
  45876. /**
  45877. * Sets the right trigger value
  45878. */
  45879. set rightTrigger(newValue: number);
  45880. /**
  45881. * Defines the callback to call when a button is pressed
  45882. * @param callback defines the callback to use
  45883. */
  45884. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45885. /**
  45886. * Defines the callback to call when a button is released
  45887. * @param callback defines the callback to use
  45888. */
  45889. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45890. /**
  45891. * Defines the callback to call when a pad is pressed
  45892. * @param callback defines the callback to use
  45893. */
  45894. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45895. /**
  45896. * Defines the callback to call when a pad is released
  45897. * @param callback defines the callback to use
  45898. */
  45899. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45900. private _setButtonValue;
  45901. private _setDPadValue;
  45902. /**
  45903. * Gets the value of the `Cross` button
  45904. */
  45905. get buttonCross(): number;
  45906. /**
  45907. * Sets the value of the `Cross` button
  45908. */
  45909. set buttonCross(value: number);
  45910. /**
  45911. * Gets the value of the `Circle` button
  45912. */
  45913. get buttonCircle(): number;
  45914. /**
  45915. * Sets the value of the `Circle` button
  45916. */
  45917. set buttonCircle(value: number);
  45918. /**
  45919. * Gets the value of the `Square` button
  45920. */
  45921. get buttonSquare(): number;
  45922. /**
  45923. * Sets the value of the `Square` button
  45924. */
  45925. set buttonSquare(value: number);
  45926. /**
  45927. * Gets the value of the `Triangle` button
  45928. */
  45929. get buttonTriangle(): number;
  45930. /**
  45931. * Sets the value of the `Triangle` button
  45932. */
  45933. set buttonTriangle(value: number);
  45934. /**
  45935. * Gets the value of the `Options` button
  45936. */
  45937. get buttonOptions(): number;
  45938. /**
  45939. * Sets the value of the `Options` button
  45940. */
  45941. set buttonOptions(value: number);
  45942. /**
  45943. * Gets the value of the `Share` button
  45944. */
  45945. get buttonShare(): number;
  45946. /**
  45947. * Sets the value of the `Share` button
  45948. */
  45949. set buttonShare(value: number);
  45950. /**
  45951. * Gets the value of the `L1` button
  45952. */
  45953. get buttonL1(): number;
  45954. /**
  45955. * Sets the value of the `L1` button
  45956. */
  45957. set buttonL1(value: number);
  45958. /**
  45959. * Gets the value of the `R1` button
  45960. */
  45961. get buttonR1(): number;
  45962. /**
  45963. * Sets the value of the `R1` button
  45964. */
  45965. set buttonR1(value: number);
  45966. /**
  45967. * Gets the value of the Left joystick
  45968. */
  45969. get buttonLeftStick(): number;
  45970. /**
  45971. * Sets the value of the Left joystick
  45972. */
  45973. set buttonLeftStick(value: number);
  45974. /**
  45975. * Gets the value of the Right joystick
  45976. */
  45977. get buttonRightStick(): number;
  45978. /**
  45979. * Sets the value of the Right joystick
  45980. */
  45981. set buttonRightStick(value: number);
  45982. /**
  45983. * Gets the value of D-pad up
  45984. */
  45985. get dPadUp(): number;
  45986. /**
  45987. * Sets the value of D-pad up
  45988. */
  45989. set dPadUp(value: number);
  45990. /**
  45991. * Gets the value of D-pad down
  45992. */
  45993. get dPadDown(): number;
  45994. /**
  45995. * Sets the value of D-pad down
  45996. */
  45997. set dPadDown(value: number);
  45998. /**
  45999. * Gets the value of D-pad left
  46000. */
  46001. get dPadLeft(): number;
  46002. /**
  46003. * Sets the value of D-pad left
  46004. */
  46005. set dPadLeft(value: number);
  46006. /**
  46007. * Gets the value of D-pad right
  46008. */
  46009. get dPadRight(): number;
  46010. /**
  46011. * Sets the value of D-pad right
  46012. */
  46013. set dPadRight(value: number);
  46014. /**
  46015. * Force the gamepad to synchronize with device values
  46016. */
  46017. update(): void;
  46018. /**
  46019. * Disposes the gamepad
  46020. */
  46021. dispose(): void;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /**
  46026. * Manager for handling gamepads
  46027. */
  46028. export class GamepadManager {
  46029. private _scene?;
  46030. private _babylonGamepads;
  46031. private _oneGamepadConnected;
  46032. /** @hidden */
  46033. _isMonitoring: boolean;
  46034. private _gamepadEventSupported;
  46035. private _gamepadSupport?;
  46036. /**
  46037. * observable to be triggered when the gamepad controller has been connected
  46038. */
  46039. onGamepadConnectedObservable: Observable<Gamepad>;
  46040. /**
  46041. * observable to be triggered when the gamepad controller has been disconnected
  46042. */
  46043. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46044. private _onGamepadConnectedEvent;
  46045. private _onGamepadDisconnectedEvent;
  46046. /**
  46047. * Initializes the gamepad manager
  46048. * @param _scene BabylonJS scene
  46049. */
  46050. constructor(_scene?: Scene | undefined);
  46051. /**
  46052. * The gamepads in the game pad manager
  46053. */
  46054. get gamepads(): Gamepad[];
  46055. /**
  46056. * Get the gamepad controllers based on type
  46057. * @param type The type of gamepad controller
  46058. * @returns Nullable gamepad
  46059. */
  46060. getGamepadByType(type?: number): Nullable<Gamepad>;
  46061. /**
  46062. * Disposes the gamepad manager
  46063. */
  46064. dispose(): void;
  46065. private _addNewGamepad;
  46066. private _startMonitoringGamepads;
  46067. private _stopMonitoringGamepads;
  46068. /** @hidden */
  46069. _checkGamepadsStatus(): void;
  46070. private _updateGamepadObjects;
  46071. }
  46072. }
  46073. declare module BABYLON {
  46074. interface Scene {
  46075. /** @hidden */
  46076. _gamepadManager: Nullable<GamepadManager>;
  46077. /**
  46078. * Gets the gamepad manager associated with the scene
  46079. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46080. */
  46081. gamepadManager: GamepadManager;
  46082. }
  46083. /**
  46084. * Interface representing a free camera inputs manager
  46085. */
  46086. interface FreeCameraInputsManager {
  46087. /**
  46088. * Adds gamepad input support to the FreeCameraInputsManager.
  46089. * @returns the FreeCameraInputsManager
  46090. */
  46091. addGamepad(): FreeCameraInputsManager;
  46092. }
  46093. /**
  46094. * Interface representing an arc rotate camera inputs manager
  46095. */
  46096. interface ArcRotateCameraInputsManager {
  46097. /**
  46098. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46099. * @returns the camera inputs manager
  46100. */
  46101. addGamepad(): ArcRotateCameraInputsManager;
  46102. }
  46103. /**
  46104. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46105. */
  46106. export class GamepadSystemSceneComponent implements ISceneComponent {
  46107. /**
  46108. * The component name helpfull to identify the component in the list of scene components.
  46109. */
  46110. readonly name: string;
  46111. /**
  46112. * The scene the component belongs to.
  46113. */
  46114. scene: Scene;
  46115. /**
  46116. * Creates a new instance of the component for the given scene
  46117. * @param scene Defines the scene to register the component in
  46118. */
  46119. constructor(scene: Scene);
  46120. /**
  46121. * Registers the component in a given scene
  46122. */
  46123. register(): void;
  46124. /**
  46125. * Rebuilds the elements related to this component in case of
  46126. * context lost for instance.
  46127. */
  46128. rebuild(): void;
  46129. /**
  46130. * Disposes the component and the associated ressources
  46131. */
  46132. dispose(): void;
  46133. private _beforeCameraUpdate;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /**
  46138. * 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,
  46139. * which still works and will still be found in many Playgrounds.
  46140. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46141. */
  46142. export class UniversalCamera extends TouchCamera {
  46143. /**
  46144. * Defines the gamepad rotation sensiblity.
  46145. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46146. */
  46147. get gamepadAngularSensibility(): number;
  46148. set gamepadAngularSensibility(value: number);
  46149. /**
  46150. * Defines the gamepad move sensiblity.
  46151. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46152. */
  46153. get gamepadMoveSensibility(): number;
  46154. set gamepadMoveSensibility(value: number);
  46155. /**
  46156. * 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,
  46157. * which still works and will still be found in many Playgrounds.
  46158. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46159. * @param name Define the name of the camera in the scene
  46160. * @param position Define the start position of the camera in the scene
  46161. * @param scene Define the scene the camera belongs to
  46162. */
  46163. constructor(name: string, position: Vector3, scene: Scene);
  46164. /**
  46165. * Gets the current object class name.
  46166. * @return the class name
  46167. */
  46168. getClassName(): string;
  46169. }
  46170. }
  46171. declare module BABYLON {
  46172. /**
  46173. * This represents a FPS type of camera. This is only here for back compat purpose.
  46174. * Please use the UniversalCamera instead as both are identical.
  46175. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46176. */
  46177. export class GamepadCamera extends UniversalCamera {
  46178. /**
  46179. * Instantiates a new Gamepad Camera
  46180. * This represents a FPS type of camera. This is only here for back compat purpose.
  46181. * Please use the UniversalCamera instead as both are identical.
  46182. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46183. * @param name Define the name of the camera in the scene
  46184. * @param position Define the start position of the camera in the scene
  46185. * @param scene Define the scene the camera belongs to
  46186. */
  46187. constructor(name: string, position: Vector3, scene: Scene);
  46188. /**
  46189. * Gets the current object class name.
  46190. * @return the class name
  46191. */
  46192. getClassName(): string;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /** @hidden */
  46197. export var passPixelShader: {
  46198. name: string;
  46199. shader: string;
  46200. };
  46201. }
  46202. declare module BABYLON {
  46203. /** @hidden */
  46204. export var passCubePixelShader: {
  46205. name: string;
  46206. shader: string;
  46207. };
  46208. }
  46209. declare module BABYLON {
  46210. /**
  46211. * PassPostProcess which produces an output the same as it's input
  46212. */
  46213. export class PassPostProcess extends PostProcess {
  46214. /**
  46215. * Gets a string identifying the name of the class
  46216. * @returns "PassPostProcess" string
  46217. */
  46218. getClassName(): string;
  46219. /**
  46220. * Creates the PassPostProcess
  46221. * @param name The name of the effect.
  46222. * @param options The required width/height ratio to downsize to before computing the render pass.
  46223. * @param camera The camera to apply the render pass to.
  46224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46225. * @param engine The engine which the post process will be applied. (default: current engine)
  46226. * @param reusable If the post process can be reused on the same frame. (default: false)
  46227. * @param textureType The type of texture to be used when performing the post processing.
  46228. * @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)
  46229. */
  46230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46231. /** @hidden */
  46232. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46233. }
  46234. /**
  46235. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46236. */
  46237. export class PassCubePostProcess extends PostProcess {
  46238. private _face;
  46239. /**
  46240. * Gets or sets the cube face to display.
  46241. * * 0 is +X
  46242. * * 1 is -X
  46243. * * 2 is +Y
  46244. * * 3 is -Y
  46245. * * 4 is +Z
  46246. * * 5 is -Z
  46247. */
  46248. get face(): number;
  46249. set face(value: number);
  46250. /**
  46251. * Gets a string identifying the name of the class
  46252. * @returns "PassCubePostProcess" string
  46253. */
  46254. getClassName(): string;
  46255. /**
  46256. * Creates the PassCubePostProcess
  46257. * @param name The name of the effect.
  46258. * @param options The required width/height ratio to downsize to before computing the render pass.
  46259. * @param camera The camera to apply the render pass to.
  46260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46261. * @param engine The engine which the post process will be applied. (default: current engine)
  46262. * @param reusable If the post process can be reused on the same frame. (default: false)
  46263. * @param textureType The type of texture to be used when performing the post processing.
  46264. * @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)
  46265. */
  46266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46267. /** @hidden */
  46268. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46269. }
  46270. }
  46271. declare module BABYLON {
  46272. /** @hidden */
  46273. export var anaglyphPixelShader: {
  46274. name: string;
  46275. shader: string;
  46276. };
  46277. }
  46278. declare module BABYLON {
  46279. /**
  46280. * Postprocess used to generate anaglyphic rendering
  46281. */
  46282. export class AnaglyphPostProcess extends PostProcess {
  46283. private _passedProcess;
  46284. /**
  46285. * Gets a string identifying the name of the class
  46286. * @returns "AnaglyphPostProcess" string
  46287. */
  46288. getClassName(): string;
  46289. /**
  46290. * Creates a new AnaglyphPostProcess
  46291. * @param name defines postprocess name
  46292. * @param options defines creation options or target ratio scale
  46293. * @param rigCameras defines cameras using this postprocess
  46294. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46295. * @param engine defines hosting engine
  46296. * @param reusable defines if the postprocess will be reused multiple times per frame
  46297. */
  46298. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46299. }
  46300. }
  46301. declare module BABYLON {
  46302. /**
  46303. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46304. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46305. */
  46306. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46307. /**
  46308. * Creates a new AnaglyphArcRotateCamera
  46309. * @param name defines camera name
  46310. * @param alpha defines alpha angle (in radians)
  46311. * @param beta defines beta angle (in radians)
  46312. * @param radius defines radius
  46313. * @param target defines camera target
  46314. * @param interaxialDistance defines distance between each color axis
  46315. * @param scene defines the hosting scene
  46316. */
  46317. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46318. /**
  46319. * Gets camera class name
  46320. * @returns AnaglyphArcRotateCamera
  46321. */
  46322. getClassName(): string;
  46323. }
  46324. }
  46325. declare module BABYLON {
  46326. /**
  46327. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46328. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46329. */
  46330. export class AnaglyphFreeCamera extends FreeCamera {
  46331. /**
  46332. * Creates a new AnaglyphFreeCamera
  46333. * @param name defines camera name
  46334. * @param position defines initial position
  46335. * @param interaxialDistance defines distance between each color axis
  46336. * @param scene defines the hosting scene
  46337. */
  46338. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46339. /**
  46340. * Gets camera class name
  46341. * @returns AnaglyphFreeCamera
  46342. */
  46343. getClassName(): string;
  46344. }
  46345. }
  46346. declare module BABYLON {
  46347. /**
  46348. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46349. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46350. */
  46351. export class AnaglyphGamepadCamera extends GamepadCamera {
  46352. /**
  46353. * Creates a new AnaglyphGamepadCamera
  46354. * @param name defines camera name
  46355. * @param position defines initial position
  46356. * @param interaxialDistance defines distance between each color axis
  46357. * @param scene defines the hosting scene
  46358. */
  46359. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46360. /**
  46361. * Gets camera class name
  46362. * @returns AnaglyphGamepadCamera
  46363. */
  46364. getClassName(): string;
  46365. }
  46366. }
  46367. declare module BABYLON {
  46368. /**
  46369. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46370. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46371. */
  46372. export class AnaglyphUniversalCamera extends UniversalCamera {
  46373. /**
  46374. * Creates a new AnaglyphUniversalCamera
  46375. * @param name defines camera name
  46376. * @param position defines initial position
  46377. * @param interaxialDistance defines distance between each color axis
  46378. * @param scene defines the hosting scene
  46379. */
  46380. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46381. /**
  46382. * Gets camera class name
  46383. * @returns AnaglyphUniversalCamera
  46384. */
  46385. getClassName(): string;
  46386. }
  46387. }
  46388. declare module BABYLON {
  46389. /**
  46390. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46391. * @see https://doc.babylonjs.com/features/cameras
  46392. */
  46393. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46394. /**
  46395. * Creates a new StereoscopicArcRotateCamera
  46396. * @param name defines camera name
  46397. * @param alpha defines alpha angle (in radians)
  46398. * @param beta defines beta angle (in radians)
  46399. * @param radius defines radius
  46400. * @param target defines camera target
  46401. * @param interaxialDistance defines distance between each color axis
  46402. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46403. * @param scene defines the hosting scene
  46404. */
  46405. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46406. /**
  46407. * Gets camera class name
  46408. * @returns StereoscopicArcRotateCamera
  46409. */
  46410. getClassName(): string;
  46411. }
  46412. }
  46413. declare module BABYLON {
  46414. /**
  46415. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46416. * @see https://doc.babylonjs.com/features/cameras
  46417. */
  46418. export class StereoscopicFreeCamera extends FreeCamera {
  46419. /**
  46420. * Creates a new StereoscopicFreeCamera
  46421. * @param name defines camera name
  46422. * @param position defines initial position
  46423. * @param interaxialDistance defines distance between each color axis
  46424. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46425. * @param scene defines the hosting scene
  46426. */
  46427. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46428. /**
  46429. * Gets camera class name
  46430. * @returns StereoscopicFreeCamera
  46431. */
  46432. getClassName(): string;
  46433. }
  46434. }
  46435. declare module BABYLON {
  46436. /**
  46437. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46438. * @see https://doc.babylonjs.com/features/cameras
  46439. */
  46440. export class StereoscopicGamepadCamera extends GamepadCamera {
  46441. /**
  46442. * Creates a new StereoscopicGamepadCamera
  46443. * @param name defines camera name
  46444. * @param position defines initial position
  46445. * @param interaxialDistance defines distance between each color axis
  46446. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46447. * @param scene defines the hosting scene
  46448. */
  46449. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46450. /**
  46451. * Gets camera class name
  46452. * @returns StereoscopicGamepadCamera
  46453. */
  46454. getClassName(): string;
  46455. }
  46456. }
  46457. declare module BABYLON {
  46458. /**
  46459. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46460. * @see https://doc.babylonjs.com/features/cameras
  46461. */
  46462. export class StereoscopicUniversalCamera extends UniversalCamera {
  46463. /**
  46464. * Creates a new StereoscopicUniversalCamera
  46465. * @param name defines camera name
  46466. * @param position defines initial position
  46467. * @param interaxialDistance defines distance between each color axis
  46468. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46469. * @param scene defines the hosting scene
  46470. */
  46471. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46472. /**
  46473. * Gets camera class name
  46474. * @returns StereoscopicUniversalCamera
  46475. */
  46476. getClassName(): string;
  46477. }
  46478. }
  46479. declare module BABYLON {
  46480. /**
  46481. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46482. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46483. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46484. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46485. */
  46486. export class VirtualJoysticksCamera extends FreeCamera {
  46487. /**
  46488. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46489. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46490. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46491. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46492. * @param name Define the name of the camera in the scene
  46493. * @param position Define the start position of the camera in the scene
  46494. * @param scene Define the scene the camera belongs to
  46495. */
  46496. constructor(name: string, position: Vector3, scene: Scene);
  46497. /**
  46498. * Gets the current object class name.
  46499. * @return the class name
  46500. */
  46501. getClassName(): string;
  46502. }
  46503. }
  46504. declare module BABYLON {
  46505. /**
  46506. * This represents all the required metrics to create a VR camera.
  46507. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46508. */
  46509. export class VRCameraMetrics {
  46510. /**
  46511. * Define the horizontal resolution off the screen.
  46512. */
  46513. hResolution: number;
  46514. /**
  46515. * Define the vertical resolution off the screen.
  46516. */
  46517. vResolution: number;
  46518. /**
  46519. * Define the horizontal screen size.
  46520. */
  46521. hScreenSize: number;
  46522. /**
  46523. * Define the vertical screen size.
  46524. */
  46525. vScreenSize: number;
  46526. /**
  46527. * Define the vertical screen center position.
  46528. */
  46529. vScreenCenter: number;
  46530. /**
  46531. * Define the distance of the eyes to the screen.
  46532. */
  46533. eyeToScreenDistance: number;
  46534. /**
  46535. * Define the distance between both lenses
  46536. */
  46537. lensSeparationDistance: number;
  46538. /**
  46539. * Define the distance between both viewer's eyes.
  46540. */
  46541. interpupillaryDistance: number;
  46542. /**
  46543. * Define the distortion factor of the VR postprocess.
  46544. * Please, touch with care.
  46545. */
  46546. distortionK: number[];
  46547. /**
  46548. * Define the chromatic aberration correction factors for the VR post process.
  46549. */
  46550. chromaAbCorrection: number[];
  46551. /**
  46552. * Define the scale factor of the post process.
  46553. * The smaller the better but the slower.
  46554. */
  46555. postProcessScaleFactor: number;
  46556. /**
  46557. * Define an offset for the lens center.
  46558. */
  46559. lensCenterOffset: number;
  46560. /**
  46561. * Define if the current vr camera should compensate the distortion of the lense or not.
  46562. */
  46563. compensateDistortion: boolean;
  46564. /**
  46565. * Defines if multiview should be enabled when rendering (Default: false)
  46566. */
  46567. multiviewEnabled: boolean;
  46568. /**
  46569. * Gets the rendering aspect ratio based on the provided resolutions.
  46570. */
  46571. get aspectRatio(): number;
  46572. /**
  46573. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46574. */
  46575. get aspectRatioFov(): number;
  46576. /**
  46577. * @hidden
  46578. */
  46579. get leftHMatrix(): Matrix;
  46580. /**
  46581. * @hidden
  46582. */
  46583. get rightHMatrix(): Matrix;
  46584. /**
  46585. * @hidden
  46586. */
  46587. get leftPreViewMatrix(): Matrix;
  46588. /**
  46589. * @hidden
  46590. */
  46591. get rightPreViewMatrix(): Matrix;
  46592. /**
  46593. * Get the default VRMetrics based on the most generic setup.
  46594. * @returns the default vr metrics
  46595. */
  46596. static GetDefault(): VRCameraMetrics;
  46597. }
  46598. }
  46599. declare module BABYLON {
  46600. /** @hidden */
  46601. export var vrDistortionCorrectionPixelShader: {
  46602. name: string;
  46603. shader: string;
  46604. };
  46605. }
  46606. declare module BABYLON {
  46607. /**
  46608. * VRDistortionCorrectionPostProcess used for mobile VR
  46609. */
  46610. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46611. private _isRightEye;
  46612. private _distortionFactors;
  46613. private _postProcessScaleFactor;
  46614. private _lensCenterOffset;
  46615. private _scaleIn;
  46616. private _scaleFactor;
  46617. private _lensCenter;
  46618. /**
  46619. * Gets a string identifying the name of the class
  46620. * @returns "VRDistortionCorrectionPostProcess" string
  46621. */
  46622. getClassName(): string;
  46623. /**
  46624. * Initializes the VRDistortionCorrectionPostProcess
  46625. * @param name The name of the effect.
  46626. * @param camera The camera to apply the render pass to.
  46627. * @param isRightEye If this is for the right eye distortion
  46628. * @param vrMetrics All the required metrics for the VR camera
  46629. */
  46630. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46631. }
  46632. }
  46633. declare module BABYLON {
  46634. /**
  46635. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46636. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46637. */
  46638. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46639. /**
  46640. * Creates a new VRDeviceOrientationArcRotateCamera
  46641. * @param name defines camera name
  46642. * @param alpha defines the camera rotation along the logitudinal axis
  46643. * @param beta defines the camera rotation along the latitudinal axis
  46644. * @param radius defines the camera distance from its target
  46645. * @param target defines the camera target
  46646. * @param scene defines the scene the camera belongs to
  46647. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46648. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46649. */
  46650. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46651. /**
  46652. * Gets camera class name
  46653. * @returns VRDeviceOrientationArcRotateCamera
  46654. */
  46655. getClassName(): string;
  46656. }
  46657. }
  46658. declare module BABYLON {
  46659. /**
  46660. * Camera used to simulate VR rendering (based on FreeCamera)
  46661. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46662. */
  46663. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46664. /**
  46665. * Creates a new VRDeviceOrientationFreeCamera
  46666. * @param name defines camera name
  46667. * @param position defines the start position of the camera
  46668. * @param scene defines the scene the camera belongs to
  46669. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46670. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46671. */
  46672. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46673. /**
  46674. * Gets camera class name
  46675. * @returns VRDeviceOrientationFreeCamera
  46676. */
  46677. getClassName(): string;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46683. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46684. */
  46685. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46686. /**
  46687. * Creates a new VRDeviceOrientationGamepadCamera
  46688. * @param name defines camera name
  46689. * @param position defines the start position of the camera
  46690. * @param scene defines the scene the camera belongs to
  46691. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46692. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46693. */
  46694. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46695. /**
  46696. * Gets camera class name
  46697. * @returns VRDeviceOrientationGamepadCamera
  46698. */
  46699. getClassName(): string;
  46700. }
  46701. }
  46702. declare module BABYLON {
  46703. /**
  46704. * A class extending Texture allowing drawing on a texture
  46705. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46706. */
  46707. export class DynamicTexture extends Texture {
  46708. private _generateMipMaps;
  46709. private _canvas;
  46710. private _context;
  46711. /**
  46712. * Creates a DynamicTexture
  46713. * @param name defines the name of the texture
  46714. * @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
  46715. * @param scene defines the scene where you want the texture
  46716. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46717. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46718. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46719. */
  46720. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46721. /**
  46722. * Get the current class name of the texture useful for serialization or dynamic coding.
  46723. * @returns "DynamicTexture"
  46724. */
  46725. getClassName(): string;
  46726. /**
  46727. * Gets the current state of canRescale
  46728. */
  46729. get canRescale(): boolean;
  46730. private _recreate;
  46731. /**
  46732. * Scales the texture
  46733. * @param ratio the scale factor to apply to both width and height
  46734. */
  46735. scale(ratio: number): void;
  46736. /**
  46737. * Resizes the texture
  46738. * @param width the new width
  46739. * @param height the new height
  46740. */
  46741. scaleTo(width: number, height: number): void;
  46742. /**
  46743. * Gets the context of the canvas used by the texture
  46744. * @returns the canvas context of the dynamic texture
  46745. */
  46746. getContext(): CanvasRenderingContext2D;
  46747. /**
  46748. * Clears the texture
  46749. */
  46750. clear(): void;
  46751. /**
  46752. * Updates the texture
  46753. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46754. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46755. */
  46756. update(invertY?: boolean, premulAlpha?: boolean): void;
  46757. /**
  46758. * Draws text onto the texture
  46759. * @param text defines the text to be drawn
  46760. * @param x defines the placement of the text from the left
  46761. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46762. * @param font defines the font to be used with font-style, font-size, font-name
  46763. * @param color defines the color used for the text
  46764. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46765. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46766. * @param update defines whether texture is immediately update (default is true)
  46767. */
  46768. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46769. /**
  46770. * Clones the texture
  46771. * @returns the clone of the texture.
  46772. */
  46773. clone(): DynamicTexture;
  46774. /**
  46775. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46776. * @returns a serialized dynamic texture object
  46777. */
  46778. serialize(): any;
  46779. private _IsCanvasElement;
  46780. /** @hidden */
  46781. _rebuild(): void;
  46782. }
  46783. }
  46784. declare module BABYLON {
  46785. /**
  46786. * Class containing static functions to help procedurally build meshes
  46787. */
  46788. export class GroundBuilder {
  46789. /**
  46790. * Creates a ground mesh
  46791. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46792. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46794. * @param name defines the name of the mesh
  46795. * @param options defines the options used to create the mesh
  46796. * @param scene defines the hosting scene
  46797. * @returns the ground mesh
  46798. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46799. */
  46800. static CreateGround(name: string, options: {
  46801. width?: number;
  46802. height?: number;
  46803. subdivisions?: number;
  46804. subdivisionsX?: number;
  46805. subdivisionsY?: number;
  46806. updatable?: boolean;
  46807. }, scene: any): Mesh;
  46808. /**
  46809. * Creates a tiled ground mesh
  46810. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46811. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46812. * * 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
  46813. * * 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
  46814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46815. * @param name defines the name of the mesh
  46816. * @param options defines the options used to create the mesh
  46817. * @param scene defines the hosting scene
  46818. * @returns the tiled ground mesh
  46819. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46820. */
  46821. static CreateTiledGround(name: string, options: {
  46822. xmin: number;
  46823. zmin: number;
  46824. xmax: number;
  46825. zmax: number;
  46826. subdivisions?: {
  46827. w: number;
  46828. h: number;
  46829. };
  46830. precision?: {
  46831. w: number;
  46832. h: number;
  46833. };
  46834. updatable?: boolean;
  46835. }, scene?: Nullable<Scene>): Mesh;
  46836. /**
  46837. * Creates a ground mesh from a height map
  46838. * * The parameter `url` sets the URL of the height map image resource.
  46839. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46840. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46841. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46842. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46843. * * 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.
  46844. * * 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).
  46845. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46847. * @param name defines the name of the mesh
  46848. * @param url defines the url to the height map
  46849. * @param options defines the options used to create the mesh
  46850. * @param scene defines the hosting scene
  46851. * @returns the ground mesh
  46852. * @see https://doc.babylonjs.com/babylon101/height_map
  46853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46854. */
  46855. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46856. width?: number;
  46857. height?: number;
  46858. subdivisions?: number;
  46859. minHeight?: number;
  46860. maxHeight?: number;
  46861. colorFilter?: Color3;
  46862. alphaFilter?: number;
  46863. updatable?: boolean;
  46864. onReady?: (mesh: GroundMesh) => void;
  46865. }, scene?: Nullable<Scene>): GroundMesh;
  46866. }
  46867. }
  46868. declare module BABYLON {
  46869. /**
  46870. * Class containing static functions to help procedurally build meshes
  46871. */
  46872. export class TorusBuilder {
  46873. /**
  46874. * Creates a torus mesh
  46875. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46876. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46877. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46879. * * 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
  46880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46881. * @param name defines the name of the mesh
  46882. * @param options defines the options used to create the mesh
  46883. * @param scene defines the hosting scene
  46884. * @returns the torus mesh
  46885. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46886. */
  46887. static CreateTorus(name: string, options: {
  46888. diameter?: number;
  46889. thickness?: number;
  46890. tessellation?: number;
  46891. updatable?: boolean;
  46892. sideOrientation?: number;
  46893. frontUVs?: Vector4;
  46894. backUVs?: Vector4;
  46895. }, scene: any): Mesh;
  46896. }
  46897. }
  46898. declare module BABYLON {
  46899. /**
  46900. * Class containing static functions to help procedurally build meshes
  46901. */
  46902. export class CylinderBuilder {
  46903. /**
  46904. * Creates a cylinder or a cone mesh
  46905. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46906. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46907. * * 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.
  46908. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46909. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46910. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46911. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46912. * * 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).
  46913. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46914. * * 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).
  46915. * * 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
  46916. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46917. * * 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
  46918. * * 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.
  46919. * * If `enclose` is false, a ring surface is one element.
  46920. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46921. * * 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
  46922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46923. * * 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
  46924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46925. * @param name defines the name of the mesh
  46926. * @param options defines the options used to create the mesh
  46927. * @param scene defines the hosting scene
  46928. * @returns the cylinder mesh
  46929. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46930. */
  46931. static CreateCylinder(name: string, options: {
  46932. height?: number;
  46933. diameterTop?: number;
  46934. diameterBottom?: number;
  46935. diameter?: number;
  46936. tessellation?: number;
  46937. subdivisions?: number;
  46938. arc?: number;
  46939. faceColors?: Color4[];
  46940. faceUV?: Vector4[];
  46941. updatable?: boolean;
  46942. hasRings?: boolean;
  46943. enclose?: boolean;
  46944. cap?: number;
  46945. sideOrientation?: number;
  46946. frontUVs?: Vector4;
  46947. backUVs?: Vector4;
  46948. }, scene: any): Mesh;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /**
  46953. * States of the webXR experience
  46954. */
  46955. export enum WebXRState {
  46956. /**
  46957. * Transitioning to being in XR mode
  46958. */
  46959. ENTERING_XR = 0,
  46960. /**
  46961. * Transitioning to non XR mode
  46962. */
  46963. EXITING_XR = 1,
  46964. /**
  46965. * In XR mode and presenting
  46966. */
  46967. IN_XR = 2,
  46968. /**
  46969. * Not entered XR mode
  46970. */
  46971. NOT_IN_XR = 3
  46972. }
  46973. /**
  46974. * Abstraction of the XR render target
  46975. */
  46976. export interface WebXRRenderTarget extends IDisposable {
  46977. /**
  46978. * xrpresent context of the canvas which can be used to display/mirror xr content
  46979. */
  46980. canvasContext: WebGLRenderingContext;
  46981. /**
  46982. * xr layer for the canvas
  46983. */
  46984. xrLayer: Nullable<XRWebGLLayer>;
  46985. /**
  46986. * Initializes the xr layer for the session
  46987. * @param xrSession xr session
  46988. * @returns a promise that will resolve once the XR Layer has been created
  46989. */
  46990. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46991. }
  46992. }
  46993. declare module BABYLON {
  46994. /**
  46995. * COnfiguration object for WebXR output canvas
  46996. */
  46997. export class WebXRManagedOutputCanvasOptions {
  46998. /**
  46999. * An optional canvas in case you wish to create it yourself and provide it here.
  47000. * If not provided, a new canvas will be created
  47001. */
  47002. canvasElement?: HTMLCanvasElement;
  47003. /**
  47004. * Options for this XR Layer output
  47005. */
  47006. canvasOptions?: XRWebGLLayerOptions;
  47007. /**
  47008. * CSS styling for a newly created canvas (if not provided)
  47009. */
  47010. newCanvasCssStyle?: string;
  47011. /**
  47012. * Get the default values of the configuration object
  47013. * @param engine defines the engine to use (can be null)
  47014. * @returns default values of this configuration object
  47015. */
  47016. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  47017. }
  47018. /**
  47019. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47020. */
  47021. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47022. private _options;
  47023. private _canvas;
  47024. private _engine;
  47025. private _originalCanvasSize;
  47026. /**
  47027. * Rendering context of the canvas which can be used to display/mirror xr content
  47028. */
  47029. canvasContext: WebGLRenderingContext;
  47030. /**
  47031. * xr layer for the canvas
  47032. */
  47033. xrLayer: Nullable<XRWebGLLayer>;
  47034. /**
  47035. * Obseervers registered here will be triggered when the xr layer was initialized
  47036. */
  47037. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47038. /**
  47039. * Initializes the canvas to be added/removed upon entering/exiting xr
  47040. * @param _xrSessionManager The XR Session manager
  47041. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47042. */
  47043. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47044. /**
  47045. * Disposes of the object
  47046. */
  47047. dispose(): void;
  47048. /**
  47049. * Initializes the xr layer for the session
  47050. * @param xrSession xr session
  47051. * @returns a promise that will resolve once the XR Layer has been created
  47052. */
  47053. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47054. private _addCanvas;
  47055. private _removeCanvas;
  47056. private _setCanvasSize;
  47057. private _setManagedOutputCanvas;
  47058. }
  47059. }
  47060. declare module BABYLON {
  47061. /**
  47062. * Manages an XRSession to work with Babylon's engine
  47063. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47064. */
  47065. export class WebXRSessionManager implements IDisposable {
  47066. /** The scene which the session should be created for */
  47067. scene: Scene;
  47068. private _referenceSpace;
  47069. private _rttProvider;
  47070. private _sessionEnded;
  47071. private _xrNavigator;
  47072. private baseLayer;
  47073. /**
  47074. * The base reference space from which the session started. good if you want to reset your
  47075. * reference space
  47076. */
  47077. baseReferenceSpace: XRReferenceSpace;
  47078. /**
  47079. * Current XR frame
  47080. */
  47081. currentFrame: Nullable<XRFrame>;
  47082. /** WebXR timestamp updated every frame */
  47083. currentTimestamp: number;
  47084. /**
  47085. * Used just in case of a failure to initialize an immersive session.
  47086. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47087. */
  47088. defaultHeightCompensation: number;
  47089. /**
  47090. * Fires every time a new xrFrame arrives which can be used to update the camera
  47091. */
  47092. onXRFrameObservable: Observable<XRFrame>;
  47093. /**
  47094. * Fires when the reference space changed
  47095. */
  47096. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47097. /**
  47098. * Fires when the xr session is ended either by the device or manually done
  47099. */
  47100. onXRSessionEnded: Observable<any>;
  47101. /**
  47102. * Fires when the xr session is ended either by the device or manually done
  47103. */
  47104. onXRSessionInit: Observable<XRSession>;
  47105. /**
  47106. * Underlying xr session
  47107. */
  47108. session: XRSession;
  47109. /**
  47110. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47111. * or get the offset the player is currently at.
  47112. */
  47113. viewerReferenceSpace: XRReferenceSpace;
  47114. /**
  47115. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47116. * @param scene The scene which the session should be created for
  47117. */
  47118. constructor(
  47119. /** The scene which the session should be created for */
  47120. scene: Scene);
  47121. /**
  47122. * The current reference space used in this session. This reference space can constantly change!
  47123. * It is mainly used to offset the camera's position.
  47124. */
  47125. get referenceSpace(): XRReferenceSpace;
  47126. /**
  47127. * Set a new reference space and triggers the observable
  47128. */
  47129. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47130. /**
  47131. * Disposes of the session manager
  47132. */
  47133. dispose(): void;
  47134. /**
  47135. * Stops the xrSession and restores the render loop
  47136. * @returns Promise which resolves after it exits XR
  47137. */
  47138. exitXRAsync(): Promise<void>;
  47139. /**
  47140. * Gets the correct render target texture to be rendered this frame for this eye
  47141. * @param eye the eye for which to get the render target
  47142. * @returns the render target for the specified eye
  47143. */
  47144. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47145. /**
  47146. * Creates a WebXRRenderTarget object for the XR session
  47147. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47148. * @param options optional options to provide when creating a new render target
  47149. * @returns a WebXR render target to which the session can render
  47150. */
  47151. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47152. /**
  47153. * Initializes the manager
  47154. * After initialization enterXR can be called to start an XR session
  47155. * @returns Promise which resolves after it is initialized
  47156. */
  47157. initializeAsync(): Promise<void>;
  47158. /**
  47159. * Initializes an xr session
  47160. * @param xrSessionMode mode to initialize
  47161. * @param xrSessionInit defines optional and required values to pass to the session builder
  47162. * @returns a promise which will resolve once the session has been initialized
  47163. */
  47164. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47165. /**
  47166. * Checks if a session would be supported for the creation options specified
  47167. * @param sessionMode session mode to check if supported eg. immersive-vr
  47168. * @returns A Promise that resolves to true if supported and false if not
  47169. */
  47170. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47171. /**
  47172. * Resets the reference space to the one started the session
  47173. */
  47174. resetReferenceSpace(): void;
  47175. /**
  47176. * Starts rendering to the xr layer
  47177. */
  47178. runXRRenderLoop(): void;
  47179. /**
  47180. * Sets the reference space on the xr session
  47181. * @param referenceSpaceType space to set
  47182. * @returns a promise that will resolve once the reference space has been set
  47183. */
  47184. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47185. /**
  47186. * Updates the render state of the session
  47187. * @param state state to set
  47188. * @returns a promise that resolves once the render state has been updated
  47189. */
  47190. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47191. /**
  47192. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47193. * @param sessionMode defines the session to test
  47194. * @returns a promise with boolean as final value
  47195. */
  47196. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47197. private _createRenderTargetTexture;
  47198. }
  47199. }
  47200. declare module BABYLON {
  47201. /**
  47202. * WebXR Camera which holds the views for the xrSession
  47203. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47204. */
  47205. export class WebXRCamera extends FreeCamera {
  47206. private _xrSessionManager;
  47207. private _firstFrame;
  47208. private _referenceQuaternion;
  47209. private _referencedPosition;
  47210. private _xrInvPositionCache;
  47211. private _xrInvQuaternionCache;
  47212. /**
  47213. * Observable raised before camera teleportation
  47214. */
  47215. onBeforeCameraTeleport: Observable<Vector3>;
  47216. /**
  47217. * Observable raised after camera teleportation
  47218. */
  47219. onAfterCameraTeleport: Observable<Vector3>;
  47220. /**
  47221. * Should position compensation execute on first frame.
  47222. * This is used when copying the position from a native (non XR) camera
  47223. */
  47224. compensateOnFirstFrame: boolean;
  47225. /**
  47226. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47227. * @param name the name of the camera
  47228. * @param scene the scene to add the camera to
  47229. * @param _xrSessionManager a constructed xr session manager
  47230. */
  47231. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47232. /**
  47233. * Return the user's height, unrelated to the current ground.
  47234. * This will be the y position of this camera, when ground level is 0.
  47235. */
  47236. get realWorldHeight(): number;
  47237. /** @hidden */
  47238. _updateForDualEyeDebugging(): void;
  47239. /**
  47240. * Sets this camera's transformation based on a non-vr camera
  47241. * @param otherCamera the non-vr camera to copy the transformation from
  47242. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47243. */
  47244. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47245. /**
  47246. * Gets the current instance class name ("WebXRCamera").
  47247. * @returns the class name
  47248. */
  47249. getClassName(): string;
  47250. private _rotate180;
  47251. private _updateFromXRSession;
  47252. private _updateNumberOfRigCameras;
  47253. private _updateReferenceSpace;
  47254. private _updateReferenceSpaceOffset;
  47255. }
  47256. }
  47257. declare module BABYLON {
  47258. /**
  47259. * Defining the interface required for a (webxr) feature
  47260. */
  47261. export interface IWebXRFeature extends IDisposable {
  47262. /**
  47263. * Is this feature attached
  47264. */
  47265. attached: boolean;
  47266. /**
  47267. * Should auto-attach be disabled?
  47268. */
  47269. disableAutoAttach: boolean;
  47270. /**
  47271. * Attach the feature to the session
  47272. * Will usually be called by the features manager
  47273. *
  47274. * @param force should attachment be forced (even when already attached)
  47275. * @returns true if successful.
  47276. */
  47277. attach(force?: boolean): boolean;
  47278. /**
  47279. * Detach the feature from the session
  47280. * Will usually be called by the features manager
  47281. *
  47282. * @returns true if successful.
  47283. */
  47284. detach(): boolean;
  47285. /**
  47286. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47287. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47288. *
  47289. * @returns whether or not the feature is compatible in this environment
  47290. */
  47291. isCompatible(): boolean;
  47292. /**
  47293. * Was this feature disposed;
  47294. */
  47295. isDisposed: boolean;
  47296. /**
  47297. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47298. */
  47299. xrNativeFeatureName?: string;
  47300. /**
  47301. * A list of (Babylon WebXR) features this feature depends on
  47302. */
  47303. dependsOn?: string[];
  47304. }
  47305. /**
  47306. * A list of the currently available features without referencing them
  47307. */
  47308. export class WebXRFeatureName {
  47309. /**
  47310. * The name of the anchor system feature
  47311. */
  47312. static readonly ANCHOR_SYSTEM: string;
  47313. /**
  47314. * The name of the background remover feature
  47315. */
  47316. static readonly BACKGROUND_REMOVER: string;
  47317. /**
  47318. * The name of the hit test feature
  47319. */
  47320. static readonly HIT_TEST: string;
  47321. /**
  47322. * physics impostors for xr controllers feature
  47323. */
  47324. static readonly PHYSICS_CONTROLLERS: string;
  47325. /**
  47326. * The name of the plane detection feature
  47327. */
  47328. static readonly PLANE_DETECTION: string;
  47329. /**
  47330. * The name of the pointer selection feature
  47331. */
  47332. static readonly POINTER_SELECTION: string;
  47333. /**
  47334. * The name of the teleportation feature
  47335. */
  47336. static readonly TELEPORTATION: string;
  47337. /**
  47338. * The name of the feature points feature.
  47339. */
  47340. static readonly FEATURE_POINTS: string;
  47341. /**
  47342. * The name of the hand tracking feature.
  47343. */
  47344. static readonly HAND_TRACKING: string;
  47345. }
  47346. /**
  47347. * Defining the constructor of a feature. Used to register the modules.
  47348. */
  47349. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47350. /**
  47351. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47352. * It is mainly used in AR sessions.
  47353. *
  47354. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47355. */
  47356. export class WebXRFeaturesManager implements IDisposable {
  47357. private _xrSessionManager;
  47358. private static readonly _AvailableFeatures;
  47359. private _features;
  47360. /**
  47361. * constructs a new features manages.
  47362. *
  47363. * @param _xrSessionManager an instance of WebXRSessionManager
  47364. */
  47365. constructor(_xrSessionManager: WebXRSessionManager);
  47366. /**
  47367. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47368. * Mainly used internally.
  47369. *
  47370. * @param featureName the name of the feature to register
  47371. * @param constructorFunction the function used to construct the module
  47372. * @param version the (babylon) version of the module
  47373. * @param stable is that a stable version of this module
  47374. */
  47375. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47376. /**
  47377. * Returns a constructor of a specific feature.
  47378. *
  47379. * @param featureName the name of the feature to construct
  47380. * @param version the version of the feature to load
  47381. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47382. * @param options optional options provided to the module.
  47383. * @returns a function that, when called, will return a new instance of this feature
  47384. */
  47385. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47386. /**
  47387. * Can be used to return the list of features currently registered
  47388. *
  47389. * @returns an Array of available features
  47390. */
  47391. static GetAvailableFeatures(): string[];
  47392. /**
  47393. * Gets the versions available for a specific feature
  47394. * @param featureName the name of the feature
  47395. * @returns an array with the available versions
  47396. */
  47397. static GetAvailableVersions(featureName: string): string[];
  47398. /**
  47399. * Return the latest unstable version of this feature
  47400. * @param featureName the name of the feature to search
  47401. * @returns the version number. if not found will return -1
  47402. */
  47403. static GetLatestVersionOfFeature(featureName: string): number;
  47404. /**
  47405. * Return the latest stable version of this feature
  47406. * @param featureName the name of the feature to search
  47407. * @returns the version number. if not found will return -1
  47408. */
  47409. static GetStableVersionOfFeature(featureName: string): number;
  47410. /**
  47411. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47412. * Can be used during a session to start a feature
  47413. * @param featureName the name of feature to attach
  47414. */
  47415. attachFeature(featureName: string): void;
  47416. /**
  47417. * Can be used inside a session or when the session ends to detach a specific feature
  47418. * @param featureName the name of the feature to detach
  47419. */
  47420. detachFeature(featureName: string): void;
  47421. /**
  47422. * Used to disable an already-enabled feature
  47423. * The feature will be disposed and will be recreated once enabled.
  47424. * @param featureName the feature to disable
  47425. * @returns true if disable was successful
  47426. */
  47427. disableFeature(featureName: string | {
  47428. Name: string;
  47429. }): boolean;
  47430. /**
  47431. * dispose this features manager
  47432. */
  47433. dispose(): void;
  47434. /**
  47435. * 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.
  47436. * 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.
  47437. *
  47438. * @param featureName the name of the feature to load or the class of the feature
  47439. * @param version optional version to load. if not provided the latest version will be enabled
  47440. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47441. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47442. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47443. * @returns a new constructed feature or throws an error if feature not found.
  47444. */
  47445. enableFeature(featureName: string | {
  47446. Name: string;
  47447. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47448. /**
  47449. * get the implementation of an enabled feature.
  47450. * @param featureName the name of the feature to load
  47451. * @returns the feature class, if found
  47452. */
  47453. getEnabledFeature(featureName: string): IWebXRFeature;
  47454. /**
  47455. * Get the list of enabled features
  47456. * @returns an array of enabled features
  47457. */
  47458. getEnabledFeatures(): string[];
  47459. /**
  47460. * This function will exten the session creation configuration object with enabled features.
  47461. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47462. * according to the defined "required" variable, provided during enableFeature call
  47463. * @param xrSessionInit the xr Session init object to extend
  47464. *
  47465. * @returns an extended XRSessionInit object
  47466. */
  47467. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47468. }
  47469. }
  47470. declare module BABYLON {
  47471. /**
  47472. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47473. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47474. */
  47475. export class WebXRExperienceHelper implements IDisposable {
  47476. private scene;
  47477. private _nonVRCamera;
  47478. private _originalSceneAutoClear;
  47479. private _supported;
  47480. /**
  47481. * Camera used to render xr content
  47482. */
  47483. camera: WebXRCamera;
  47484. /** A features manager for this xr session */
  47485. featuresManager: WebXRFeaturesManager;
  47486. /**
  47487. * Observers registered here will be triggered after the camera's initial transformation is set
  47488. * This can be used to set a different ground level or an extra rotation.
  47489. *
  47490. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47491. * to the position set after this observable is done executing.
  47492. */
  47493. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47494. /**
  47495. * Fires when the state of the experience helper has changed
  47496. */
  47497. onStateChangedObservable: Observable<WebXRState>;
  47498. /** Session manager used to keep track of xr session */
  47499. sessionManager: WebXRSessionManager;
  47500. /**
  47501. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47502. */
  47503. state: WebXRState;
  47504. /**
  47505. * Creates a WebXRExperienceHelper
  47506. * @param scene The scene the helper should be created in
  47507. */
  47508. private constructor();
  47509. /**
  47510. * Creates the experience helper
  47511. * @param scene the scene to attach the experience helper to
  47512. * @returns a promise for the experience helper
  47513. */
  47514. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47515. /**
  47516. * Disposes of the experience helper
  47517. */
  47518. dispose(): void;
  47519. /**
  47520. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47521. * @param sessionMode options for the XR session
  47522. * @param referenceSpaceType frame of reference of the XR session
  47523. * @param renderTarget the output canvas that will be used to enter XR mode
  47524. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47525. * @returns promise that resolves after xr mode has entered
  47526. */
  47527. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47528. /**
  47529. * Exits XR mode and returns the scene to its original state
  47530. * @returns promise that resolves after xr mode has exited
  47531. */
  47532. exitXRAsync(): Promise<void>;
  47533. private _nonXRToXRCamera;
  47534. private _setState;
  47535. }
  47536. }
  47537. declare module BABYLON {
  47538. /**
  47539. * X-Y values for axes in WebXR
  47540. */
  47541. export interface IWebXRMotionControllerAxesValue {
  47542. /**
  47543. * The value of the x axis
  47544. */
  47545. x: number;
  47546. /**
  47547. * The value of the y-axis
  47548. */
  47549. y: number;
  47550. }
  47551. /**
  47552. * changed / previous values for the values of this component
  47553. */
  47554. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47555. /**
  47556. * current (this frame) value
  47557. */
  47558. current: T;
  47559. /**
  47560. * previous (last change) value
  47561. */
  47562. previous: T;
  47563. }
  47564. /**
  47565. * Represents changes in the component between current frame and last values recorded
  47566. */
  47567. export interface IWebXRMotionControllerComponentChanges {
  47568. /**
  47569. * will be populated with previous and current values if axes changed
  47570. */
  47571. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47572. /**
  47573. * will be populated with previous and current values if pressed changed
  47574. */
  47575. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47576. /**
  47577. * will be populated with previous and current values if touched changed
  47578. */
  47579. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47580. /**
  47581. * will be populated with previous and current values if value changed
  47582. */
  47583. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47584. }
  47585. /**
  47586. * This class represents a single component (for example button or thumbstick) of a motion controller
  47587. */
  47588. export class WebXRControllerComponent implements IDisposable {
  47589. /**
  47590. * the id of this component
  47591. */
  47592. id: string;
  47593. /**
  47594. * the type of the component
  47595. */
  47596. type: MotionControllerComponentType;
  47597. private _buttonIndex;
  47598. private _axesIndices;
  47599. private _axes;
  47600. private _changes;
  47601. private _currentValue;
  47602. private _hasChanges;
  47603. private _pressed;
  47604. private _touched;
  47605. /**
  47606. * button component type
  47607. */
  47608. static BUTTON_TYPE: MotionControllerComponentType;
  47609. /**
  47610. * squeeze component type
  47611. */
  47612. static SQUEEZE_TYPE: MotionControllerComponentType;
  47613. /**
  47614. * Thumbstick component type
  47615. */
  47616. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47617. /**
  47618. * Touchpad component type
  47619. */
  47620. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47621. /**
  47622. * trigger component type
  47623. */
  47624. static TRIGGER_TYPE: MotionControllerComponentType;
  47625. /**
  47626. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47627. * the axes data changes
  47628. */
  47629. onAxisValueChangedObservable: Observable<{
  47630. x: number;
  47631. y: number;
  47632. }>;
  47633. /**
  47634. * Observers registered here will be triggered when the state of a button changes
  47635. * State change is either pressed / touched / value
  47636. */
  47637. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47638. /**
  47639. * Creates a new component for a motion controller.
  47640. * It is created by the motion controller itself
  47641. *
  47642. * @param id the id of this component
  47643. * @param type the type of the component
  47644. * @param _buttonIndex index in the buttons array of the gamepad
  47645. * @param _axesIndices indices of the values in the axes array of the gamepad
  47646. */
  47647. constructor(
  47648. /**
  47649. * the id of this component
  47650. */
  47651. id: string,
  47652. /**
  47653. * the type of the component
  47654. */
  47655. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47656. /**
  47657. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47658. */
  47659. get axes(): IWebXRMotionControllerAxesValue;
  47660. /**
  47661. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47662. */
  47663. get changes(): IWebXRMotionControllerComponentChanges;
  47664. /**
  47665. * Return whether or not the component changed the last frame
  47666. */
  47667. get hasChanges(): boolean;
  47668. /**
  47669. * is the button currently pressed
  47670. */
  47671. get pressed(): boolean;
  47672. /**
  47673. * is the button currently touched
  47674. */
  47675. get touched(): boolean;
  47676. /**
  47677. * Get the current value of this component
  47678. */
  47679. get value(): number;
  47680. /**
  47681. * Dispose this component
  47682. */
  47683. dispose(): void;
  47684. /**
  47685. * Are there axes correlating to this component
  47686. * @return true is axes data is available
  47687. */
  47688. isAxes(): boolean;
  47689. /**
  47690. * Is this component a button (hence - pressable)
  47691. * @returns true if can be pressed
  47692. */
  47693. isButton(): boolean;
  47694. /**
  47695. * update this component using the gamepad object it is in. Called on every frame
  47696. * @param nativeController the native gamepad controller object
  47697. */
  47698. update(nativeController: IMinimalMotionControllerObject): void;
  47699. }
  47700. }
  47701. declare module BABYLON {
  47702. /**
  47703. * Interface used to represent data loading progression
  47704. */
  47705. export interface ISceneLoaderProgressEvent {
  47706. /**
  47707. * Defines if data length to load can be evaluated
  47708. */
  47709. readonly lengthComputable: boolean;
  47710. /**
  47711. * Defines the loaded data length
  47712. */
  47713. readonly loaded: number;
  47714. /**
  47715. * Defines the data length to load
  47716. */
  47717. readonly total: number;
  47718. }
  47719. /**
  47720. * Interface used by SceneLoader plugins to define supported file extensions
  47721. */
  47722. export interface ISceneLoaderPluginExtensions {
  47723. /**
  47724. * Defines the list of supported extensions
  47725. */
  47726. [extension: string]: {
  47727. isBinary: boolean;
  47728. };
  47729. }
  47730. /**
  47731. * Interface used by SceneLoader plugin factory
  47732. */
  47733. export interface ISceneLoaderPluginFactory {
  47734. /**
  47735. * Defines the name of the factory
  47736. */
  47737. name: string;
  47738. /**
  47739. * Function called to create a new plugin
  47740. * @return the new plugin
  47741. */
  47742. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47743. /**
  47744. * The callback that returns true if the data can be directly loaded.
  47745. * @param data string containing the file data
  47746. * @returns if the data can be loaded directly
  47747. */
  47748. canDirectLoad?(data: string): boolean;
  47749. }
  47750. /**
  47751. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47752. */
  47753. export interface ISceneLoaderPluginBase {
  47754. /**
  47755. * The friendly name of this plugin.
  47756. */
  47757. name: string;
  47758. /**
  47759. * The file extensions supported by this plugin.
  47760. */
  47761. extensions: string | ISceneLoaderPluginExtensions;
  47762. /**
  47763. * The callback called when loading from a url.
  47764. * @param scene scene loading this url
  47765. * @param url url to load
  47766. * @param onSuccess callback called when the file successfully loads
  47767. * @param onProgress callback called while file is loading (if the server supports this mode)
  47768. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47769. * @param onError callback called when the file fails to load
  47770. * @returns a file request object
  47771. */
  47772. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47773. /**
  47774. * The callback called when loading from a file object.
  47775. * @param scene scene loading this file
  47776. * @param file defines the file to load
  47777. * @param onSuccess defines the callback to call when data is loaded
  47778. * @param onProgress defines the callback to call during loading process
  47779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47780. * @param onError defines the callback to call when an error occurs
  47781. * @returns a file request object
  47782. */
  47783. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47784. /**
  47785. * The callback that returns true if the data can be directly loaded.
  47786. * @param data string containing the file data
  47787. * @returns if the data can be loaded directly
  47788. */
  47789. canDirectLoad?(data: string): boolean;
  47790. /**
  47791. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47792. * @param scene scene loading this data
  47793. * @param data string containing the data
  47794. * @returns data to pass to the plugin
  47795. */
  47796. directLoad?(scene: Scene, data: string): any;
  47797. /**
  47798. * The callback that allows custom handling of the root url based on the response url.
  47799. * @param rootUrl the original root url
  47800. * @param responseURL the response url if available
  47801. * @returns the new root url
  47802. */
  47803. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47804. }
  47805. /**
  47806. * Interface used to define a SceneLoader plugin
  47807. */
  47808. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47809. /**
  47810. * Import meshes into a scene.
  47811. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47812. * @param scene The scene to import into
  47813. * @param data The data to import
  47814. * @param rootUrl The root url for scene and resources
  47815. * @param meshes The meshes array to import into
  47816. * @param particleSystems The particle systems array to import into
  47817. * @param skeletons The skeletons array to import into
  47818. * @param onError The callback when import fails
  47819. * @returns True if successful or false otherwise
  47820. */
  47821. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47822. /**
  47823. * Load into a scene.
  47824. * @param scene The scene to load into
  47825. * @param data The data to import
  47826. * @param rootUrl The root url for scene and resources
  47827. * @param onError The callback when import fails
  47828. * @returns True if successful or false otherwise
  47829. */
  47830. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47831. /**
  47832. * Load into an asset container.
  47833. * @param scene The scene to load into
  47834. * @param data The data to import
  47835. * @param rootUrl The root url for scene and resources
  47836. * @param onError The callback when import fails
  47837. * @returns The loaded asset container
  47838. */
  47839. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47840. }
  47841. /**
  47842. * Interface used to define an async SceneLoader plugin
  47843. */
  47844. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47845. /**
  47846. * Import meshes into a scene.
  47847. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47848. * @param scene The scene to import into
  47849. * @param data The data to import
  47850. * @param rootUrl The root url for scene and resources
  47851. * @param onProgress The callback when the load progresses
  47852. * @param fileName Defines the name of the file to load
  47853. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47854. */
  47855. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47856. meshes: AbstractMesh[];
  47857. particleSystems: IParticleSystem[];
  47858. skeletons: Skeleton[];
  47859. animationGroups: AnimationGroup[];
  47860. }>;
  47861. /**
  47862. * Load into a scene.
  47863. * @param scene The scene to load into
  47864. * @param data The data to import
  47865. * @param rootUrl The root url for scene and resources
  47866. * @param onProgress The callback when the load progresses
  47867. * @param fileName Defines the name of the file to load
  47868. * @returns Nothing
  47869. */
  47870. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47871. /**
  47872. * Load into an asset container.
  47873. * @param scene The scene to load into
  47874. * @param data The data to import
  47875. * @param rootUrl The root url for scene and resources
  47876. * @param onProgress The callback when the load progresses
  47877. * @param fileName Defines the name of the file to load
  47878. * @returns The loaded asset container
  47879. */
  47880. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47881. }
  47882. /**
  47883. * Mode that determines how to handle old animation groups before loading new ones.
  47884. */
  47885. export enum SceneLoaderAnimationGroupLoadingMode {
  47886. /**
  47887. * Reset all old animations to initial state then dispose them.
  47888. */
  47889. Clean = 0,
  47890. /**
  47891. * Stop all old animations.
  47892. */
  47893. Stop = 1,
  47894. /**
  47895. * Restart old animations from first frame.
  47896. */
  47897. Sync = 2,
  47898. /**
  47899. * Old animations remains untouched.
  47900. */
  47901. NoSync = 3
  47902. }
  47903. /**
  47904. * Defines a plugin registered by the SceneLoader
  47905. */
  47906. interface IRegisteredPlugin {
  47907. /**
  47908. * Defines the plugin to use
  47909. */
  47910. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47911. /**
  47912. * Defines if the plugin supports binary data
  47913. */
  47914. isBinary: boolean;
  47915. }
  47916. /**
  47917. * Class used to load scene from various file formats using registered plugins
  47918. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47919. */
  47920. export class SceneLoader {
  47921. /**
  47922. * No logging while loading
  47923. */
  47924. static readonly NO_LOGGING: number;
  47925. /**
  47926. * Minimal logging while loading
  47927. */
  47928. static readonly MINIMAL_LOGGING: number;
  47929. /**
  47930. * Summary logging while loading
  47931. */
  47932. static readonly SUMMARY_LOGGING: number;
  47933. /**
  47934. * Detailled logging while loading
  47935. */
  47936. static readonly DETAILED_LOGGING: number;
  47937. /**
  47938. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47939. */
  47940. static get ForceFullSceneLoadingForIncremental(): boolean;
  47941. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47942. /**
  47943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47944. */
  47945. static get ShowLoadingScreen(): boolean;
  47946. static set ShowLoadingScreen(value: boolean);
  47947. /**
  47948. * Defines the current logging level (while loading the scene)
  47949. * @ignorenaming
  47950. */
  47951. static get loggingLevel(): number;
  47952. static set loggingLevel(value: number);
  47953. /**
  47954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47955. */
  47956. static get CleanBoneMatrixWeights(): boolean;
  47957. static set CleanBoneMatrixWeights(value: boolean);
  47958. /**
  47959. * Event raised when a plugin is used to load a scene
  47960. */
  47961. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47962. private static _registeredPlugins;
  47963. private static _showingLoadingScreen;
  47964. /**
  47965. * Gets the default plugin (used to load Babylon files)
  47966. * @returns the .babylon plugin
  47967. */
  47968. static GetDefaultPlugin(): IRegisteredPlugin;
  47969. private static _GetPluginForExtension;
  47970. private static _GetPluginForDirectLoad;
  47971. private static _GetPluginForFilename;
  47972. private static _GetDirectLoad;
  47973. private static _LoadData;
  47974. private static _GetFileInfo;
  47975. /**
  47976. * Gets a plugin that can load the given extension
  47977. * @param extension defines the extension to load
  47978. * @returns a plugin or null if none works
  47979. */
  47980. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47981. /**
  47982. * Gets a boolean indicating that the given extension can be loaded
  47983. * @param extension defines the extension to load
  47984. * @returns true if the extension is supported
  47985. */
  47986. static IsPluginForExtensionAvailable(extension: string): boolean;
  47987. /**
  47988. * Adds a new plugin to the list of registered plugins
  47989. * @param plugin defines the plugin to add
  47990. */
  47991. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47992. /**
  47993. * Import meshes into a scene
  47994. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47995. * @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)
  47996. * @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)
  47997. * @param scene the instance of BABYLON.Scene to append to
  47998. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  47999. * @param onProgress a callback with a progress event for each file being loaded
  48000. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48001. * @param pluginExtension the extension used to determine the plugin
  48002. * @returns The loaded plugin
  48003. */
  48004. 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>;
  48005. /**
  48006. * Import meshes into a scene
  48007. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48008. * @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)
  48009. * @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)
  48010. * @param scene the instance of BABYLON.Scene to append to
  48011. * @param onProgress a callback with a progress event for each file being loaded
  48012. * @param pluginExtension the extension used to determine the plugin
  48013. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48014. */
  48015. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48016. meshes: AbstractMesh[];
  48017. particleSystems: IParticleSystem[];
  48018. skeletons: Skeleton[];
  48019. animationGroups: AnimationGroup[];
  48020. }>;
  48021. /**
  48022. * Load a scene
  48023. * @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)
  48024. * @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)
  48025. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48026. * @param onSuccess a callback with the scene when import succeeds
  48027. * @param onProgress a callback with a progress event for each file being loaded
  48028. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48029. * @param pluginExtension the extension used to determine the plugin
  48030. * @returns The loaded plugin
  48031. */
  48032. 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>;
  48033. /**
  48034. * Load a scene
  48035. * @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)
  48036. * @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)
  48037. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48038. * @param onProgress a callback with a progress event for each file being loaded
  48039. * @param pluginExtension the extension used to determine the plugin
  48040. * @returns The loaded scene
  48041. */
  48042. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48043. /**
  48044. * Append a scene
  48045. * @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)
  48046. * @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)
  48047. * @param scene is the instance of BABYLON.Scene to append to
  48048. * @param onSuccess a callback with the scene when import succeeds
  48049. * @param onProgress a callback with a progress event for each file being loaded
  48050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48051. * @param pluginExtension the extension used to determine the plugin
  48052. * @returns The loaded plugin
  48053. */
  48054. 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>;
  48055. /**
  48056. * Append a scene
  48057. * @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)
  48058. * @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)
  48059. * @param scene is the instance of BABYLON.Scene to append to
  48060. * @param onProgress a callback with a progress event for each file being loaded
  48061. * @param pluginExtension the extension used to determine the plugin
  48062. * @returns The given scene
  48063. */
  48064. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48065. /**
  48066. * Load a scene into an asset container
  48067. * @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)
  48068. * @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)
  48069. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48070. * @param onSuccess a callback with the scene when import succeeds
  48071. * @param onProgress a callback with a progress event for each file being loaded
  48072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48073. * @param pluginExtension the extension used to determine the plugin
  48074. * @returns The loaded plugin
  48075. */
  48076. 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>;
  48077. /**
  48078. * Load a scene into an asset container
  48079. * @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)
  48080. * @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)
  48081. * @param scene is the instance of Scene to append to
  48082. * @param onProgress a callback with a progress event for each file being loaded
  48083. * @param pluginExtension the extension used to determine the plugin
  48084. * @returns The loaded asset container
  48085. */
  48086. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48087. /**
  48088. * Import animations from a file into a scene
  48089. * @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)
  48090. * @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)
  48091. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48092. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48093. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48094. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48095. * @param onSuccess a callback with the scene when import succeeds
  48096. * @param onProgress a callback with a progress event for each file being loaded
  48097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48098. * @param pluginExtension the extension used to determine the plugin
  48099. */
  48100. 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;
  48101. /**
  48102. * Import animations from a file into a scene
  48103. * @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)
  48104. * @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)
  48105. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48106. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48107. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48108. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48109. * @param onSuccess a callback with the scene when import succeeds
  48110. * @param onProgress a callback with a progress event for each file being loaded
  48111. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48112. * @param pluginExtension the extension used to determine the plugin
  48113. * @returns the updated scene with imported animations
  48114. */
  48115. 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>;
  48116. }
  48117. }
  48118. declare module BABYLON {
  48119. /**
  48120. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48121. */
  48122. export type MotionControllerHandedness = "none" | "left" | "right";
  48123. /**
  48124. * The type of components available in motion controllers.
  48125. * This is not the name of the component.
  48126. */
  48127. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48128. /**
  48129. * The state of a controller component
  48130. */
  48131. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48132. /**
  48133. * The schema of motion controller layout.
  48134. * No object will be initialized using this interface
  48135. * This is used just to define the profile.
  48136. */
  48137. export interface IMotionControllerLayout {
  48138. /**
  48139. * Path to load the assets. Usually relative to the base path
  48140. */
  48141. assetPath: string;
  48142. /**
  48143. * Available components (unsorted)
  48144. */
  48145. components: {
  48146. /**
  48147. * A map of component Ids
  48148. */
  48149. [componentId: string]: {
  48150. /**
  48151. * The type of input the component outputs
  48152. */
  48153. type: MotionControllerComponentType;
  48154. /**
  48155. * The indices of this component in the gamepad object
  48156. */
  48157. gamepadIndices: {
  48158. /**
  48159. * Index of button
  48160. */
  48161. button?: number;
  48162. /**
  48163. * If available, index of x-axis
  48164. */
  48165. xAxis?: number;
  48166. /**
  48167. * If available, index of y-axis
  48168. */
  48169. yAxis?: number;
  48170. };
  48171. /**
  48172. * The mesh's root node name
  48173. */
  48174. rootNodeName: string;
  48175. /**
  48176. * Animation definitions for this model
  48177. */
  48178. visualResponses: {
  48179. [stateKey: string]: {
  48180. /**
  48181. * What property will be animated
  48182. */
  48183. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48184. /**
  48185. * What states influence this visual response
  48186. */
  48187. states: MotionControllerComponentStateType[];
  48188. /**
  48189. * Type of animation - movement or visibility
  48190. */
  48191. valueNodeProperty: "transform" | "visibility";
  48192. /**
  48193. * Base node name to move. Its position will be calculated according to the min and max nodes
  48194. */
  48195. valueNodeName?: string;
  48196. /**
  48197. * Minimum movement node
  48198. */
  48199. minNodeName?: string;
  48200. /**
  48201. * Max movement node
  48202. */
  48203. maxNodeName?: string;
  48204. };
  48205. };
  48206. /**
  48207. * If touch enabled, what is the name of node to display user feedback
  48208. */
  48209. touchPointNodeName?: string;
  48210. };
  48211. };
  48212. /**
  48213. * Is it xr standard mapping or not
  48214. */
  48215. gamepadMapping: "" | "xr-standard";
  48216. /**
  48217. * Base root node of this entire model
  48218. */
  48219. rootNodeName: string;
  48220. /**
  48221. * Defines the main button component id
  48222. */
  48223. selectComponentId: string;
  48224. }
  48225. /**
  48226. * A definition for the layout map in the input profile
  48227. */
  48228. export interface IMotionControllerLayoutMap {
  48229. /**
  48230. * Layouts with handedness type as a key
  48231. */
  48232. [handedness: string]: IMotionControllerLayout;
  48233. }
  48234. /**
  48235. * The XR Input profile schema
  48236. * Profiles can be found here:
  48237. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48238. */
  48239. export interface IMotionControllerProfile {
  48240. /**
  48241. * fallback profiles for this profileId
  48242. */
  48243. fallbackProfileIds: string[];
  48244. /**
  48245. * The layout map, with handedness as key
  48246. */
  48247. layouts: IMotionControllerLayoutMap;
  48248. /**
  48249. * The id of this profile
  48250. * correlates to the profile(s) in the xrInput.profiles array
  48251. */
  48252. profileId: string;
  48253. }
  48254. /**
  48255. * A helper-interface for the 3 meshes needed for controller button animation
  48256. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48257. */
  48258. export interface IMotionControllerButtonMeshMap {
  48259. /**
  48260. * the mesh that defines the pressed value mesh position.
  48261. * This is used to find the max-position of this button
  48262. */
  48263. pressedMesh: AbstractMesh;
  48264. /**
  48265. * the mesh that defines the unpressed value mesh position.
  48266. * This is used to find the min (or initial) position of this button
  48267. */
  48268. unpressedMesh: AbstractMesh;
  48269. /**
  48270. * The mesh that will be changed when value changes
  48271. */
  48272. valueMesh: AbstractMesh;
  48273. }
  48274. /**
  48275. * A helper-interface for the 3 meshes needed for controller axis animation.
  48276. * This will be expanded when touchpad animations are fully supported
  48277. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48278. */
  48279. export interface IMotionControllerMeshMap {
  48280. /**
  48281. * the mesh that defines the maximum value mesh position.
  48282. */
  48283. maxMesh?: AbstractMesh;
  48284. /**
  48285. * the mesh that defines the minimum value mesh position.
  48286. */
  48287. minMesh?: AbstractMesh;
  48288. /**
  48289. * The mesh that will be changed when axis value changes
  48290. */
  48291. valueMesh?: AbstractMesh;
  48292. }
  48293. /**
  48294. * The elements needed for change-detection of the gamepad objects in motion controllers
  48295. */
  48296. export interface IMinimalMotionControllerObject {
  48297. /**
  48298. * Available axes of this controller
  48299. */
  48300. axes: number[];
  48301. /**
  48302. * An array of available buttons
  48303. */
  48304. buttons: Array<{
  48305. /**
  48306. * Value of the button/trigger
  48307. */
  48308. value: number;
  48309. /**
  48310. * If the button/trigger is currently touched
  48311. */
  48312. touched: boolean;
  48313. /**
  48314. * If the button/trigger is currently pressed
  48315. */
  48316. pressed: boolean;
  48317. }>;
  48318. /**
  48319. * EXPERIMENTAL haptic support.
  48320. */
  48321. hapticActuators?: Array<{
  48322. pulse: (value: number, duration: number) => Promise<boolean>;
  48323. }>;
  48324. }
  48325. /**
  48326. * An Abstract Motion controller
  48327. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48328. * Each component has an observable to check for changes in value and state
  48329. */
  48330. export abstract class WebXRAbstractMotionController implements IDisposable {
  48331. protected scene: Scene;
  48332. protected layout: IMotionControllerLayout;
  48333. /**
  48334. * The gamepad object correlating to this controller
  48335. */
  48336. gamepadObject: IMinimalMotionControllerObject;
  48337. /**
  48338. * handedness (left/right/none) of this controller
  48339. */
  48340. handedness: MotionControllerHandedness;
  48341. private _initComponent;
  48342. private _modelReady;
  48343. /**
  48344. * A map of components (WebXRControllerComponent) in this motion controller
  48345. * Components have a ComponentType and can also have both button and axis definitions
  48346. */
  48347. readonly components: {
  48348. [id: string]: WebXRControllerComponent;
  48349. };
  48350. /**
  48351. * Disable the model's animation. Can be set at any time.
  48352. */
  48353. disableAnimation: boolean;
  48354. /**
  48355. * Observers registered here will be triggered when the model of this controller is done loading
  48356. */
  48357. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48358. /**
  48359. * The profile id of this motion controller
  48360. */
  48361. abstract profileId: string;
  48362. /**
  48363. * The root mesh of the model. It is null if the model was not yet initialized
  48364. */
  48365. rootMesh: Nullable<AbstractMesh>;
  48366. /**
  48367. * constructs a new abstract motion controller
  48368. * @param scene the scene to which the model of the controller will be added
  48369. * @param layout The profile layout to load
  48370. * @param gamepadObject The gamepad object correlating to this controller
  48371. * @param handedness handedness (left/right/none) of this controller
  48372. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48373. */
  48374. constructor(scene: Scene, layout: IMotionControllerLayout,
  48375. /**
  48376. * The gamepad object correlating to this controller
  48377. */
  48378. gamepadObject: IMinimalMotionControllerObject,
  48379. /**
  48380. * handedness (left/right/none) of this controller
  48381. */
  48382. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48383. /**
  48384. * Dispose this controller, the model mesh and all its components
  48385. */
  48386. dispose(): void;
  48387. /**
  48388. * Returns all components of specific type
  48389. * @param type the type to search for
  48390. * @return an array of components with this type
  48391. */
  48392. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48393. /**
  48394. * get a component based an its component id as defined in layout.components
  48395. * @param id the id of the component
  48396. * @returns the component correlates to the id or undefined if not found
  48397. */
  48398. getComponent(id: string): WebXRControllerComponent;
  48399. /**
  48400. * Get the list of components available in this motion controller
  48401. * @returns an array of strings correlating to available components
  48402. */
  48403. getComponentIds(): string[];
  48404. /**
  48405. * Get the first component of specific type
  48406. * @param type type of component to find
  48407. * @return a controller component or null if not found
  48408. */
  48409. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48410. /**
  48411. * Get the main (Select) component of this controller as defined in the layout
  48412. * @returns the main component of this controller
  48413. */
  48414. getMainComponent(): WebXRControllerComponent;
  48415. /**
  48416. * Loads the model correlating to this controller
  48417. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48418. * @returns A promise fulfilled with the result of the model loading
  48419. */
  48420. loadModel(): Promise<boolean>;
  48421. /**
  48422. * Update this model using the current XRFrame
  48423. * @param xrFrame the current xr frame to use and update the model
  48424. */
  48425. updateFromXRFrame(xrFrame: XRFrame): void;
  48426. /**
  48427. * Backwards compatibility due to a deeply-integrated typo
  48428. */
  48429. get handness(): XREye;
  48430. /**
  48431. * Pulse (vibrate) this controller
  48432. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48433. * Consecutive calls to this function will cancel the last pulse call
  48434. *
  48435. * @param value the strength of the pulse in 0.0...1.0 range
  48436. * @param duration Duration of the pulse in milliseconds
  48437. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48438. * @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
  48439. */
  48440. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48441. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48442. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48443. /**
  48444. * Moves the axis on the controller mesh based on its current state
  48445. * @param axis the index of the axis
  48446. * @param axisValue the value of the axis which determines the meshes new position
  48447. * @hidden
  48448. */
  48449. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48450. /**
  48451. * Update the model itself with the current frame data
  48452. * @param xrFrame the frame to use for updating the model mesh
  48453. */
  48454. protected updateModel(xrFrame: XRFrame): void;
  48455. /**
  48456. * Get the filename and path for this controller's model
  48457. * @returns a map of filename and path
  48458. */
  48459. protected abstract _getFilenameAndPath(): {
  48460. filename: string;
  48461. path: string;
  48462. };
  48463. /**
  48464. * This function is called before the mesh is loaded. It checks for loading constraints.
  48465. * For example, this function can check if the GLB loader is available
  48466. * If this function returns false, the generic controller will be loaded instead
  48467. * @returns Is the client ready to load the mesh
  48468. */
  48469. protected abstract _getModelLoadingConstraints(): boolean;
  48470. /**
  48471. * This function will be called after the model was successfully loaded and can be used
  48472. * for mesh transformations before it is available for the user
  48473. * @param meshes the loaded meshes
  48474. */
  48475. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48476. /**
  48477. * Set the root mesh for this controller. Important for the WebXR controller class
  48478. * @param meshes the loaded meshes
  48479. */
  48480. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48481. /**
  48482. * A function executed each frame that updates the mesh (if needed)
  48483. * @param xrFrame the current xrFrame
  48484. */
  48485. protected abstract _updateModel(xrFrame: XRFrame): void;
  48486. private _getGenericFilenameAndPath;
  48487. private _getGenericParentMesh;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * A generic trigger-only motion controller for WebXR
  48493. */
  48494. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48495. /**
  48496. * Static version of the profile id of this controller
  48497. */
  48498. static ProfileId: string;
  48499. profileId: string;
  48500. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48501. protected _getFilenameAndPath(): {
  48502. filename: string;
  48503. path: string;
  48504. };
  48505. protected _getModelLoadingConstraints(): boolean;
  48506. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48507. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48508. protected _updateModel(): void;
  48509. }
  48510. }
  48511. declare module BABYLON {
  48512. /**
  48513. * Class containing static functions to help procedurally build meshes
  48514. */
  48515. export class SphereBuilder {
  48516. /**
  48517. * Creates a sphere mesh
  48518. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48519. * * 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`)
  48520. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48521. * * 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
  48522. * * 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)
  48523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48524. * * 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
  48525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48526. * @param name defines the name of the mesh
  48527. * @param options defines the options used to create the mesh
  48528. * @param scene defines the hosting scene
  48529. * @returns the sphere mesh
  48530. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48531. */
  48532. static CreateSphere(name: string, options: {
  48533. segments?: number;
  48534. diameter?: number;
  48535. diameterX?: number;
  48536. diameterY?: number;
  48537. diameterZ?: number;
  48538. arc?: number;
  48539. slice?: number;
  48540. sideOrientation?: number;
  48541. frontUVs?: Vector4;
  48542. backUVs?: Vector4;
  48543. updatable?: boolean;
  48544. }, scene?: Nullable<Scene>): Mesh;
  48545. }
  48546. }
  48547. declare module BABYLON {
  48548. /**
  48549. * A profiled motion controller has its profile loaded from an online repository.
  48550. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48551. */
  48552. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48553. private _repositoryUrl;
  48554. private _buttonMeshMapping;
  48555. private _touchDots;
  48556. /**
  48557. * The profile ID of this controller. Will be populated when the controller initializes.
  48558. */
  48559. profileId: string;
  48560. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48561. dispose(): void;
  48562. protected _getFilenameAndPath(): {
  48563. filename: string;
  48564. path: string;
  48565. };
  48566. protected _getModelLoadingConstraints(): boolean;
  48567. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48568. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48569. protected _updateModel(_xrFrame: XRFrame): void;
  48570. }
  48571. }
  48572. declare module BABYLON {
  48573. /**
  48574. * A construction function type to create a new controller based on an xrInput object
  48575. */
  48576. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48577. /**
  48578. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48579. *
  48580. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48581. * it should be replaced with auto-loaded controllers.
  48582. *
  48583. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48584. */
  48585. export class WebXRMotionControllerManager {
  48586. private static _AvailableControllers;
  48587. private static _Fallbacks;
  48588. private static _ProfileLoadingPromises;
  48589. private static _ProfilesList;
  48590. /**
  48591. * The base URL of the online controller repository. Can be changed at any time.
  48592. */
  48593. static BaseRepositoryUrl: string;
  48594. /**
  48595. * Which repository gets priority - local or online
  48596. */
  48597. static PrioritizeOnlineRepository: boolean;
  48598. /**
  48599. * Use the online repository, or use only locally-defined controllers
  48600. */
  48601. static UseOnlineRepository: boolean;
  48602. /**
  48603. * Clear the cache used for profile loading and reload when requested again
  48604. */
  48605. static ClearProfilesCache(): void;
  48606. /**
  48607. * Register the default fallbacks.
  48608. * This function is called automatically when this file is imported.
  48609. */
  48610. static DefaultFallbacks(): void;
  48611. /**
  48612. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48613. * @param profileId the profile to which a fallback needs to be found
  48614. * @return an array with corresponding fallback profiles
  48615. */
  48616. static FindFallbackWithProfileId(profileId: string): string[];
  48617. /**
  48618. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48619. * The order of search:
  48620. *
  48621. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48622. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48623. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48624. * 4) return the generic trigger controller if none were found
  48625. *
  48626. * @param xrInput the xrInput to which a new controller is initialized
  48627. * @param scene the scene to which the model will be added
  48628. * @param forceProfile force a certain profile for this controller
  48629. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48630. */
  48631. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48632. /**
  48633. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48634. *
  48635. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48636. *
  48637. * @param type the profile type to register
  48638. * @param constructFunction the function to be called when loading this profile
  48639. */
  48640. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48641. /**
  48642. * Register a fallback to a specific profile.
  48643. * @param profileId the profileId that will receive the fallbacks
  48644. * @param fallbacks A list of fallback profiles
  48645. */
  48646. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48647. /**
  48648. * Will update the list of profiles available in the repository
  48649. * @return a promise that resolves to a map of profiles available online
  48650. */
  48651. static UpdateProfilesList(): Promise<{
  48652. [profile: string]: string;
  48653. }>;
  48654. private static _LoadProfileFromRepository;
  48655. private static _LoadProfilesFromAvailableControllers;
  48656. }
  48657. }
  48658. declare module BABYLON {
  48659. /**
  48660. * Configuration options for the WebXR controller creation
  48661. */
  48662. export interface IWebXRControllerOptions {
  48663. /**
  48664. * Should the controller mesh be animated when a user interacts with it
  48665. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48666. */
  48667. disableMotionControllerAnimation?: boolean;
  48668. /**
  48669. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48670. */
  48671. doNotLoadControllerMesh?: boolean;
  48672. /**
  48673. * Force a specific controller type for this controller.
  48674. * This can be used when creating your own profile or when testing different controllers
  48675. */
  48676. forceControllerProfile?: string;
  48677. /**
  48678. * Defines a rendering group ID for meshes that will be loaded.
  48679. * This is for the default controllers only.
  48680. */
  48681. renderingGroupId?: number;
  48682. }
  48683. /**
  48684. * Represents an XR controller
  48685. */
  48686. export class WebXRInputSource {
  48687. private _scene;
  48688. /** The underlying input source for the controller */
  48689. inputSource: XRInputSource;
  48690. private _options;
  48691. private _tmpVector;
  48692. private _uniqueId;
  48693. private _disposed;
  48694. /**
  48695. * 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
  48696. */
  48697. grip?: AbstractMesh;
  48698. /**
  48699. * If available, this is the gamepad object related to this controller.
  48700. * Using this object it is possible to get click events and trackpad changes of the
  48701. * webxr controller that is currently being used.
  48702. */
  48703. motionController?: WebXRAbstractMotionController;
  48704. /**
  48705. * Event that fires when the controller is removed/disposed.
  48706. * The object provided as event data is this controller, after associated assets were disposed.
  48707. * uniqueId is still available.
  48708. */
  48709. onDisposeObservable: Observable<WebXRInputSource>;
  48710. /**
  48711. * Will be triggered when the mesh associated with the motion controller is done loading.
  48712. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48713. * A shortened version of controller -> motion controller -> on mesh loaded.
  48714. */
  48715. onMeshLoadedObservable: Observable<AbstractMesh>;
  48716. /**
  48717. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48718. */
  48719. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48720. /**
  48721. * Pointer which can be used to select objects or attach a visible laser to
  48722. */
  48723. pointer: AbstractMesh;
  48724. /**
  48725. * Creates the input source object
  48726. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48727. * @param _scene the scene which the controller should be associated to
  48728. * @param inputSource the underlying input source for the controller
  48729. * @param _options options for this controller creation
  48730. */
  48731. constructor(_scene: Scene,
  48732. /** The underlying input source for the controller */
  48733. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48734. /**
  48735. * Get this controllers unique id
  48736. */
  48737. get uniqueId(): string;
  48738. /**
  48739. * Disposes of the object
  48740. */
  48741. dispose(): void;
  48742. /**
  48743. * Gets a world space ray coming from the pointer or grip
  48744. * @param result the resulting ray
  48745. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48746. */
  48747. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48748. /**
  48749. * Updates the controller pose based on the given XRFrame
  48750. * @param xrFrame xr frame to update the pose with
  48751. * @param referenceSpace reference space to use
  48752. */
  48753. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48754. }
  48755. }
  48756. declare module BABYLON {
  48757. /**
  48758. * The schema for initialization options of the XR Input class
  48759. */
  48760. export interface IWebXRInputOptions {
  48761. /**
  48762. * If set to true no model will be automatically loaded
  48763. */
  48764. doNotLoadControllerMeshes?: boolean;
  48765. /**
  48766. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48767. * If not found, the xr input profile data will be used.
  48768. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48769. */
  48770. forceInputProfile?: string;
  48771. /**
  48772. * Do not send a request to the controller repository to load the profile.
  48773. *
  48774. * Instead, use the controllers available in babylon itself.
  48775. */
  48776. disableOnlineControllerRepository?: boolean;
  48777. /**
  48778. * A custom URL for the controllers repository
  48779. */
  48780. customControllersRepositoryURL?: string;
  48781. /**
  48782. * Should the controller model's components not move according to the user input
  48783. */
  48784. disableControllerAnimation?: boolean;
  48785. /**
  48786. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48787. */
  48788. controllerOptions?: IWebXRControllerOptions;
  48789. }
  48790. /**
  48791. * XR input used to track XR inputs such as controllers/rays
  48792. */
  48793. export class WebXRInput implements IDisposable {
  48794. /**
  48795. * the xr session manager for this session
  48796. */
  48797. xrSessionManager: WebXRSessionManager;
  48798. /**
  48799. * the WebXR camera for this session. Mainly used for teleportation
  48800. */
  48801. xrCamera: WebXRCamera;
  48802. private readonly options;
  48803. /**
  48804. * XR controllers being tracked
  48805. */
  48806. controllers: Array<WebXRInputSource>;
  48807. private _frameObserver;
  48808. private _sessionEndedObserver;
  48809. private _sessionInitObserver;
  48810. /**
  48811. * Event when a controller has been connected/added
  48812. */
  48813. onControllerAddedObservable: Observable<WebXRInputSource>;
  48814. /**
  48815. * Event when a controller has been removed/disconnected
  48816. */
  48817. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48818. /**
  48819. * Initializes the WebXRInput
  48820. * @param xrSessionManager the xr session manager for this session
  48821. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48822. * @param options = initialization options for this xr input
  48823. */
  48824. constructor(
  48825. /**
  48826. * the xr session manager for this session
  48827. */
  48828. xrSessionManager: WebXRSessionManager,
  48829. /**
  48830. * the WebXR camera for this session. Mainly used for teleportation
  48831. */
  48832. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48833. private _onInputSourcesChange;
  48834. private _addAndRemoveControllers;
  48835. /**
  48836. * Disposes of the object
  48837. */
  48838. dispose(): void;
  48839. }
  48840. }
  48841. declare module BABYLON {
  48842. /**
  48843. * This is the base class for all WebXR features.
  48844. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48845. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48846. */
  48847. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48848. protected _xrSessionManager: WebXRSessionManager;
  48849. private _attached;
  48850. private _removeOnDetach;
  48851. /**
  48852. * Is this feature disposed?
  48853. */
  48854. isDisposed: boolean;
  48855. /**
  48856. * Should auto-attach be disabled?
  48857. */
  48858. disableAutoAttach: boolean;
  48859. /**
  48860. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48861. */
  48862. xrNativeFeatureName: string;
  48863. /**
  48864. * Construct a new (abstract) WebXR feature
  48865. * @param _xrSessionManager the xr session manager for this feature
  48866. */
  48867. constructor(_xrSessionManager: WebXRSessionManager);
  48868. /**
  48869. * Is this feature attached
  48870. */
  48871. get attached(): boolean;
  48872. /**
  48873. * attach this feature
  48874. *
  48875. * @param force should attachment be forced (even when already attached)
  48876. * @returns true if successful, false is failed or already attached
  48877. */
  48878. attach(force?: boolean): boolean;
  48879. /**
  48880. * detach this feature.
  48881. *
  48882. * @returns true if successful, false if failed or already detached
  48883. */
  48884. detach(): boolean;
  48885. /**
  48886. * Dispose this feature and all of the resources attached
  48887. */
  48888. dispose(): void;
  48889. /**
  48890. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48891. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48892. *
  48893. * @returns whether or not the feature is compatible in this environment
  48894. */
  48895. isCompatible(): boolean;
  48896. /**
  48897. * This is used to register callbacks that will automatically be removed when detach is called.
  48898. * @param observable the observable to which the observer will be attached
  48899. * @param callback the callback to register
  48900. */
  48901. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48902. /**
  48903. * Code in this function will be executed on each xrFrame received from the browser.
  48904. * This function will not execute after the feature is detached.
  48905. * @param _xrFrame the current frame
  48906. */
  48907. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48908. }
  48909. }
  48910. declare module BABYLON {
  48911. /**
  48912. * Renders a layer on top of an existing scene
  48913. */
  48914. export class UtilityLayerRenderer implements IDisposable {
  48915. /** the original scene that will be rendered on top of */
  48916. originalScene: Scene;
  48917. private _pointerCaptures;
  48918. private _lastPointerEvents;
  48919. private static _DefaultUtilityLayer;
  48920. private static _DefaultKeepDepthUtilityLayer;
  48921. private _sharedGizmoLight;
  48922. private _renderCamera;
  48923. /**
  48924. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48925. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48926. * @returns the camera that is used when rendering the utility layer
  48927. */
  48928. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48929. /**
  48930. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48931. * @param cam the camera that should be used when rendering the utility layer
  48932. */
  48933. setRenderCamera(cam: Nullable<Camera>): void;
  48934. /**
  48935. * @hidden
  48936. * Light which used by gizmos to get light shading
  48937. */
  48938. _getSharedGizmoLight(): HemisphericLight;
  48939. /**
  48940. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48941. */
  48942. pickUtilitySceneFirst: boolean;
  48943. /**
  48944. * 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)
  48945. */
  48946. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48947. /**
  48948. * 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)
  48949. */
  48950. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48951. /**
  48952. * The scene that is rendered on top of the original scene
  48953. */
  48954. utilityLayerScene: Scene;
  48955. /**
  48956. * If the utility layer should automatically be rendered on top of existing scene
  48957. */
  48958. shouldRender: boolean;
  48959. /**
  48960. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48961. */
  48962. onlyCheckPointerDownEvents: boolean;
  48963. /**
  48964. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48965. */
  48966. processAllEvents: boolean;
  48967. /**
  48968. * Observable raised when the pointer move from the utility layer scene to the main scene
  48969. */
  48970. onPointerOutObservable: Observable<number>;
  48971. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48972. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48973. private _afterRenderObserver;
  48974. private _sceneDisposeObserver;
  48975. private _originalPointerObserver;
  48976. /**
  48977. * Instantiates a UtilityLayerRenderer
  48978. * @param originalScene the original scene that will be rendered on top of
  48979. * @param handleEvents boolean indicating if the utility layer should handle events
  48980. */
  48981. constructor(
  48982. /** the original scene that will be rendered on top of */
  48983. originalScene: Scene, handleEvents?: boolean);
  48984. private _notifyObservers;
  48985. /**
  48986. * Renders the utility layers scene on top of the original scene
  48987. */
  48988. render(): void;
  48989. /**
  48990. * Disposes of the renderer
  48991. */
  48992. dispose(): void;
  48993. private _updateCamera;
  48994. }
  48995. }
  48996. declare module BABYLON {
  48997. /**
  48998. * Options interface for the pointer selection module
  48999. */
  49000. export interface IWebXRControllerPointerSelectionOptions {
  49001. /**
  49002. * if provided, this scene will be used to render meshes.
  49003. */
  49004. customUtilityLayerScene?: Scene;
  49005. /**
  49006. * 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)
  49007. * If not disabled, the last picked point will be used to execute a pointer up event
  49008. * If disabled, pointer up event will be triggered right after the pointer down event.
  49009. * Used in screen and gaze target ray mode only
  49010. */
  49011. disablePointerUpOnTouchOut: boolean;
  49012. /**
  49013. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  49014. */
  49015. forceGazeMode: boolean;
  49016. /**
  49017. * 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
  49018. * to start a new countdown to the pointer down event.
  49019. * Defaults to 1.
  49020. */
  49021. gazeModePointerMovedFactor?: number;
  49022. /**
  49023. * Different button type to use instead of the main component
  49024. */
  49025. overrideButtonId?: string;
  49026. /**
  49027. * use this rendering group id for the meshes (optional)
  49028. */
  49029. renderingGroupId?: number;
  49030. /**
  49031. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49032. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49033. * 3000 means 3 seconds between pointing at something and selecting it
  49034. */
  49035. timeToSelect?: number;
  49036. /**
  49037. * Should meshes created here be added to a utility layer or the main scene
  49038. */
  49039. useUtilityLayer?: boolean;
  49040. /**
  49041. * Optional WebXR camera to be used for gaze selection
  49042. */
  49043. gazeCamera?: WebXRCamera;
  49044. /**
  49045. * the xr input to use with this pointer selection
  49046. */
  49047. xrInput: WebXRInput;
  49048. }
  49049. /**
  49050. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49051. */
  49052. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49053. private readonly _options;
  49054. private static _idCounter;
  49055. private _attachController;
  49056. private _controllers;
  49057. private _scene;
  49058. private _tmpVectorForPickCompare;
  49059. /**
  49060. * The module's name
  49061. */
  49062. static readonly Name: string;
  49063. /**
  49064. * The (Babylon) version of this module.
  49065. * This is an integer representing the implementation version.
  49066. * This number does not correspond to the WebXR specs version
  49067. */
  49068. static readonly Version: number;
  49069. /**
  49070. * Disable lighting on the laser pointer (so it will always be visible)
  49071. */
  49072. disablePointerLighting: boolean;
  49073. /**
  49074. * Disable lighting on the selection mesh (so it will always be visible)
  49075. */
  49076. disableSelectionMeshLighting: boolean;
  49077. /**
  49078. * Should the laser pointer be displayed
  49079. */
  49080. displayLaserPointer: boolean;
  49081. /**
  49082. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49083. */
  49084. displaySelectionMesh: boolean;
  49085. /**
  49086. * This color will be set to the laser pointer when selection is triggered
  49087. */
  49088. laserPointerPickedColor: Color3;
  49089. /**
  49090. * Default color of the laser pointer
  49091. */
  49092. laserPointerDefaultColor: Color3;
  49093. /**
  49094. * default color of the selection ring
  49095. */
  49096. selectionMeshDefaultColor: Color3;
  49097. /**
  49098. * This color will be applied to the selection ring when selection is triggered
  49099. */
  49100. selectionMeshPickedColor: Color3;
  49101. /**
  49102. * Optional filter to be used for ray selection. This predicate shares behavior with
  49103. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49104. */
  49105. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49106. /**
  49107. * constructs a new background remover module
  49108. * @param _xrSessionManager the session manager for this module
  49109. * @param _options read-only options to be used in this module
  49110. */
  49111. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49112. /**
  49113. * attach this feature
  49114. * Will usually be called by the features manager
  49115. *
  49116. * @returns true if successful.
  49117. */
  49118. attach(): boolean;
  49119. /**
  49120. * detach this feature.
  49121. * Will usually be called by the features manager
  49122. *
  49123. * @returns true if successful.
  49124. */
  49125. detach(): boolean;
  49126. /**
  49127. * Will get the mesh under a specific pointer.
  49128. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49129. * @param controllerId the controllerId to check
  49130. * @returns The mesh under pointer or null if no mesh is under the pointer
  49131. */
  49132. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49133. /**
  49134. * Get the xr controller that correlates to the pointer id in the pointer event
  49135. *
  49136. * @param id the pointer id to search for
  49137. * @returns the controller that correlates to this id or null if not found
  49138. */
  49139. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49140. protected _onXRFrame(_xrFrame: XRFrame): void;
  49141. private _attachGazeMode;
  49142. private _attachScreenRayMode;
  49143. private _attachTrackedPointerRayMode;
  49144. private _convertNormalToDirectionOfRay;
  49145. private _detachController;
  49146. private _generateNewMeshPair;
  49147. private _pickingMoved;
  49148. private _updatePointerDistance;
  49149. /** @hidden */
  49150. get lasterPointerDefaultColor(): Color3;
  49151. }
  49152. }
  49153. declare module BABYLON {
  49154. /**
  49155. * Button which can be used to enter a different mode of XR
  49156. */
  49157. export class WebXREnterExitUIButton {
  49158. /** button element */
  49159. element: HTMLElement;
  49160. /** XR initialization options for the button */
  49161. sessionMode: XRSessionMode;
  49162. /** Reference space type */
  49163. referenceSpaceType: XRReferenceSpaceType;
  49164. /**
  49165. * Creates a WebXREnterExitUIButton
  49166. * @param element button element
  49167. * @param sessionMode XR initialization session mode
  49168. * @param referenceSpaceType the type of reference space to be used
  49169. */
  49170. constructor(
  49171. /** button element */
  49172. element: HTMLElement,
  49173. /** XR initialization options for the button */
  49174. sessionMode: XRSessionMode,
  49175. /** Reference space type */
  49176. referenceSpaceType: XRReferenceSpaceType);
  49177. /**
  49178. * Extendable function which can be used to update the button's visuals when the state changes
  49179. * @param activeButton the current active button in the UI
  49180. */
  49181. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49182. }
  49183. /**
  49184. * Options to create the webXR UI
  49185. */
  49186. export class WebXREnterExitUIOptions {
  49187. /**
  49188. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49189. */
  49190. customButtons?: Array<WebXREnterExitUIButton>;
  49191. /**
  49192. * A reference space type to use when creating the default button.
  49193. * Default is local-floor
  49194. */
  49195. referenceSpaceType?: XRReferenceSpaceType;
  49196. /**
  49197. * Context to enter xr with
  49198. */
  49199. renderTarget?: Nullable<WebXRRenderTarget>;
  49200. /**
  49201. * A session mode to use when creating the default button.
  49202. * Default is immersive-vr
  49203. */
  49204. sessionMode?: XRSessionMode;
  49205. /**
  49206. * A list of optional features to init the session with
  49207. */
  49208. optionalFeatures?: string[];
  49209. /**
  49210. * A list of optional features to init the session with
  49211. */
  49212. requiredFeatures?: string[];
  49213. }
  49214. /**
  49215. * UI to allow the user to enter/exit XR mode
  49216. */
  49217. export class WebXREnterExitUI implements IDisposable {
  49218. private scene;
  49219. /** version of the options passed to this UI */
  49220. options: WebXREnterExitUIOptions;
  49221. private _activeButton;
  49222. private _buttons;
  49223. /**
  49224. * The HTML Div Element to which buttons are added.
  49225. */
  49226. readonly overlay: HTMLDivElement;
  49227. /**
  49228. * Fired every time the active button is changed.
  49229. *
  49230. * When xr is entered via a button that launches xr that button will be the callback parameter
  49231. *
  49232. * When exiting xr the callback parameter will be null)
  49233. */
  49234. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49235. /**
  49236. *
  49237. * @param scene babylon scene object to use
  49238. * @param options (read-only) version of the options passed to this UI
  49239. */
  49240. private constructor();
  49241. /**
  49242. * Creates UI to allow the user to enter/exit XR mode
  49243. * @param scene the scene to add the ui to
  49244. * @param helper the xr experience helper to enter/exit xr with
  49245. * @param options options to configure the UI
  49246. * @returns the created ui
  49247. */
  49248. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49249. /**
  49250. * Disposes of the XR UI component
  49251. */
  49252. dispose(): void;
  49253. private _updateButtons;
  49254. }
  49255. }
  49256. declare module BABYLON {
  49257. /**
  49258. * Class containing static functions to help procedurally build meshes
  49259. */
  49260. export class LinesBuilder {
  49261. /**
  49262. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49263. * * 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
  49264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49265. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49266. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49267. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49268. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49269. * * 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
  49270. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49273. * @param name defines the name of the new line system
  49274. * @param options defines the options used to create the line system
  49275. * @param scene defines the hosting scene
  49276. * @returns a new line system mesh
  49277. */
  49278. static CreateLineSystem(name: string, options: {
  49279. lines: Vector3[][];
  49280. updatable?: boolean;
  49281. instance?: Nullable<LinesMesh>;
  49282. colors?: Nullable<Color4[][]>;
  49283. useVertexAlpha?: boolean;
  49284. }, scene: Nullable<Scene>): LinesMesh;
  49285. /**
  49286. * Creates a line mesh
  49287. * 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
  49288. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49289. * * The parameter `points` is an array successive Vector3
  49290. * * 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
  49291. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49292. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49293. * * When updating an instance, remember that only point positions can change, not the number of points
  49294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49296. * @param name defines the name of the new line system
  49297. * @param options defines the options used to create the line system
  49298. * @param scene defines the hosting scene
  49299. * @returns a new line mesh
  49300. */
  49301. static CreateLines(name: string, options: {
  49302. points: Vector3[];
  49303. updatable?: boolean;
  49304. instance?: Nullable<LinesMesh>;
  49305. colors?: Color4[];
  49306. useVertexAlpha?: boolean;
  49307. }, scene?: Nullable<Scene>): LinesMesh;
  49308. /**
  49309. * Creates a dashed line mesh
  49310. * * 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
  49311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49312. * * The parameter `points` is an array successive Vector3
  49313. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49314. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49315. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49316. * * 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
  49317. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49318. * * When updating an instance, remember that only point positions can change, not the number of points
  49319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49320. * @param name defines the name of the mesh
  49321. * @param options defines the options used to create the mesh
  49322. * @param scene defines the hosting scene
  49323. * @returns the dashed line mesh
  49324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49325. */
  49326. static CreateDashedLines(name: string, options: {
  49327. points: Vector3[];
  49328. dashSize?: number;
  49329. gapSize?: number;
  49330. dashNb?: number;
  49331. updatable?: boolean;
  49332. instance?: LinesMesh;
  49333. useVertexAlpha?: boolean;
  49334. }, scene?: Nullable<Scene>): LinesMesh;
  49335. }
  49336. }
  49337. declare module BABYLON {
  49338. /**
  49339. * Construction options for a timer
  49340. */
  49341. export interface ITimerOptions<T> {
  49342. /**
  49343. * Time-to-end
  49344. */
  49345. timeout: number;
  49346. /**
  49347. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49348. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49349. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49350. */
  49351. contextObservable: Observable<T>;
  49352. /**
  49353. * Optional parameters when adding an observer to the observable
  49354. */
  49355. observableParameters?: {
  49356. mask?: number;
  49357. insertFirst?: boolean;
  49358. scope?: any;
  49359. };
  49360. /**
  49361. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49362. */
  49363. breakCondition?: (data?: ITimerData<T>) => boolean;
  49364. /**
  49365. * Will be triggered when the time condition has met
  49366. */
  49367. onEnded?: (data: ITimerData<any>) => void;
  49368. /**
  49369. * Will be triggered when the break condition has met (prematurely ended)
  49370. */
  49371. onAborted?: (data: ITimerData<any>) => void;
  49372. /**
  49373. * Optional function to execute on each tick (or count)
  49374. */
  49375. onTick?: (data: ITimerData<any>) => void;
  49376. }
  49377. /**
  49378. * An interface defining the data sent by the timer
  49379. */
  49380. export interface ITimerData<T> {
  49381. /**
  49382. * When did it start
  49383. */
  49384. startTime: number;
  49385. /**
  49386. * Time now
  49387. */
  49388. currentTime: number;
  49389. /**
  49390. * Time passed since started
  49391. */
  49392. deltaTime: number;
  49393. /**
  49394. * How much is completed, in [0.0...1.0].
  49395. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49396. */
  49397. completeRate: number;
  49398. /**
  49399. * What the registered observable sent in the last count
  49400. */
  49401. payload: T;
  49402. }
  49403. /**
  49404. * The current state of the timer
  49405. */
  49406. export enum TimerState {
  49407. /**
  49408. * Timer initialized, not yet started
  49409. */
  49410. INIT = 0,
  49411. /**
  49412. * Timer started and counting
  49413. */
  49414. STARTED = 1,
  49415. /**
  49416. * Timer ended (whether aborted or time reached)
  49417. */
  49418. ENDED = 2
  49419. }
  49420. /**
  49421. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49422. *
  49423. * @param options options with which to initialize this timer
  49424. */
  49425. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49426. /**
  49427. * An advanced implementation of a timer class
  49428. */
  49429. export class AdvancedTimer<T = any> implements IDisposable {
  49430. /**
  49431. * Will notify each time the timer calculates the remaining time
  49432. */
  49433. onEachCountObservable: Observable<ITimerData<T>>;
  49434. /**
  49435. * Will trigger when the timer was aborted due to the break condition
  49436. */
  49437. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49438. /**
  49439. * Will trigger when the timer ended successfully
  49440. */
  49441. onTimerEndedObservable: Observable<ITimerData<T>>;
  49442. /**
  49443. * Will trigger when the timer state has changed
  49444. */
  49445. onStateChangedObservable: Observable<TimerState>;
  49446. private _observer;
  49447. private _contextObservable;
  49448. private _observableParameters;
  49449. private _startTime;
  49450. private _timer;
  49451. private _state;
  49452. private _breakCondition;
  49453. private _timeToEnd;
  49454. private _breakOnNextTick;
  49455. /**
  49456. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49457. * @param options construction options for this advanced timer
  49458. */
  49459. constructor(options: ITimerOptions<T>);
  49460. /**
  49461. * set a breaking condition for this timer. Default is to never break during count
  49462. * @param predicate the new break condition. Returns true to break, false otherwise
  49463. */
  49464. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49465. /**
  49466. * Reset ALL associated observables in this advanced timer
  49467. */
  49468. clearObservables(): void;
  49469. /**
  49470. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49471. *
  49472. * @param timeToEnd how much time to measure until timer ended
  49473. */
  49474. start(timeToEnd?: number): void;
  49475. /**
  49476. * Will force a stop on the next tick.
  49477. */
  49478. stop(): void;
  49479. /**
  49480. * Dispose this timer, clearing all resources
  49481. */
  49482. dispose(): void;
  49483. private _setState;
  49484. private _tick;
  49485. private _stop;
  49486. }
  49487. }
  49488. declare module BABYLON {
  49489. /**
  49490. * The options container for the teleportation module
  49491. */
  49492. export interface IWebXRTeleportationOptions {
  49493. /**
  49494. * if provided, this scene will be used to render meshes.
  49495. */
  49496. customUtilityLayerScene?: Scene;
  49497. /**
  49498. * Values to configure the default target mesh
  49499. */
  49500. defaultTargetMeshOptions?: {
  49501. /**
  49502. * Fill color of the teleportation area
  49503. */
  49504. teleportationFillColor?: string;
  49505. /**
  49506. * Border color for the teleportation area
  49507. */
  49508. teleportationBorderColor?: string;
  49509. /**
  49510. * Disable the mesh's animation sequence
  49511. */
  49512. disableAnimation?: boolean;
  49513. /**
  49514. * Disable lighting on the material or the ring and arrow
  49515. */
  49516. disableLighting?: boolean;
  49517. /**
  49518. * Override the default material of the torus and arrow
  49519. */
  49520. torusArrowMaterial?: Material;
  49521. };
  49522. /**
  49523. * A list of meshes to use as floor meshes.
  49524. * Meshes can be added and removed after initializing the feature using the
  49525. * addFloorMesh and removeFloorMesh functions
  49526. * If empty, rotation will still work
  49527. */
  49528. floorMeshes?: AbstractMesh[];
  49529. /**
  49530. * use this rendering group id for the meshes (optional)
  49531. */
  49532. renderingGroupId?: number;
  49533. /**
  49534. * Should teleportation move only to snap points
  49535. */
  49536. snapPointsOnly?: boolean;
  49537. /**
  49538. * An array of points to which the teleportation will snap to.
  49539. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49540. */
  49541. snapPositions?: Vector3[];
  49542. /**
  49543. * How close should the teleportation ray be in order to snap to position.
  49544. * Default to 0.8 units (meters)
  49545. */
  49546. snapToPositionRadius?: number;
  49547. /**
  49548. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49549. * If you want to support rotation, make sure your mesh has a direction indicator.
  49550. *
  49551. * When left untouched, the default mesh will be initialized.
  49552. */
  49553. teleportationTargetMesh?: AbstractMesh;
  49554. /**
  49555. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49556. */
  49557. timeToTeleport?: number;
  49558. /**
  49559. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49560. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49561. */
  49562. useMainComponentOnly?: boolean;
  49563. /**
  49564. * Should meshes created here be added to a utility layer or the main scene
  49565. */
  49566. useUtilityLayer?: boolean;
  49567. /**
  49568. * Babylon XR Input class for controller
  49569. */
  49570. xrInput: WebXRInput;
  49571. /**
  49572. * Meshes that the teleportation ray cannot go through
  49573. */
  49574. pickBlockerMeshes?: AbstractMesh[];
  49575. }
  49576. /**
  49577. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49578. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49579. * the input of the attached controllers.
  49580. */
  49581. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49582. private _options;
  49583. private _controllers;
  49584. private _currentTeleportationControllerId;
  49585. private _floorMeshes;
  49586. private _quadraticBezierCurve;
  49587. private _selectionFeature;
  49588. private _snapToPositions;
  49589. private _snappedToPoint;
  49590. private _teleportationRingMaterial?;
  49591. private _tmpRay;
  49592. private _tmpVector;
  49593. private _tmpQuaternion;
  49594. /**
  49595. * The module's name
  49596. */
  49597. static readonly Name: string;
  49598. /**
  49599. * The (Babylon) version of this module.
  49600. * This is an integer representing the implementation version.
  49601. * This number does not correspond to the webxr specs version
  49602. */
  49603. static readonly Version: number;
  49604. /**
  49605. * Is movement backwards enabled
  49606. */
  49607. backwardsMovementEnabled: boolean;
  49608. /**
  49609. * Distance to travel when moving backwards
  49610. */
  49611. backwardsTeleportationDistance: number;
  49612. /**
  49613. * The distance from the user to the inspection point in the direction of the controller
  49614. * A higher number will allow the user to move further
  49615. * defaults to 5 (meters, in xr units)
  49616. */
  49617. parabolicCheckRadius: number;
  49618. /**
  49619. * Should the module support parabolic ray on top of direct ray
  49620. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49621. * Very helpful when moving between floors / different heights
  49622. */
  49623. parabolicRayEnabled: boolean;
  49624. /**
  49625. * How much rotation should be applied when rotating right and left
  49626. */
  49627. rotationAngle: number;
  49628. /**
  49629. * Is rotation enabled when moving forward?
  49630. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49631. */
  49632. rotationEnabled: boolean;
  49633. /**
  49634. * constructs a new anchor system
  49635. * @param _xrSessionManager an instance of WebXRSessionManager
  49636. * @param _options configuration object for this feature
  49637. */
  49638. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49639. /**
  49640. * Get the snapPointsOnly flag
  49641. */
  49642. get snapPointsOnly(): boolean;
  49643. /**
  49644. * Sets the snapPointsOnly flag
  49645. * @param snapToPoints should teleportation be exclusively to snap points
  49646. */
  49647. set snapPointsOnly(snapToPoints: boolean);
  49648. /**
  49649. * Add a new mesh to the floor meshes array
  49650. * @param mesh the mesh to use as floor mesh
  49651. */
  49652. addFloorMesh(mesh: AbstractMesh): void;
  49653. /**
  49654. * Add a new snap-to point to fix teleportation to this position
  49655. * @param newSnapPoint The new Snap-To point
  49656. */
  49657. addSnapPoint(newSnapPoint: Vector3): void;
  49658. attach(): boolean;
  49659. detach(): boolean;
  49660. dispose(): void;
  49661. /**
  49662. * Remove a mesh from the floor meshes array
  49663. * @param mesh the mesh to remove
  49664. */
  49665. removeFloorMesh(mesh: AbstractMesh): void;
  49666. /**
  49667. * Remove a mesh from the floor meshes array using its name
  49668. * @param name the mesh name to remove
  49669. */
  49670. removeFloorMeshByName(name: string): void;
  49671. /**
  49672. * 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
  49673. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49674. * @returns was the point found and removed or not
  49675. */
  49676. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49677. /**
  49678. * This function sets a selection feature that will be disabled when
  49679. * the forward ray is shown and will be reattached when hidden.
  49680. * This is used to remove the selection rays when moving.
  49681. * @param selectionFeature the feature to disable when forward movement is enabled
  49682. */
  49683. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49684. protected _onXRFrame(_xrFrame: XRFrame): void;
  49685. private _attachController;
  49686. private _createDefaultTargetMesh;
  49687. private _detachController;
  49688. private _findClosestSnapPointWithRadius;
  49689. private _setTargetMeshPosition;
  49690. private _setTargetMeshVisibility;
  49691. private _showParabolicPath;
  49692. private _teleportForward;
  49693. }
  49694. }
  49695. declare module BABYLON {
  49696. /**
  49697. * Options for the default xr helper
  49698. */
  49699. export class WebXRDefaultExperienceOptions {
  49700. /**
  49701. * Enable or disable default UI to enter XR
  49702. */
  49703. disableDefaultUI?: boolean;
  49704. /**
  49705. * Should teleportation not initialize. defaults to false.
  49706. */
  49707. disableTeleportation?: boolean;
  49708. /**
  49709. * Floor meshes that will be used for teleport
  49710. */
  49711. floorMeshes?: Array<AbstractMesh>;
  49712. /**
  49713. * If set to true, the first frame will not be used to reset position
  49714. * The first frame is mainly used when copying transformation from the old camera
  49715. * Mainly used in AR
  49716. */
  49717. ignoreNativeCameraTransformation?: boolean;
  49718. /**
  49719. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49720. */
  49721. inputOptions?: IWebXRInputOptions;
  49722. /**
  49723. * optional configuration for the output canvas
  49724. */
  49725. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49726. /**
  49727. * optional UI options. This can be used among other to change session mode and reference space type
  49728. */
  49729. uiOptions?: WebXREnterExitUIOptions;
  49730. /**
  49731. * When loading teleportation and pointer select, use stable versions instead of latest.
  49732. */
  49733. useStablePlugins?: boolean;
  49734. /**
  49735. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49736. */
  49737. renderingGroupId?: number;
  49738. /**
  49739. * A list of optional features to init the session with
  49740. * If set to true, all features we support will be added
  49741. */
  49742. optionalFeatures?: boolean | string[];
  49743. }
  49744. /**
  49745. * Default experience which provides a similar setup to the previous webVRExperience
  49746. */
  49747. export class WebXRDefaultExperience {
  49748. /**
  49749. * Base experience
  49750. */
  49751. baseExperience: WebXRExperienceHelper;
  49752. /**
  49753. * Enables ui for entering/exiting xr
  49754. */
  49755. enterExitUI: WebXREnterExitUI;
  49756. /**
  49757. * Input experience extension
  49758. */
  49759. input: WebXRInput;
  49760. /**
  49761. * Enables laser pointer and selection
  49762. */
  49763. pointerSelection: WebXRControllerPointerSelection;
  49764. /**
  49765. * Default target xr should render to
  49766. */
  49767. renderTarget: WebXRRenderTarget;
  49768. /**
  49769. * Enables teleportation
  49770. */
  49771. teleportation: WebXRMotionControllerTeleportation;
  49772. private constructor();
  49773. /**
  49774. * Creates the default xr experience
  49775. * @param scene scene
  49776. * @param options options for basic configuration
  49777. * @returns resulting WebXRDefaultExperience
  49778. */
  49779. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49780. /**
  49781. * DIsposes of the experience helper
  49782. */
  49783. dispose(): void;
  49784. }
  49785. }
  49786. declare module BABYLON {
  49787. /**
  49788. * Options to modify the vr teleportation behavior.
  49789. */
  49790. export interface VRTeleportationOptions {
  49791. /**
  49792. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49793. */
  49794. floorMeshName?: string;
  49795. /**
  49796. * A list of meshes to be used as the teleportation floor. (default: empty)
  49797. */
  49798. floorMeshes?: Mesh[];
  49799. /**
  49800. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49801. */
  49802. teleportationMode?: number;
  49803. /**
  49804. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49805. */
  49806. teleportationTime?: number;
  49807. /**
  49808. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49809. */
  49810. teleportationSpeed?: number;
  49811. /**
  49812. * The easing function used in the animation or null for Linear. (default CircleEase)
  49813. */
  49814. easingFunction?: EasingFunction;
  49815. }
  49816. /**
  49817. * Options to modify the vr experience helper's behavior.
  49818. */
  49819. export interface VRExperienceHelperOptions extends WebVROptions {
  49820. /**
  49821. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49822. */
  49823. createDeviceOrientationCamera?: boolean;
  49824. /**
  49825. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49826. */
  49827. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49828. /**
  49829. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49830. */
  49831. laserToggle?: boolean;
  49832. /**
  49833. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49834. */
  49835. floorMeshes?: Mesh[];
  49836. /**
  49837. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49838. */
  49839. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49840. /**
  49841. * Defines if WebXR should be used instead of WebVR (if available)
  49842. */
  49843. useXR?: boolean;
  49844. }
  49845. /**
  49846. * Event containing information after VR has been entered
  49847. */
  49848. export class OnAfterEnteringVRObservableEvent {
  49849. /**
  49850. * If entering vr was successful
  49851. */
  49852. success: boolean;
  49853. }
  49854. /**
  49855. * Helps to quickly add VR support to an existing scene.
  49856. * See https://doc.babylonjs.com/how_to/webvr_helper
  49857. */
  49858. export class VRExperienceHelper {
  49859. /** Options to modify the vr experience helper's behavior. */
  49860. webVROptions: VRExperienceHelperOptions;
  49861. private _scene;
  49862. private _position;
  49863. private _btnVR;
  49864. private _btnVRDisplayed;
  49865. private _webVRsupported;
  49866. private _webVRready;
  49867. private _webVRrequesting;
  49868. private _webVRpresenting;
  49869. private _hasEnteredVR;
  49870. private _fullscreenVRpresenting;
  49871. private _inputElement;
  49872. private _webVRCamera;
  49873. private _vrDeviceOrientationCamera;
  49874. private _deviceOrientationCamera;
  49875. private _existingCamera;
  49876. private _onKeyDown;
  49877. private _onVrDisplayPresentChange;
  49878. private _onVRDisplayChanged;
  49879. private _onVRRequestPresentStart;
  49880. private _onVRRequestPresentComplete;
  49881. /**
  49882. * 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)
  49883. */
  49884. enableGazeEvenWhenNoPointerLock: boolean;
  49885. /**
  49886. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49887. */
  49888. exitVROnDoubleTap: boolean;
  49889. /**
  49890. * Observable raised right before entering VR.
  49891. */
  49892. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49893. /**
  49894. * Observable raised when entering VR has completed.
  49895. */
  49896. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49897. /**
  49898. * Observable raised when exiting VR.
  49899. */
  49900. onExitingVRObservable: Observable<VRExperienceHelper>;
  49901. /**
  49902. * Observable raised when controller mesh is loaded.
  49903. */
  49904. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49905. /** Return this.onEnteringVRObservable
  49906. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49907. */
  49908. get onEnteringVR(): Observable<VRExperienceHelper>;
  49909. /** Return this.onExitingVRObservable
  49910. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49911. */
  49912. get onExitingVR(): Observable<VRExperienceHelper>;
  49913. /** Return this.onControllerMeshLoadedObservable
  49914. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49915. */
  49916. get onControllerMeshLoaded(): Observable<WebVRController>;
  49917. private _rayLength;
  49918. private _useCustomVRButton;
  49919. private _teleportationRequested;
  49920. private _teleportActive;
  49921. private _floorMeshName;
  49922. private _floorMeshesCollection;
  49923. private _teleportationMode;
  49924. private _teleportationTime;
  49925. private _teleportationSpeed;
  49926. private _teleportationEasing;
  49927. private _rotationAllowed;
  49928. private _teleportBackwardsVector;
  49929. private _teleportationTarget;
  49930. private _isDefaultTeleportationTarget;
  49931. private _postProcessMove;
  49932. private _teleportationFillColor;
  49933. private _teleportationBorderColor;
  49934. private _rotationAngle;
  49935. private _haloCenter;
  49936. private _cameraGazer;
  49937. private _padSensibilityUp;
  49938. private _padSensibilityDown;
  49939. private _leftController;
  49940. private _rightController;
  49941. private _gazeColor;
  49942. private _laserColor;
  49943. private _pickedLaserColor;
  49944. private _pickedGazeColor;
  49945. /**
  49946. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49947. */
  49948. onNewMeshSelected: Observable<AbstractMesh>;
  49949. /**
  49950. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49951. * This observable will provide the mesh and the controller used to select the mesh
  49952. */
  49953. onMeshSelectedWithController: Observable<{
  49954. mesh: AbstractMesh;
  49955. controller: WebVRController;
  49956. }>;
  49957. /**
  49958. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49959. */
  49960. onNewMeshPicked: Observable<PickingInfo>;
  49961. private _circleEase;
  49962. /**
  49963. * Observable raised before camera teleportation
  49964. */
  49965. onBeforeCameraTeleport: Observable<Vector3>;
  49966. /**
  49967. * Observable raised after camera teleportation
  49968. */
  49969. onAfterCameraTeleport: Observable<Vector3>;
  49970. /**
  49971. * Observable raised when current selected mesh gets unselected
  49972. */
  49973. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49974. private _raySelectionPredicate;
  49975. /**
  49976. * To be optionaly changed by user to define custom ray selection
  49977. */
  49978. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49979. /**
  49980. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49981. */
  49982. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49983. /**
  49984. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49985. */
  49986. teleportationEnabled: boolean;
  49987. private _defaultHeight;
  49988. private _teleportationInitialized;
  49989. private _interactionsEnabled;
  49990. private _interactionsRequested;
  49991. private _displayGaze;
  49992. private _displayLaserPointer;
  49993. /**
  49994. * The mesh used to display where the user is going to teleport.
  49995. */
  49996. get teleportationTarget(): Mesh;
  49997. /**
  49998. * Sets the mesh to be used to display where the user is going to teleport.
  49999. */
  50000. set teleportationTarget(value: Mesh);
  50001. /**
  50002. * 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
  50003. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50004. * See https://doc.babylonjs.com/resources/baking_transformations
  50005. */
  50006. get gazeTrackerMesh(): Mesh;
  50007. set gazeTrackerMesh(value: Mesh);
  50008. /**
  50009. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50010. */
  50011. updateGazeTrackerScale: boolean;
  50012. /**
  50013. * If the gaze trackers color should be updated when selecting meshes
  50014. */
  50015. updateGazeTrackerColor: boolean;
  50016. /**
  50017. * If the controller laser color should be updated when selecting meshes
  50018. */
  50019. updateControllerLaserColor: boolean;
  50020. /**
  50021. * The gaze tracking mesh corresponding to the left controller
  50022. */
  50023. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50024. /**
  50025. * The gaze tracking mesh corresponding to the right controller
  50026. */
  50027. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50028. /**
  50029. * If the ray of the gaze should be displayed.
  50030. */
  50031. get displayGaze(): boolean;
  50032. /**
  50033. * Sets if the ray of the gaze should be displayed.
  50034. */
  50035. set displayGaze(value: boolean);
  50036. /**
  50037. * If the ray of the LaserPointer should be displayed.
  50038. */
  50039. get displayLaserPointer(): boolean;
  50040. /**
  50041. * Sets if the ray of the LaserPointer should be displayed.
  50042. */
  50043. set displayLaserPointer(value: boolean);
  50044. /**
  50045. * The deviceOrientationCamera used as the camera when not in VR.
  50046. */
  50047. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50048. /**
  50049. * Based on the current WebVR support, returns the current VR camera used.
  50050. */
  50051. get currentVRCamera(): Nullable<Camera>;
  50052. /**
  50053. * The webVRCamera which is used when in VR.
  50054. */
  50055. get webVRCamera(): WebVRFreeCamera;
  50056. /**
  50057. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50058. */
  50059. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50060. /**
  50061. * The html button that is used to trigger entering into VR.
  50062. */
  50063. get vrButton(): Nullable<HTMLButtonElement>;
  50064. private get _teleportationRequestInitiated();
  50065. /**
  50066. * Defines whether or not Pointer lock should be requested when switching to
  50067. * full screen.
  50068. */
  50069. requestPointerLockOnFullScreen: boolean;
  50070. /**
  50071. * If asking to force XR, this will be populated with the default xr experience
  50072. */
  50073. xr: WebXRDefaultExperience;
  50074. /**
  50075. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50076. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50077. */
  50078. xrTestDone: boolean;
  50079. /**
  50080. * Instantiates a VRExperienceHelper.
  50081. * Helps to quickly add VR support to an existing scene.
  50082. * @param scene The scene the VRExperienceHelper belongs to.
  50083. * @param webVROptions Options to modify the vr experience helper's behavior.
  50084. */
  50085. constructor(scene: Scene,
  50086. /** Options to modify the vr experience helper's behavior. */
  50087. webVROptions?: VRExperienceHelperOptions);
  50088. private completeVRInit;
  50089. private _onDefaultMeshLoaded;
  50090. private _onResize;
  50091. private _onFullscreenChange;
  50092. /**
  50093. * Gets a value indicating if we are currently in VR mode.
  50094. */
  50095. get isInVRMode(): boolean;
  50096. private onVrDisplayPresentChange;
  50097. private onVRDisplayChanged;
  50098. private moveButtonToBottomRight;
  50099. private displayVRButton;
  50100. private updateButtonVisibility;
  50101. private _cachedAngularSensibility;
  50102. /**
  50103. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50104. * Otherwise, will use the fullscreen API.
  50105. */
  50106. enterVR(): void;
  50107. /**
  50108. * Attempt to exit VR, or fullscreen.
  50109. */
  50110. exitVR(): void;
  50111. /**
  50112. * The position of the vr experience helper.
  50113. */
  50114. get position(): Vector3;
  50115. /**
  50116. * Sets the position of the vr experience helper.
  50117. */
  50118. set position(value: Vector3);
  50119. /**
  50120. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50121. */
  50122. enableInteractions(): void;
  50123. private get _noControllerIsActive();
  50124. private beforeRender;
  50125. private _isTeleportationFloor;
  50126. /**
  50127. * Adds a floor mesh to be used for teleportation.
  50128. * @param floorMesh the mesh to be used for teleportation.
  50129. */
  50130. addFloorMesh(floorMesh: Mesh): void;
  50131. /**
  50132. * Removes a floor mesh from being used for teleportation.
  50133. * @param floorMesh the mesh to be removed.
  50134. */
  50135. removeFloorMesh(floorMesh: Mesh): void;
  50136. /**
  50137. * Enables interactions and teleportation using the VR controllers and gaze.
  50138. * @param vrTeleportationOptions options to modify teleportation behavior.
  50139. */
  50140. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50141. private _onNewGamepadConnected;
  50142. private _tryEnableInteractionOnController;
  50143. private _onNewGamepadDisconnected;
  50144. private _enableInteractionOnController;
  50145. private _checkTeleportWithRay;
  50146. private _checkRotate;
  50147. private _checkTeleportBackwards;
  50148. private _enableTeleportationOnController;
  50149. private _createTeleportationCircles;
  50150. private _displayTeleportationTarget;
  50151. private _hideTeleportationTarget;
  50152. private _rotateCamera;
  50153. private _moveTeleportationSelectorTo;
  50154. private _workingVector;
  50155. private _workingQuaternion;
  50156. private _workingMatrix;
  50157. /**
  50158. * Time Constant Teleportation Mode
  50159. */
  50160. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50161. /**
  50162. * Speed Constant Teleportation Mode
  50163. */
  50164. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50165. /**
  50166. * Teleports the users feet to the desired location
  50167. * @param location The location where the user's feet should be placed
  50168. */
  50169. teleportCamera(location: Vector3): void;
  50170. private _convertNormalToDirectionOfRay;
  50171. private _castRayAndSelectObject;
  50172. private _notifySelectedMeshUnselected;
  50173. /**
  50174. * Permanently set new colors for the laser pointer
  50175. * @param color the new laser color
  50176. * @param pickedColor the new laser color when picked mesh detected
  50177. */
  50178. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50179. /**
  50180. * Set lighting enabled / disabled on the laser pointer of both controllers
  50181. * @param enabled should the lighting be enabled on the laser pointer
  50182. */
  50183. setLaserLightingState(enabled?: boolean): void;
  50184. /**
  50185. * Permanently set new colors for the gaze pointer
  50186. * @param color the new gaze color
  50187. * @param pickedColor the new gaze color when picked mesh detected
  50188. */
  50189. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50190. /**
  50191. * Sets the color of the laser ray from the vr controllers.
  50192. * @param color new color for the ray.
  50193. */
  50194. changeLaserColor(color: Color3): void;
  50195. /**
  50196. * Sets the color of the ray from the vr headsets gaze.
  50197. * @param color new color for the ray.
  50198. */
  50199. changeGazeColor(color: Color3): void;
  50200. /**
  50201. * Exits VR and disposes of the vr experience helper
  50202. */
  50203. dispose(): void;
  50204. /**
  50205. * Gets the name of the VRExperienceHelper class
  50206. * @returns "VRExperienceHelper"
  50207. */
  50208. getClassName(): string;
  50209. }
  50210. }
  50211. declare module BABYLON {
  50212. /**
  50213. * Contains an array of blocks representing the octree
  50214. */
  50215. export interface IOctreeContainer<T> {
  50216. /**
  50217. * Blocks within the octree
  50218. */
  50219. blocks: Array<OctreeBlock<T>>;
  50220. }
  50221. /**
  50222. * Class used to store a cell in an octree
  50223. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50224. */
  50225. export class OctreeBlock<T> {
  50226. /**
  50227. * Gets the content of the current block
  50228. */
  50229. entries: T[];
  50230. /**
  50231. * Gets the list of block children
  50232. */
  50233. blocks: Array<OctreeBlock<T>>;
  50234. private _depth;
  50235. private _maxDepth;
  50236. private _capacity;
  50237. private _minPoint;
  50238. private _maxPoint;
  50239. private _boundingVectors;
  50240. private _creationFunc;
  50241. /**
  50242. * Creates a new block
  50243. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50244. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50245. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50246. * @param depth defines the current depth of this block in the octree
  50247. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50248. * @param creationFunc defines a callback to call when an element is added to the block
  50249. */
  50250. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50251. /**
  50252. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50253. */
  50254. get capacity(): number;
  50255. /**
  50256. * Gets the minimum vector (in world space) of the block's bounding box
  50257. */
  50258. get minPoint(): Vector3;
  50259. /**
  50260. * Gets the maximum vector (in world space) of the block's bounding box
  50261. */
  50262. get maxPoint(): Vector3;
  50263. /**
  50264. * Add a new element to this block
  50265. * @param entry defines the element to add
  50266. */
  50267. addEntry(entry: T): void;
  50268. /**
  50269. * Remove an element from this block
  50270. * @param entry defines the element to remove
  50271. */
  50272. removeEntry(entry: T): void;
  50273. /**
  50274. * Add an array of elements to this block
  50275. * @param entries defines the array of elements to add
  50276. */
  50277. addEntries(entries: T[]): void;
  50278. /**
  50279. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50280. * @param frustumPlanes defines the frustum planes to test
  50281. * @param selection defines the array to store current content if selection is positive
  50282. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50283. */
  50284. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50285. /**
  50286. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50287. * @param sphereCenter defines the bounding sphere center
  50288. * @param sphereRadius defines the bounding sphere radius
  50289. * @param selection defines the array to store current content if selection is positive
  50290. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50291. */
  50292. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50293. /**
  50294. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50295. * @param ray defines the ray to test with
  50296. * @param selection defines the array to store current content if selection is positive
  50297. */
  50298. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50299. /**
  50300. * Subdivide the content into child blocks (this block will then be empty)
  50301. */
  50302. createInnerBlocks(): void;
  50303. /**
  50304. * @hidden
  50305. */
  50306. 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;
  50307. }
  50308. }
  50309. declare module BABYLON {
  50310. /**
  50311. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50312. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50313. */
  50314. export class Octree<T> {
  50315. /** 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.) */
  50316. maxDepth: number;
  50317. /**
  50318. * Blocks within the octree containing objects
  50319. */
  50320. blocks: Array<OctreeBlock<T>>;
  50321. /**
  50322. * Content stored in the octree
  50323. */
  50324. dynamicContent: T[];
  50325. private _maxBlockCapacity;
  50326. private _selectionContent;
  50327. private _creationFunc;
  50328. /**
  50329. * Creates a octree
  50330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50331. * @param creationFunc function to be used to instatiate the octree
  50332. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50333. * @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.)
  50334. */
  50335. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50336. /** 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.) */
  50337. maxDepth?: number);
  50338. /**
  50339. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50340. * @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);
  50341. * @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);
  50342. * @param entries meshes to be added to the octree blocks
  50343. */
  50344. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50345. /**
  50346. * Adds a mesh to the octree
  50347. * @param entry Mesh to add to the octree
  50348. */
  50349. addMesh(entry: T): void;
  50350. /**
  50351. * Remove an element from the octree
  50352. * @param entry defines the element to remove
  50353. */
  50354. removeMesh(entry: T): void;
  50355. /**
  50356. * Selects an array of meshes within the frustum
  50357. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50358. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50359. * @returns array of meshes within the frustum
  50360. */
  50361. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50362. /**
  50363. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50364. * @param sphereCenter defines the bounding sphere center
  50365. * @param sphereRadius defines the bounding sphere radius
  50366. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50367. * @returns an array of objects that intersect the sphere
  50368. */
  50369. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50370. /**
  50371. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50372. * @param ray defines the ray to test with
  50373. * @returns array of intersected objects
  50374. */
  50375. intersectsRay(ray: Ray): SmartArray<T>;
  50376. /**
  50377. * Adds a mesh into the octree block if it intersects the block
  50378. */
  50379. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50380. /**
  50381. * Adds a submesh into the octree block if it intersects the block
  50382. */
  50383. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50384. }
  50385. }
  50386. declare module BABYLON {
  50387. interface Scene {
  50388. /**
  50389. * @hidden
  50390. * Backing Filed
  50391. */
  50392. _selectionOctree: Octree<AbstractMesh>;
  50393. /**
  50394. * Gets the octree used to boost mesh selection (picking)
  50395. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50396. */
  50397. selectionOctree: Octree<AbstractMesh>;
  50398. /**
  50399. * Creates or updates the octree used to boost selection (picking)
  50400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50401. * @param maxCapacity defines the maximum capacity per leaf
  50402. * @param maxDepth defines the maximum depth of the octree
  50403. * @returns an octree of AbstractMesh
  50404. */
  50405. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50406. }
  50407. interface AbstractMesh {
  50408. /**
  50409. * @hidden
  50410. * Backing Field
  50411. */
  50412. _submeshesOctree: Octree<SubMesh>;
  50413. /**
  50414. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50415. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50416. * @param maxCapacity defines the maximum size of each block (64 by default)
  50417. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50418. * @returns the new octree
  50419. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50420. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50421. */
  50422. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50423. }
  50424. /**
  50425. * Defines the octree scene component responsible to manage any octrees
  50426. * in a given scene.
  50427. */
  50428. export class OctreeSceneComponent {
  50429. /**
  50430. * The component name help to identify the component in the list of scene components.
  50431. */
  50432. readonly name: string;
  50433. /**
  50434. * The scene the component belongs to.
  50435. */
  50436. scene: Scene;
  50437. /**
  50438. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50439. */
  50440. readonly checksIsEnabled: boolean;
  50441. /**
  50442. * Creates a new instance of the component for the given scene
  50443. * @param scene Defines the scene to register the component in
  50444. */
  50445. constructor(scene: Scene);
  50446. /**
  50447. * Registers the component in a given scene
  50448. */
  50449. register(): void;
  50450. /**
  50451. * Return the list of active meshes
  50452. * @returns the list of active meshes
  50453. */
  50454. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50455. /**
  50456. * Return the list of active sub meshes
  50457. * @param mesh The mesh to get the candidates sub meshes from
  50458. * @returns the list of active sub meshes
  50459. */
  50460. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50461. private _tempRay;
  50462. /**
  50463. * Return the list of sub meshes intersecting with a given local ray
  50464. * @param mesh defines the mesh to find the submesh for
  50465. * @param localRay defines the ray in local space
  50466. * @returns the list of intersecting sub meshes
  50467. */
  50468. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50469. /**
  50470. * Return the list of sub meshes colliding with a collider
  50471. * @param mesh defines the mesh to find the submesh for
  50472. * @param collider defines the collider to evaluate the collision against
  50473. * @returns the list of colliding sub meshes
  50474. */
  50475. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50476. /**
  50477. * Rebuilds the elements related to this component in case of
  50478. * context lost for instance.
  50479. */
  50480. rebuild(): void;
  50481. /**
  50482. * Disposes the component and the associated ressources.
  50483. */
  50484. dispose(): void;
  50485. }
  50486. }
  50487. declare module BABYLON {
  50488. /**
  50489. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50490. */
  50491. export class Gizmo implements IDisposable {
  50492. /** The utility layer the gizmo will be added to */
  50493. gizmoLayer: UtilityLayerRenderer;
  50494. /**
  50495. * The root mesh of the gizmo
  50496. */
  50497. _rootMesh: Mesh;
  50498. private _attachedMesh;
  50499. private _attachedNode;
  50500. /**
  50501. * Ratio for the scale of the gizmo (Default: 1)
  50502. */
  50503. protected _scaleRatio: number;
  50504. /**
  50505. * Ratio for the scale of the gizmo (Default: 1)
  50506. */
  50507. set scaleRatio(value: number);
  50508. get scaleRatio(): number;
  50509. /**
  50510. * If a custom mesh has been set (Default: false)
  50511. */
  50512. protected _customMeshSet: boolean;
  50513. /**
  50514. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50515. * * When set, interactions will be enabled
  50516. */
  50517. get attachedMesh(): Nullable<AbstractMesh>;
  50518. set attachedMesh(value: Nullable<AbstractMesh>);
  50519. /**
  50520. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50521. * * When set, interactions will be enabled
  50522. */
  50523. get attachedNode(): Nullable<Node>;
  50524. set attachedNode(value: Nullable<Node>);
  50525. /**
  50526. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50527. * @param mesh The mesh to replace the default mesh of the gizmo
  50528. */
  50529. setCustomMesh(mesh: Mesh): void;
  50530. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50531. /**
  50532. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50533. */
  50534. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50535. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50536. /**
  50537. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50538. */
  50539. updateGizmoPositionToMatchAttachedMesh: boolean;
  50540. /**
  50541. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50542. */
  50543. updateScale: boolean;
  50544. protected _interactionsEnabled: boolean;
  50545. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50546. private _beforeRenderObserver;
  50547. private _tempQuaternion;
  50548. private _tempVector;
  50549. private _tempVector2;
  50550. private _tempMatrix1;
  50551. private _tempMatrix2;
  50552. private _rightHandtoLeftHandMatrix;
  50553. /**
  50554. * Creates a gizmo
  50555. * @param gizmoLayer The utility layer the gizmo will be added to
  50556. */
  50557. constructor(
  50558. /** The utility layer the gizmo will be added to */
  50559. gizmoLayer?: UtilityLayerRenderer);
  50560. /**
  50561. * Updates the gizmo to match the attached mesh's position/rotation
  50562. */
  50563. protected _update(): void;
  50564. /**
  50565. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50566. * @param value Node, TransformNode or mesh
  50567. */
  50568. protected _matrixChanged(): void;
  50569. /**
  50570. * Disposes of the gizmo
  50571. */
  50572. dispose(): void;
  50573. }
  50574. }
  50575. declare module BABYLON {
  50576. /**
  50577. * Single plane drag gizmo
  50578. */
  50579. export class PlaneDragGizmo extends Gizmo {
  50580. /**
  50581. * Drag behavior responsible for the gizmos dragging interactions
  50582. */
  50583. dragBehavior: PointerDragBehavior;
  50584. private _pointerObserver;
  50585. /**
  50586. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50587. */
  50588. snapDistance: number;
  50589. /**
  50590. * Event that fires each time the gizmo snaps to a new location.
  50591. * * snapDistance is the the change in distance
  50592. */
  50593. onSnapObservable: Observable<{
  50594. snapDistance: number;
  50595. }>;
  50596. private _plane;
  50597. private _coloredMaterial;
  50598. private _hoverMaterial;
  50599. private _isEnabled;
  50600. private _parent;
  50601. /** @hidden */
  50602. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50603. /** @hidden */
  50604. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50605. /**
  50606. * Creates a PlaneDragGizmo
  50607. * @param gizmoLayer The utility layer the gizmo will be added to
  50608. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50609. * @param color The color of the gizmo
  50610. */
  50611. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50612. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50613. /**
  50614. * If the gizmo is enabled
  50615. */
  50616. set isEnabled(value: boolean);
  50617. get isEnabled(): boolean;
  50618. /**
  50619. * Disposes of the gizmo
  50620. */
  50621. dispose(): void;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. /**
  50626. * Gizmo that enables dragging a mesh along 3 axis
  50627. */
  50628. export class PositionGizmo extends Gizmo {
  50629. /**
  50630. * Internal gizmo used for interactions on the x axis
  50631. */
  50632. xGizmo: AxisDragGizmo;
  50633. /**
  50634. * Internal gizmo used for interactions on the y axis
  50635. */
  50636. yGizmo: AxisDragGizmo;
  50637. /**
  50638. * Internal gizmo used for interactions on the z axis
  50639. */
  50640. zGizmo: AxisDragGizmo;
  50641. /**
  50642. * Internal gizmo used for interactions on the yz plane
  50643. */
  50644. xPlaneGizmo: PlaneDragGizmo;
  50645. /**
  50646. * Internal gizmo used for interactions on the xz plane
  50647. */
  50648. yPlaneGizmo: PlaneDragGizmo;
  50649. /**
  50650. * Internal gizmo used for interactions on the xy plane
  50651. */
  50652. zPlaneGizmo: PlaneDragGizmo;
  50653. /**
  50654. * private variables
  50655. */
  50656. private _meshAttached;
  50657. private _nodeAttached;
  50658. private _snapDistance;
  50659. /** Fires an event when any of it's sub gizmos are dragged */
  50660. onDragStartObservable: Observable<unknown>;
  50661. /** Fires an event when any of it's sub gizmos are released from dragging */
  50662. onDragEndObservable: Observable<unknown>;
  50663. /**
  50664. * If set to true, planar drag is enabled
  50665. */
  50666. private _planarGizmoEnabled;
  50667. get attachedMesh(): Nullable<AbstractMesh>;
  50668. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50669. get attachedNode(): Nullable<Node>;
  50670. set attachedNode(node: Nullable<Node>);
  50671. /**
  50672. * Creates a PositionGizmo
  50673. * @param gizmoLayer The utility layer the gizmo will be added to
  50674. @param thickness display gizmo axis thickness
  50675. */
  50676. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50677. /**
  50678. * If the planar drag gizmo is enabled
  50679. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50680. */
  50681. set planarGizmoEnabled(value: boolean);
  50682. get planarGizmoEnabled(): boolean;
  50683. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50684. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50685. /**
  50686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50687. */
  50688. set snapDistance(value: number);
  50689. get snapDistance(): number;
  50690. /**
  50691. * Ratio for the scale of the gizmo (Default: 1)
  50692. */
  50693. set scaleRatio(value: number);
  50694. get scaleRatio(): number;
  50695. /**
  50696. * Disposes of the gizmo
  50697. */
  50698. dispose(): void;
  50699. /**
  50700. * CustomMeshes are not supported by this gizmo
  50701. * @param mesh The mesh to replace the default mesh of the gizmo
  50702. */
  50703. setCustomMesh(mesh: Mesh): void;
  50704. }
  50705. }
  50706. declare module BABYLON {
  50707. /**
  50708. * Single axis drag gizmo
  50709. */
  50710. export class AxisDragGizmo extends Gizmo {
  50711. /**
  50712. * Drag behavior responsible for the gizmos dragging interactions
  50713. */
  50714. dragBehavior: PointerDragBehavior;
  50715. private _pointerObserver;
  50716. /**
  50717. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50718. */
  50719. snapDistance: number;
  50720. /**
  50721. * Event that fires each time the gizmo snaps to a new location.
  50722. * * snapDistance is the the change in distance
  50723. */
  50724. onSnapObservable: Observable<{
  50725. snapDistance: number;
  50726. }>;
  50727. private _isEnabled;
  50728. private _parent;
  50729. private _arrow;
  50730. private _coloredMaterial;
  50731. private _hoverMaterial;
  50732. /** @hidden */
  50733. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50734. /** @hidden */
  50735. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50736. /**
  50737. * Creates an AxisDragGizmo
  50738. * @param gizmoLayer The utility layer the gizmo will be added to
  50739. * @param dragAxis The axis which the gizmo will be able to drag on
  50740. * @param color The color of the gizmo
  50741. * @param thickness display gizmo axis thickness
  50742. */
  50743. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50744. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50745. /**
  50746. * If the gizmo is enabled
  50747. */
  50748. set isEnabled(value: boolean);
  50749. get isEnabled(): boolean;
  50750. /**
  50751. * Disposes of the gizmo
  50752. */
  50753. dispose(): void;
  50754. }
  50755. }
  50756. declare module BABYLON.Debug {
  50757. /**
  50758. * The Axes viewer will show 3 axes in a specific point in space
  50759. */
  50760. export class AxesViewer {
  50761. private _xAxis;
  50762. private _yAxis;
  50763. private _zAxis;
  50764. private _scaleLinesFactor;
  50765. private _instanced;
  50766. /**
  50767. * Gets the hosting scene
  50768. */
  50769. scene: Nullable<Scene>;
  50770. /**
  50771. * Gets or sets a number used to scale line length
  50772. */
  50773. scaleLines: number;
  50774. /** Gets the node hierarchy used to render x-axis */
  50775. get xAxis(): TransformNode;
  50776. /** Gets the node hierarchy used to render y-axis */
  50777. get yAxis(): TransformNode;
  50778. /** Gets the node hierarchy used to render z-axis */
  50779. get zAxis(): TransformNode;
  50780. /**
  50781. * Creates a new AxesViewer
  50782. * @param scene defines the hosting scene
  50783. * @param scaleLines defines a number used to scale line length (1 by default)
  50784. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50785. * @param xAxis defines the node hierarchy used to render the x-axis
  50786. * @param yAxis defines the node hierarchy used to render the y-axis
  50787. * @param zAxis defines the node hierarchy used to render the z-axis
  50788. */
  50789. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50790. /**
  50791. * Force the viewer to update
  50792. * @param position defines the position of the viewer
  50793. * @param xaxis defines the x axis of the viewer
  50794. * @param yaxis defines the y axis of the viewer
  50795. * @param zaxis defines the z axis of the viewer
  50796. */
  50797. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50798. /**
  50799. * Creates an instance of this axes viewer.
  50800. * @returns a new axes viewer with instanced meshes
  50801. */
  50802. createInstance(): AxesViewer;
  50803. /** Releases resources */
  50804. dispose(): void;
  50805. private static _SetRenderingGroupId;
  50806. }
  50807. }
  50808. declare module BABYLON.Debug {
  50809. /**
  50810. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50811. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50812. */
  50813. export class BoneAxesViewer extends AxesViewer {
  50814. /**
  50815. * Gets or sets the target mesh where to display the axes viewer
  50816. */
  50817. mesh: Nullable<Mesh>;
  50818. /**
  50819. * Gets or sets the target bone where to display the axes viewer
  50820. */
  50821. bone: Nullable<Bone>;
  50822. /** Gets current position */
  50823. pos: Vector3;
  50824. /** Gets direction of X axis */
  50825. xaxis: Vector3;
  50826. /** Gets direction of Y axis */
  50827. yaxis: Vector3;
  50828. /** Gets direction of Z axis */
  50829. zaxis: Vector3;
  50830. /**
  50831. * Creates a new BoneAxesViewer
  50832. * @param scene defines the hosting scene
  50833. * @param bone defines the target bone
  50834. * @param mesh defines the target mesh
  50835. * @param scaleLines defines a scaling factor for line length (1 by default)
  50836. */
  50837. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50838. /**
  50839. * Force the viewer to update
  50840. */
  50841. update(): void;
  50842. /** Releases resources */
  50843. dispose(): void;
  50844. }
  50845. }
  50846. declare module BABYLON {
  50847. /**
  50848. * Interface used to define scene explorer extensibility option
  50849. */
  50850. export interface IExplorerExtensibilityOption {
  50851. /**
  50852. * Define the option label
  50853. */
  50854. label: string;
  50855. /**
  50856. * Defines the action to execute on click
  50857. */
  50858. action: (entity: any) => void;
  50859. }
  50860. /**
  50861. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50862. */
  50863. export interface IExplorerExtensibilityGroup {
  50864. /**
  50865. * Defines a predicate to test if a given type mut be extended
  50866. */
  50867. predicate: (entity: any) => boolean;
  50868. /**
  50869. * Gets the list of options added to a type
  50870. */
  50871. entries: IExplorerExtensibilityOption[];
  50872. }
  50873. /**
  50874. * Interface used to define the options to use to create the Inspector
  50875. */
  50876. export interface IInspectorOptions {
  50877. /**
  50878. * Display in overlay mode (default: false)
  50879. */
  50880. overlay?: boolean;
  50881. /**
  50882. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50883. */
  50884. globalRoot?: HTMLElement;
  50885. /**
  50886. * Display the Scene explorer
  50887. */
  50888. showExplorer?: boolean;
  50889. /**
  50890. * Display the property inspector
  50891. */
  50892. showInspector?: boolean;
  50893. /**
  50894. * Display in embed mode (both panes on the right)
  50895. */
  50896. embedMode?: boolean;
  50897. /**
  50898. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50899. */
  50900. handleResize?: boolean;
  50901. /**
  50902. * Allow the panes to popup (default: true)
  50903. */
  50904. enablePopup?: boolean;
  50905. /**
  50906. * Allow the panes to be closed by users (default: true)
  50907. */
  50908. enableClose?: boolean;
  50909. /**
  50910. * Optional list of extensibility entries
  50911. */
  50912. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50913. /**
  50914. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50915. */
  50916. inspectorURL?: string;
  50917. /**
  50918. * Optional initial tab (default to DebugLayerTab.Properties)
  50919. */
  50920. initialTab?: DebugLayerTab;
  50921. }
  50922. interface Scene {
  50923. /**
  50924. * @hidden
  50925. * Backing field
  50926. */
  50927. _debugLayer: DebugLayer;
  50928. /**
  50929. * Gets the debug layer (aka Inspector) associated with the scene
  50930. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50931. */
  50932. debugLayer: DebugLayer;
  50933. }
  50934. /**
  50935. * Enum of inspector action tab
  50936. */
  50937. export enum DebugLayerTab {
  50938. /**
  50939. * Properties tag (default)
  50940. */
  50941. Properties = 0,
  50942. /**
  50943. * Debug tab
  50944. */
  50945. Debug = 1,
  50946. /**
  50947. * Statistics tab
  50948. */
  50949. Statistics = 2,
  50950. /**
  50951. * Tools tab
  50952. */
  50953. Tools = 3,
  50954. /**
  50955. * Settings tab
  50956. */
  50957. Settings = 4
  50958. }
  50959. /**
  50960. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50961. * what is happening in your scene
  50962. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50963. */
  50964. export class DebugLayer {
  50965. /**
  50966. * Define the url to get the inspector script from.
  50967. * By default it uses the babylonjs CDN.
  50968. * @ignoreNaming
  50969. */
  50970. static InspectorURL: string;
  50971. private _scene;
  50972. private BJSINSPECTOR;
  50973. private _onPropertyChangedObservable?;
  50974. /**
  50975. * Observable triggered when a property is changed through the inspector.
  50976. */
  50977. get onPropertyChangedObservable(): any;
  50978. /**
  50979. * Instantiates a new debug layer.
  50980. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50981. * what is happening in your scene
  50982. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50983. * @param scene Defines the scene to inspect
  50984. */
  50985. constructor(scene: Scene);
  50986. /** Creates the inspector window. */
  50987. private _createInspector;
  50988. /**
  50989. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50990. * @param entity defines the entity to select
  50991. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50992. */
  50993. select(entity: any, lineContainerTitles?: string | string[]): void;
  50994. /** Get the inspector from bundle or global */
  50995. private _getGlobalInspector;
  50996. /**
  50997. * Get if the inspector is visible or not.
  50998. * @returns true if visible otherwise, false
  50999. */
  51000. isVisible(): boolean;
  51001. /**
  51002. * Hide the inspector and close its window.
  51003. */
  51004. hide(): void;
  51005. /**
  51006. * Update the scene in the inspector
  51007. */
  51008. setAsActiveScene(): void;
  51009. /**
  51010. * Launch the debugLayer.
  51011. * @param config Define the configuration of the inspector
  51012. * @return a promise fulfilled when the debug layer is visible
  51013. */
  51014. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51015. }
  51016. }
  51017. declare module BABYLON {
  51018. /**
  51019. * Class containing static functions to help procedurally build meshes
  51020. */
  51021. export class BoxBuilder {
  51022. /**
  51023. * Creates a box mesh
  51024. * * The parameter `size` sets the size (float) of each box side (default 1)
  51025. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51026. * * 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)
  51027. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51029. * * 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
  51030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51031. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51032. * @param name defines the name of the mesh
  51033. * @param options defines the options used to create the mesh
  51034. * @param scene defines the hosting scene
  51035. * @returns the box mesh
  51036. */
  51037. static CreateBox(name: string, options: {
  51038. size?: number;
  51039. width?: number;
  51040. height?: number;
  51041. depth?: number;
  51042. faceUV?: Vector4[];
  51043. faceColors?: Color4[];
  51044. sideOrientation?: number;
  51045. frontUVs?: Vector4;
  51046. backUVs?: Vector4;
  51047. wrap?: boolean;
  51048. topBaseAt?: number;
  51049. bottomBaseAt?: number;
  51050. updatable?: boolean;
  51051. }, scene?: Nullable<Scene>): Mesh;
  51052. }
  51053. }
  51054. declare module BABYLON.Debug {
  51055. /**
  51056. * Used to show the physics impostor around the specific mesh
  51057. */
  51058. export class PhysicsViewer {
  51059. /** @hidden */
  51060. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51061. /** @hidden */
  51062. protected _meshes: Array<Nullable<AbstractMesh>>;
  51063. /** @hidden */
  51064. protected _scene: Nullable<Scene>;
  51065. /** @hidden */
  51066. protected _numMeshes: number;
  51067. /** @hidden */
  51068. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51069. private _renderFunction;
  51070. private _utilityLayer;
  51071. private _debugBoxMesh;
  51072. private _debugSphereMesh;
  51073. private _debugCylinderMesh;
  51074. private _debugMaterial;
  51075. private _debugMeshMeshes;
  51076. /**
  51077. * Creates a new PhysicsViewer
  51078. * @param scene defines the hosting scene
  51079. */
  51080. constructor(scene: Scene);
  51081. /** @hidden */
  51082. protected _updateDebugMeshes(): void;
  51083. /**
  51084. * Renders a specified physic impostor
  51085. * @param impostor defines the impostor to render
  51086. * @param targetMesh defines the mesh represented by the impostor
  51087. * @returns the new debug mesh used to render the impostor
  51088. */
  51089. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51090. /**
  51091. * Hides a specified physic impostor
  51092. * @param impostor defines the impostor to hide
  51093. */
  51094. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51095. private _getDebugMaterial;
  51096. private _getDebugBoxMesh;
  51097. private _getDebugSphereMesh;
  51098. private _getDebugCylinderMesh;
  51099. private _getDebugMeshMesh;
  51100. private _getDebugMesh;
  51101. /** Releases all resources */
  51102. dispose(): void;
  51103. }
  51104. }
  51105. declare module BABYLON {
  51106. /**
  51107. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51108. * in order to better appreciate the issue one might have.
  51109. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51110. */
  51111. export class RayHelper {
  51112. /**
  51113. * Defines the ray we are currently tryin to visualize.
  51114. */
  51115. ray: Nullable<Ray>;
  51116. private _renderPoints;
  51117. private _renderLine;
  51118. private _renderFunction;
  51119. private _scene;
  51120. private _onAfterRenderObserver;
  51121. private _onAfterStepObserver;
  51122. private _attachedToMesh;
  51123. private _meshSpaceDirection;
  51124. private _meshSpaceOrigin;
  51125. /**
  51126. * Helper function to create a colored helper in a scene in one line.
  51127. * @param ray Defines the ray we are currently tryin to visualize
  51128. * @param scene Defines the scene the ray is used in
  51129. * @param color Defines the color we want to see the ray in
  51130. * @returns The newly created ray helper.
  51131. */
  51132. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51133. /**
  51134. * Instantiate a new ray helper.
  51135. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51136. * in order to better appreciate the issue one might have.
  51137. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51138. * @param ray Defines the ray we are currently tryin to visualize
  51139. */
  51140. constructor(ray: Ray);
  51141. /**
  51142. * Shows the ray we are willing to debug.
  51143. * @param scene Defines the scene the ray needs to be rendered in
  51144. * @param color Defines the color the ray needs to be rendered in
  51145. */
  51146. show(scene: Scene, color?: Color3): void;
  51147. /**
  51148. * Hides the ray we are debugging.
  51149. */
  51150. hide(): void;
  51151. private _render;
  51152. /**
  51153. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51154. * @param mesh Defines the mesh we want the helper attached to
  51155. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51156. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51157. * @param length Defines the length of the ray
  51158. */
  51159. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51160. /**
  51161. * Detach the ray helper from the mesh it has previously been attached to.
  51162. */
  51163. detachFromMesh(): void;
  51164. private _updateToMesh;
  51165. /**
  51166. * Dispose the helper and release its associated resources.
  51167. */
  51168. dispose(): void;
  51169. }
  51170. }
  51171. declare module BABYLON {
  51172. /**
  51173. * Defines the options associated with the creation of a SkeletonViewer.
  51174. */
  51175. export interface ISkeletonViewerOptions {
  51176. /** Should the system pause animations before building the Viewer? */
  51177. pauseAnimations: boolean;
  51178. /** Should the system return the skeleton to rest before building? */
  51179. returnToRest: boolean;
  51180. /** public Display Mode of the Viewer */
  51181. displayMode: number;
  51182. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51183. displayOptions: ISkeletonViewerDisplayOptions;
  51184. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51185. computeBonesUsingShaders: boolean;
  51186. /** Flag ignore non weighted bones */
  51187. useAllBones: boolean;
  51188. }
  51189. /**
  51190. * Defines how to display the various bone meshes for the viewer.
  51191. */
  51192. export interface ISkeletonViewerDisplayOptions {
  51193. /** How far down to start tapering the bone spurs */
  51194. midStep?: number;
  51195. /** How big is the midStep? */
  51196. midStepFactor?: number;
  51197. /** Base for the Sphere Size */
  51198. sphereBaseSize?: number;
  51199. /** The ratio of the sphere to the longest bone in units */
  51200. sphereScaleUnit?: number;
  51201. /** Ratio for the Sphere Size */
  51202. sphereFactor?: number;
  51203. }
  51204. /**
  51205. * Defines the constructor options for the BoneWeight Shader.
  51206. */
  51207. export interface IBoneWeightShaderOptions {
  51208. /** Skeleton to Map */
  51209. skeleton: Skeleton;
  51210. /** Colors for Uninfluenced bones */
  51211. colorBase?: Color3;
  51212. /** Colors for 0.0-0.25 Weight bones */
  51213. colorZero?: Color3;
  51214. /** Color for 0.25-0.5 Weight Influence */
  51215. colorQuarter?: Color3;
  51216. /** Color for 0.5-0.75 Weight Influence */
  51217. colorHalf?: Color3;
  51218. /** Color for 0.75-1 Weight Influence */
  51219. colorFull?: Color3;
  51220. /** Color for Zero Weight Influence */
  51221. targetBoneIndex?: number;
  51222. }
  51223. /**
  51224. * Simple structure of the gradient steps for the Color Map.
  51225. */
  51226. export interface ISkeletonMapShaderColorMapKnot {
  51227. /** Color of the Knot */
  51228. color: Color3;
  51229. /** Location of the Knot */
  51230. location: number;
  51231. }
  51232. /**
  51233. * Defines the constructor options for the SkeletonMap Shader.
  51234. */
  51235. export interface ISkeletonMapShaderOptions {
  51236. /** Skeleton to Map */
  51237. skeleton: Skeleton;
  51238. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51239. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51240. }
  51241. }
  51242. declare module BABYLON {
  51243. /**
  51244. * Class containing static functions to help procedurally build meshes
  51245. */
  51246. export class RibbonBuilder {
  51247. /**
  51248. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51249. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51250. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51251. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51252. * * 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
  51253. * * 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
  51254. * * 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
  51255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51256. * * 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
  51257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51258. * * 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
  51259. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51260. * * 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
  51261. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51263. * @param name defines the name of the mesh
  51264. * @param options defines the options used to create the mesh
  51265. * @param scene defines the hosting scene
  51266. * @returns the ribbon mesh
  51267. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51269. */
  51270. static CreateRibbon(name: string, options: {
  51271. pathArray: Vector3[][];
  51272. closeArray?: boolean;
  51273. closePath?: boolean;
  51274. offset?: number;
  51275. updatable?: boolean;
  51276. sideOrientation?: number;
  51277. frontUVs?: Vector4;
  51278. backUVs?: Vector4;
  51279. instance?: Mesh;
  51280. invertUV?: boolean;
  51281. uvs?: Vector2[];
  51282. colors?: Color4[];
  51283. }, scene?: Nullable<Scene>): Mesh;
  51284. }
  51285. }
  51286. declare module BABYLON {
  51287. /**
  51288. * Class containing static functions to help procedurally build meshes
  51289. */
  51290. export class ShapeBuilder {
  51291. /**
  51292. * 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.
  51293. * * 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.
  51294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51295. * * 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.
  51296. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51297. * * 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
  51298. * * 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
  51299. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51301. * * 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
  51302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51304. * @param name defines the name of the mesh
  51305. * @param options defines the options used to create the mesh
  51306. * @param scene defines the hosting scene
  51307. * @returns the extruded shape mesh
  51308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51310. */
  51311. static ExtrudeShape(name: string, options: {
  51312. shape: Vector3[];
  51313. path: Vector3[];
  51314. scale?: number;
  51315. rotation?: number;
  51316. cap?: number;
  51317. updatable?: boolean;
  51318. sideOrientation?: number;
  51319. frontUVs?: Vector4;
  51320. backUVs?: Vector4;
  51321. instance?: Mesh;
  51322. invertUV?: boolean;
  51323. }, scene?: Nullable<Scene>): Mesh;
  51324. /**
  51325. * Creates an custom extruded shape mesh.
  51326. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51327. * * 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.
  51328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51329. * * 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
  51330. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51331. * * 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
  51332. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51333. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51334. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51335. * * 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
  51336. * * 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
  51337. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51339. * * 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
  51340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51342. * @param name defines the name of the mesh
  51343. * @param options defines the options used to create the mesh
  51344. * @param scene defines the hosting scene
  51345. * @returns the custom extruded shape mesh
  51346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51349. */
  51350. static ExtrudeShapeCustom(name: string, options: {
  51351. shape: Vector3[];
  51352. path: Vector3[];
  51353. scaleFunction?: any;
  51354. rotationFunction?: any;
  51355. ribbonCloseArray?: boolean;
  51356. ribbonClosePath?: boolean;
  51357. cap?: number;
  51358. updatable?: boolean;
  51359. sideOrientation?: number;
  51360. frontUVs?: Vector4;
  51361. backUVs?: Vector4;
  51362. instance?: Mesh;
  51363. invertUV?: boolean;
  51364. }, scene?: Nullable<Scene>): Mesh;
  51365. private static _ExtrudeShapeGeneric;
  51366. }
  51367. }
  51368. declare module BABYLON.Debug {
  51369. /**
  51370. * Class used to render a debug view of a given skeleton
  51371. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51372. */
  51373. export class SkeletonViewer {
  51374. /** defines the skeleton to render */
  51375. skeleton: Skeleton;
  51376. /** defines the mesh attached to the skeleton */
  51377. mesh: AbstractMesh;
  51378. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51379. autoUpdateBonesMatrices: boolean;
  51380. /** defines the rendering group id to use with the viewer */
  51381. renderingGroupId: number;
  51382. /** is the options for the viewer */
  51383. options: Partial<ISkeletonViewerOptions>;
  51384. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51385. static readonly DISPLAY_LINES: number;
  51386. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51387. static readonly DISPLAY_SPHERES: number;
  51388. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51389. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51390. /** public static method to create a BoneWeight Shader
  51391. * @param options The constructor options
  51392. * @param scene The scene that the shader is scoped to
  51393. * @returns The created ShaderMaterial
  51394. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51395. */
  51396. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51397. /** public static method to create a BoneWeight Shader
  51398. * @param options The constructor options
  51399. * @param scene The scene that the shader is scoped to
  51400. * @returns The created ShaderMaterial
  51401. */
  51402. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51403. /** private static method to create a BoneWeight Shader
  51404. * @param size The size of the buffer to create (usually the bone count)
  51405. * @param colorMap The gradient data to generate
  51406. * @param scene The scene that the shader is scoped to
  51407. * @returns an Array of floats from the color gradient values
  51408. */
  51409. private static _CreateBoneMapColorBuffer;
  51410. /** If SkeletonViewer scene scope. */
  51411. private _scene;
  51412. /** Gets or sets the color used to render the skeleton */
  51413. color: Color3;
  51414. /** Array of the points of the skeleton fo the line view. */
  51415. private _debugLines;
  51416. /** The SkeletonViewers Mesh. */
  51417. private _debugMesh;
  51418. /** If SkeletonViewer is enabled. */
  51419. private _isEnabled;
  51420. /** If SkeletonViewer is ready. */
  51421. private _ready;
  51422. /** SkeletonViewer render observable. */
  51423. private _obs;
  51424. /** The Utility Layer to render the gizmos in. */
  51425. private _utilityLayer;
  51426. private _boneIndices;
  51427. /** Gets the Scene. */
  51428. get scene(): Scene;
  51429. /** Gets the utilityLayer. */
  51430. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51431. /** Checks Ready Status. */
  51432. get isReady(): Boolean;
  51433. /** Sets Ready Status. */
  51434. set ready(value: boolean);
  51435. /** Gets the debugMesh */
  51436. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51437. /** Sets the debugMesh */
  51438. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51439. /** Gets the displayMode */
  51440. get displayMode(): number;
  51441. /** Sets the displayMode */
  51442. set displayMode(value: number);
  51443. /**
  51444. * Creates a new SkeletonViewer
  51445. * @param skeleton defines the skeleton to render
  51446. * @param mesh defines the mesh attached to the skeleton
  51447. * @param scene defines the hosting scene
  51448. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51449. * @param renderingGroupId defines the rendering group id to use with the viewer
  51450. * @param options All of the extra constructor options for the SkeletonViewer
  51451. */
  51452. constructor(
  51453. /** defines the skeleton to render */
  51454. skeleton: Skeleton,
  51455. /** defines the mesh attached to the skeleton */
  51456. mesh: AbstractMesh,
  51457. /** The Scene scope*/
  51458. scene: Scene,
  51459. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51460. autoUpdateBonesMatrices?: boolean,
  51461. /** defines the rendering group id to use with the viewer */
  51462. renderingGroupId?: number,
  51463. /** is the options for the viewer */
  51464. options?: Partial<ISkeletonViewerOptions>);
  51465. /** The Dynamic bindings for the update functions */
  51466. private _bindObs;
  51467. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51468. update(): void;
  51469. /** Gets or sets a boolean indicating if the viewer is enabled */
  51470. set isEnabled(value: boolean);
  51471. get isEnabled(): boolean;
  51472. private _getBonePosition;
  51473. private _getLinesForBonesWithLength;
  51474. private _getLinesForBonesNoLength;
  51475. /** function to revert the mesh and scene back to the initial state. */
  51476. private _revert;
  51477. /** function to build and bind sphere joint points and spur bone representations. */
  51478. private _buildSpheresAndSpurs;
  51479. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51480. private _displayLinesUpdate;
  51481. /** Changes the displayMode of the skeleton viewer
  51482. * @param mode The displayMode numerical value
  51483. */
  51484. changeDisplayMode(mode: number): void;
  51485. /** Changes the displayMode of the skeleton viewer
  51486. * @param option String of the option name
  51487. * @param value The numerical option value
  51488. */
  51489. changeDisplayOptions(option: string, value: number): void;
  51490. /** Release associated resources */
  51491. dispose(): void;
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /**
  51496. * Enum for Device Types
  51497. */
  51498. export enum DeviceType {
  51499. /** Generic */
  51500. Generic = 0,
  51501. /** Keyboard */
  51502. Keyboard = 1,
  51503. /** Mouse */
  51504. Mouse = 2,
  51505. /** Touch Pointers */
  51506. Touch = 3,
  51507. /** PS4 Dual Shock */
  51508. DualShock = 4,
  51509. /** Xbox */
  51510. Xbox = 5,
  51511. /** Switch Controller */
  51512. Switch = 6
  51513. }
  51514. /**
  51515. * Enum for All Pointers (Touch/Mouse)
  51516. */
  51517. export enum PointerInput {
  51518. /** Horizontal Axis */
  51519. Horizontal = 0,
  51520. /** Vertical Axis */
  51521. Vertical = 1,
  51522. /** Left Click or Touch */
  51523. LeftClick = 2,
  51524. /** Middle Click */
  51525. MiddleClick = 3,
  51526. /** Right Click */
  51527. RightClick = 4,
  51528. /** Browser Back */
  51529. BrowserBack = 5,
  51530. /** Browser Forward */
  51531. BrowserForward = 6
  51532. }
  51533. /**
  51534. * Enum for Dual Shock Gamepad
  51535. */
  51536. export enum DualShockInput {
  51537. /** Cross */
  51538. Cross = 0,
  51539. /** Circle */
  51540. Circle = 1,
  51541. /** Square */
  51542. Square = 2,
  51543. /** Triangle */
  51544. Triangle = 3,
  51545. /** L1 */
  51546. L1 = 4,
  51547. /** R1 */
  51548. R1 = 5,
  51549. /** L2 */
  51550. L2 = 6,
  51551. /** R2 */
  51552. R2 = 7,
  51553. /** Share */
  51554. Share = 8,
  51555. /** Options */
  51556. Options = 9,
  51557. /** L3 */
  51558. L3 = 10,
  51559. /** R3 */
  51560. R3 = 11,
  51561. /** DPadUp */
  51562. DPadUp = 12,
  51563. /** DPadDown */
  51564. DPadDown = 13,
  51565. /** DPadLeft */
  51566. DPadLeft = 14,
  51567. /** DRight */
  51568. DPadRight = 15,
  51569. /** Home */
  51570. Home = 16,
  51571. /** TouchPad */
  51572. TouchPad = 17,
  51573. /** LStickXAxis */
  51574. LStickXAxis = 18,
  51575. /** LStickYAxis */
  51576. LStickYAxis = 19,
  51577. /** RStickXAxis */
  51578. RStickXAxis = 20,
  51579. /** RStickYAxis */
  51580. RStickYAxis = 21
  51581. }
  51582. /**
  51583. * Enum for Xbox Gamepad
  51584. */
  51585. export enum XboxInput {
  51586. /** A */
  51587. A = 0,
  51588. /** B */
  51589. B = 1,
  51590. /** X */
  51591. X = 2,
  51592. /** Y */
  51593. Y = 3,
  51594. /** LB */
  51595. LB = 4,
  51596. /** RB */
  51597. RB = 5,
  51598. /** LT */
  51599. LT = 6,
  51600. /** RT */
  51601. RT = 7,
  51602. /** Back */
  51603. Back = 8,
  51604. /** Start */
  51605. Start = 9,
  51606. /** LS */
  51607. LS = 10,
  51608. /** RS */
  51609. RS = 11,
  51610. /** DPadUp */
  51611. DPadUp = 12,
  51612. /** DPadDown */
  51613. DPadDown = 13,
  51614. /** DPadLeft */
  51615. DPadLeft = 14,
  51616. /** DRight */
  51617. DPadRight = 15,
  51618. /** Home */
  51619. Home = 16,
  51620. /** LStickXAxis */
  51621. LStickXAxis = 17,
  51622. /** LStickYAxis */
  51623. LStickYAxis = 18,
  51624. /** RStickXAxis */
  51625. RStickXAxis = 19,
  51626. /** RStickYAxis */
  51627. RStickYAxis = 20
  51628. }
  51629. /**
  51630. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51631. */
  51632. export enum SwitchInput {
  51633. /** B */
  51634. B = 0,
  51635. /** A */
  51636. A = 1,
  51637. /** Y */
  51638. Y = 2,
  51639. /** X */
  51640. X = 3,
  51641. /** L */
  51642. L = 4,
  51643. /** R */
  51644. R = 5,
  51645. /** ZL */
  51646. ZL = 6,
  51647. /** ZR */
  51648. ZR = 7,
  51649. /** Minus */
  51650. Minus = 8,
  51651. /** Plus */
  51652. Plus = 9,
  51653. /** LS */
  51654. LS = 10,
  51655. /** RS */
  51656. RS = 11,
  51657. /** DPadUp */
  51658. DPadUp = 12,
  51659. /** DPadDown */
  51660. DPadDown = 13,
  51661. /** DPadLeft */
  51662. DPadLeft = 14,
  51663. /** DRight */
  51664. DPadRight = 15,
  51665. /** Home */
  51666. Home = 16,
  51667. /** Capture */
  51668. Capture = 17,
  51669. /** LStickXAxis */
  51670. LStickXAxis = 18,
  51671. /** LStickYAxis */
  51672. LStickYAxis = 19,
  51673. /** RStickXAxis */
  51674. RStickXAxis = 20,
  51675. /** RStickYAxis */
  51676. RStickYAxis = 21
  51677. }
  51678. }
  51679. declare module BABYLON {
  51680. /**
  51681. * This class will take all inputs from Keyboard, Pointer, and
  51682. * any Gamepads and provide a polling system that all devices
  51683. * will use. This class assumes that there will only be one
  51684. * pointer device and one keyboard.
  51685. */
  51686. export class DeviceInputSystem implements IDisposable {
  51687. /**
  51688. * Callback to be triggered when a device is connected
  51689. */
  51690. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51691. /**
  51692. * Callback to be triggered when a device is disconnected
  51693. */
  51694. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51695. /**
  51696. * Callback to be triggered when event driven input is updated
  51697. */
  51698. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51699. private _inputs;
  51700. private _gamepads;
  51701. private _keyboardActive;
  51702. private _pointerActive;
  51703. private _elementToAttachTo;
  51704. private _keyboardDownEvent;
  51705. private _keyboardUpEvent;
  51706. private _pointerMoveEvent;
  51707. private _pointerDownEvent;
  51708. private _pointerUpEvent;
  51709. private _gamepadConnectedEvent;
  51710. private _gamepadDisconnectedEvent;
  51711. private static _MAX_KEYCODES;
  51712. private static _MAX_POINTER_INPUTS;
  51713. private constructor();
  51714. /**
  51715. * Creates a new DeviceInputSystem instance
  51716. * @param engine Engine to pull input element from
  51717. * @returns The new instance
  51718. */
  51719. static Create(engine: Engine): DeviceInputSystem;
  51720. /**
  51721. * Checks for current device input value, given an id and input index
  51722. * @param deviceName Id of connected device
  51723. * @param inputIndex Index of device input
  51724. * @returns Current value of input
  51725. */
  51726. /**
  51727. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51728. * @param deviceType Enum specifiying device type
  51729. * @param deviceSlot "Slot" or index that device is referenced in
  51730. * @param inputIndex Id of input to be checked
  51731. * @returns Current value of input
  51732. */
  51733. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51734. /**
  51735. * Dispose of all the eventlisteners
  51736. */
  51737. dispose(): void;
  51738. /**
  51739. * Add device and inputs to device array
  51740. * @param deviceType Enum specifiying device type
  51741. * @param deviceSlot "Slot" or index that device is referenced in
  51742. * @param numberOfInputs Number of input entries to create for given device
  51743. */
  51744. private _registerDevice;
  51745. /**
  51746. * Given a specific device name, remove that device from the device map
  51747. * @param deviceType Enum specifiying device type
  51748. * @param deviceSlot "Slot" or index that device is referenced in
  51749. */
  51750. private _unregisterDevice;
  51751. /**
  51752. * Handle all actions that come from keyboard interaction
  51753. */
  51754. private _handleKeyActions;
  51755. /**
  51756. * Handle all actions that come from pointer interaction
  51757. */
  51758. private _handlePointerActions;
  51759. /**
  51760. * Handle all actions that come from gamepad interaction
  51761. */
  51762. private _handleGamepadActions;
  51763. /**
  51764. * Update all non-event based devices with each frame
  51765. * @param deviceType Enum specifiying device type
  51766. * @param deviceSlot "Slot" or index that device is referenced in
  51767. * @param inputIndex Id of input to be checked
  51768. */
  51769. private _updateDevice;
  51770. /**
  51771. * Gets DeviceType from the device name
  51772. * @param deviceName Name of Device from DeviceInputSystem
  51773. * @returns DeviceType enum value
  51774. */
  51775. private _getGamepadDeviceType;
  51776. }
  51777. }
  51778. declare module BABYLON {
  51779. /**
  51780. * Type to handle enforcement of inputs
  51781. */
  51782. 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;
  51783. }
  51784. declare module BABYLON {
  51785. /**
  51786. * Class that handles all input for a specific device
  51787. */
  51788. export class DeviceSource<T extends DeviceType> {
  51789. /** Type of device */
  51790. readonly deviceType: DeviceType;
  51791. /** "Slot" or index that device is referenced in */
  51792. readonly deviceSlot: number;
  51793. /**
  51794. * Observable to handle device input changes per device
  51795. */
  51796. readonly onInputChangedObservable: Observable<{
  51797. inputIndex: DeviceInput<T>;
  51798. previousState: Nullable<number>;
  51799. currentState: Nullable<number>;
  51800. }>;
  51801. private readonly _deviceInputSystem;
  51802. /**
  51803. * Default Constructor
  51804. * @param deviceInputSystem Reference to DeviceInputSystem
  51805. * @param deviceType Type of device
  51806. * @param deviceSlot "Slot" or index that device is referenced in
  51807. */
  51808. constructor(deviceInputSystem: DeviceInputSystem,
  51809. /** Type of device */
  51810. deviceType: DeviceType,
  51811. /** "Slot" or index that device is referenced in */
  51812. deviceSlot?: number);
  51813. /**
  51814. * Get input for specific input
  51815. * @param inputIndex index of specific input on device
  51816. * @returns Input value from DeviceInputSystem
  51817. */
  51818. getInput(inputIndex: DeviceInput<T>): number;
  51819. }
  51820. /**
  51821. * Class to keep track of devices
  51822. */
  51823. export class DeviceSourceManager implements IDisposable {
  51824. /**
  51825. * Observable to be triggered when before a device is connected
  51826. */
  51827. readonly onBeforeDeviceConnectedObservable: Observable<{
  51828. deviceType: DeviceType;
  51829. deviceSlot: number;
  51830. }>;
  51831. /**
  51832. * Observable to be triggered when before a device is disconnected
  51833. */
  51834. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51835. deviceType: DeviceType;
  51836. deviceSlot: number;
  51837. }>;
  51838. /**
  51839. * Observable to be triggered when after a device is connected
  51840. */
  51841. readonly onAfterDeviceConnectedObservable: Observable<{
  51842. deviceType: DeviceType;
  51843. deviceSlot: number;
  51844. }>;
  51845. /**
  51846. * Observable to be triggered when after a device is disconnected
  51847. */
  51848. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51849. deviceType: DeviceType;
  51850. deviceSlot: number;
  51851. }>;
  51852. private readonly _devices;
  51853. private readonly _firstDevice;
  51854. private readonly _deviceInputSystem;
  51855. /**
  51856. * Default Constructor
  51857. * @param engine engine to pull input element from
  51858. */
  51859. constructor(engine: Engine);
  51860. /**
  51861. * Gets a DeviceSource, given a type and slot
  51862. * @param deviceType Enum specifying device type
  51863. * @param deviceSlot "Slot" or index that device is referenced in
  51864. * @returns DeviceSource object
  51865. */
  51866. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51867. /**
  51868. * Gets an array of DeviceSource objects for a given device type
  51869. * @param deviceType Enum specifying device type
  51870. * @returns Array of DeviceSource objects
  51871. */
  51872. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51873. /**
  51874. * Dispose of DeviceInputSystem and other parts
  51875. */
  51876. dispose(): void;
  51877. /**
  51878. * Function to add device name to device list
  51879. * @param deviceType Enum specifying device type
  51880. * @param deviceSlot "Slot" or index that device is referenced in
  51881. */
  51882. private _addDevice;
  51883. /**
  51884. * Function to remove device name to device list
  51885. * @param deviceType Enum specifying device type
  51886. * @param deviceSlot "Slot" or index that device is referenced in
  51887. */
  51888. private _removeDevice;
  51889. /**
  51890. * Updates array storing first connected device of each type
  51891. * @param type Type of Device
  51892. */
  51893. private _updateFirstDevices;
  51894. }
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * Options to create the null engine
  51899. */
  51900. export class NullEngineOptions {
  51901. /**
  51902. * Render width (Default: 512)
  51903. */
  51904. renderWidth: number;
  51905. /**
  51906. * Render height (Default: 256)
  51907. */
  51908. renderHeight: number;
  51909. /**
  51910. * Texture size (Default: 512)
  51911. */
  51912. textureSize: number;
  51913. /**
  51914. * If delta time between frames should be constant
  51915. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51916. */
  51917. deterministicLockstep: boolean;
  51918. /**
  51919. * Maximum about of steps between frames (Default: 4)
  51920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51921. */
  51922. lockstepMaxSteps: number;
  51923. /**
  51924. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51925. */
  51926. useHighPrecisionMatrix?: boolean;
  51927. }
  51928. /**
  51929. * The null engine class provides support for headless version of babylon.js.
  51930. * This can be used in server side scenario or for testing purposes
  51931. */
  51932. export class NullEngine extends Engine {
  51933. private _options;
  51934. /**
  51935. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51937. * @returns true if engine is in deterministic lock step mode
  51938. */
  51939. isDeterministicLockStep(): boolean;
  51940. /**
  51941. * Gets the max steps when engine is running in deterministic lock step
  51942. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51943. * @returns the max steps
  51944. */
  51945. getLockstepMaxSteps(): number;
  51946. /**
  51947. * Gets the current hardware scaling level.
  51948. * By default the hardware scaling level is computed from the window device ratio.
  51949. * 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.
  51950. * @returns a number indicating the current hardware scaling level
  51951. */
  51952. getHardwareScalingLevel(): number;
  51953. constructor(options?: NullEngineOptions);
  51954. /**
  51955. * Creates a vertex buffer
  51956. * @param vertices the data for the vertex buffer
  51957. * @returns the new WebGL static buffer
  51958. */
  51959. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51960. /**
  51961. * Creates a new index buffer
  51962. * @param indices defines the content of the index buffer
  51963. * @param updatable defines if the index buffer must be updatable
  51964. * @returns a new webGL buffer
  51965. */
  51966. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51967. /**
  51968. * Clear the current render buffer or the current render target (if any is set up)
  51969. * @param color defines the color to use
  51970. * @param backBuffer defines if the back buffer must be cleared
  51971. * @param depth defines if the depth buffer must be cleared
  51972. * @param stencil defines if the stencil buffer must be cleared
  51973. */
  51974. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51975. /**
  51976. * Gets the current render width
  51977. * @param useScreen defines if screen size must be used (or the current render target if any)
  51978. * @returns a number defining the current render width
  51979. */
  51980. getRenderWidth(useScreen?: boolean): number;
  51981. /**
  51982. * Gets the current render height
  51983. * @param useScreen defines if screen size must be used (or the current render target if any)
  51984. * @returns a number defining the current render height
  51985. */
  51986. getRenderHeight(useScreen?: boolean): number;
  51987. /**
  51988. * Set the WebGL's viewport
  51989. * @param viewport defines the viewport element to be used
  51990. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51991. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51992. */
  51993. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51994. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51995. /**
  51996. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51997. * @param pipelineContext defines the pipeline context to use
  51998. * @param uniformsNames defines the list of uniform names
  51999. * @returns an array of webGL uniform locations
  52000. */
  52001. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52002. /**
  52003. * Gets the lsit of active attributes for a given webGL program
  52004. * @param pipelineContext defines the pipeline context to use
  52005. * @param attributesNames defines the list of attribute names to get
  52006. * @returns an array of indices indicating the offset of each attribute
  52007. */
  52008. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52009. /**
  52010. * Binds an effect to the webGL context
  52011. * @param effect defines the effect to bind
  52012. */
  52013. bindSamplers(effect: Effect): void;
  52014. /**
  52015. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52016. * @param effect defines the effect to activate
  52017. */
  52018. enableEffect(effect: Effect): void;
  52019. /**
  52020. * Set various states to the webGL context
  52021. * @param culling defines backface culling state
  52022. * @param zOffset defines the value to apply to zOffset (0 by default)
  52023. * @param force defines if states must be applied even if cache is up to date
  52024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52025. */
  52026. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52027. /**
  52028. * Set the value of an uniform to an array of int32
  52029. * @param uniform defines the webGL uniform location where to store the value
  52030. * @param array defines the array of int32 to store
  52031. */
  52032. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52033. /**
  52034. * Set the value of an uniform to an array of int32 (stored as vec2)
  52035. * @param uniform defines the webGL uniform location where to store the value
  52036. * @param array defines the array of int32 to store
  52037. */
  52038. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52039. /**
  52040. * Set the value of an uniform to an array of int32 (stored as vec3)
  52041. * @param uniform defines the webGL uniform location where to store the value
  52042. * @param array defines the array of int32 to store
  52043. */
  52044. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52045. /**
  52046. * Set the value of an uniform to an array of int32 (stored as vec4)
  52047. * @param uniform defines the webGL uniform location where to store the value
  52048. * @param array defines the array of int32 to store
  52049. */
  52050. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52051. /**
  52052. * Set the value of an uniform to an array of float32
  52053. * @param uniform defines the webGL uniform location where to store the value
  52054. * @param array defines the array of float32 to store
  52055. */
  52056. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52057. /**
  52058. * Set the value of an uniform to an array of float32 (stored as vec2)
  52059. * @param uniform defines the webGL uniform location where to store the value
  52060. * @param array defines the array of float32 to store
  52061. */
  52062. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52063. /**
  52064. * Set the value of an uniform to an array of float32 (stored as vec3)
  52065. * @param uniform defines the webGL uniform location where to store the value
  52066. * @param array defines the array of float32 to store
  52067. */
  52068. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52069. /**
  52070. * Set the value of an uniform to an array of float32 (stored as vec4)
  52071. * @param uniform defines the webGL uniform location where to store the value
  52072. * @param array defines the array of float32 to store
  52073. */
  52074. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52075. /**
  52076. * Set the value of an uniform to an array of number
  52077. * @param uniform defines the webGL uniform location where to store the value
  52078. * @param array defines the array of number to store
  52079. */
  52080. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52081. /**
  52082. * Set the value of an uniform to an array of number (stored as vec2)
  52083. * @param uniform defines the webGL uniform location where to store the value
  52084. * @param array defines the array of number to store
  52085. */
  52086. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52087. /**
  52088. * Set the value of an uniform to an array of number (stored as vec3)
  52089. * @param uniform defines the webGL uniform location where to store the value
  52090. * @param array defines the array of number to store
  52091. */
  52092. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52093. /**
  52094. * Set the value of an uniform to an array of number (stored as vec4)
  52095. * @param uniform defines the webGL uniform location where to store the value
  52096. * @param array defines the array of number to store
  52097. */
  52098. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52099. /**
  52100. * Set the value of an uniform to an array of float32 (stored as matrices)
  52101. * @param uniform defines the webGL uniform location where to store the value
  52102. * @param matrices defines the array of float32 to store
  52103. */
  52104. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52105. /**
  52106. * Set the value of an uniform to a matrix (3x3)
  52107. * @param uniform defines the webGL uniform location where to store the value
  52108. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52109. */
  52110. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52111. /**
  52112. * Set the value of an uniform to a matrix (2x2)
  52113. * @param uniform defines the webGL uniform location where to store the value
  52114. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52115. */
  52116. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52117. /**
  52118. * Set the value of an uniform to a number (float)
  52119. * @param uniform defines the webGL uniform location where to store the value
  52120. * @param value defines the float number to store
  52121. */
  52122. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52123. /**
  52124. * Set the value of an uniform to a vec2
  52125. * @param uniform defines the webGL uniform location where to store the value
  52126. * @param x defines the 1st component of the value
  52127. * @param y defines the 2nd component of the value
  52128. */
  52129. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52130. /**
  52131. * Set the value of an uniform to a vec3
  52132. * @param uniform defines the webGL uniform location where to store the value
  52133. * @param x defines the 1st component of the value
  52134. * @param y defines the 2nd component of the value
  52135. * @param z defines the 3rd component of the value
  52136. */
  52137. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52138. /**
  52139. * Set the value of an uniform to a boolean
  52140. * @param uniform defines the webGL uniform location where to store the value
  52141. * @param bool defines the boolean to store
  52142. */
  52143. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52144. /**
  52145. * Set the value of an uniform to a vec4
  52146. * @param uniform defines the webGL uniform location where to store the value
  52147. * @param x defines the 1st component of the value
  52148. * @param y defines the 2nd component of the value
  52149. * @param z defines the 3rd component of the value
  52150. * @param w defines the 4th component of the value
  52151. */
  52152. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52153. /**
  52154. * Sets the current alpha mode
  52155. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52156. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52157. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52158. */
  52159. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52160. /**
  52161. * Bind webGl buffers directly to the webGL context
  52162. * @param vertexBuffers defines the vertex buffer to bind
  52163. * @param indexBuffer defines the index buffer to bind
  52164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52166. * @param effect defines the effect associated with the vertex buffer
  52167. */
  52168. bindBuffers(vertexBuffers: {
  52169. [key: string]: VertexBuffer;
  52170. }, indexBuffer: DataBuffer, effect: Effect): void;
  52171. /**
  52172. * Force the entire cache to be cleared
  52173. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52174. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52175. */
  52176. wipeCaches(bruteForce?: boolean): void;
  52177. /**
  52178. * Send a draw order
  52179. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52180. * @param indexStart defines the starting index
  52181. * @param indexCount defines the number of index to draw
  52182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52183. */
  52184. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52185. /**
  52186. * Draw a list of indexed primitives
  52187. * @param fillMode defines the primitive to use
  52188. * @param indexStart defines the starting index
  52189. * @param indexCount defines the number of index to draw
  52190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52191. */
  52192. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52193. /**
  52194. * Draw a list of unindexed primitives
  52195. * @param fillMode defines the primitive to use
  52196. * @param verticesStart defines the index of first vertex to draw
  52197. * @param verticesCount defines the count of vertices to draw
  52198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52199. */
  52200. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52201. /** @hidden */
  52202. _createTexture(): WebGLTexture;
  52203. /** @hidden */
  52204. _releaseTexture(texture: InternalTexture): void;
  52205. /**
  52206. * Usually called from Texture.ts.
  52207. * Passed information to create a WebGLTexture
  52208. * @param urlArg defines a value which contains one of the following:
  52209. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52210. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52211. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52212. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52213. * @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)
  52214. * @param scene needed for loading to the correct scene
  52215. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52216. * @param onLoad optional callback to be called upon successful completion
  52217. * @param onError optional callback to be called upon failure
  52218. * @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
  52219. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52220. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52221. * @param forcedExtension defines the extension to use to pick the right loader
  52222. * @param mimeType defines an optional mime type
  52223. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52224. */
  52225. 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;
  52226. /**
  52227. * Creates a new render target texture
  52228. * @param size defines the size of the texture
  52229. * @param options defines the options used to create the texture
  52230. * @returns a new render target texture stored in an InternalTexture
  52231. */
  52232. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52233. /**
  52234. * Update the sampling mode of a given texture
  52235. * @param samplingMode defines the required sampling mode
  52236. * @param texture defines the texture to update
  52237. */
  52238. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52239. /**
  52240. * Binds the frame buffer to the specified texture.
  52241. * @param texture The texture to render to or null for the default canvas
  52242. * @param faceIndex The face of the texture to render to in case of cube texture
  52243. * @param requiredWidth The width of the target to render to
  52244. * @param requiredHeight The height of the target to render to
  52245. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52246. * @param lodLevel defines le lod level to bind to the frame buffer
  52247. */
  52248. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52249. /**
  52250. * Unbind the current render target texture from the webGL context
  52251. * @param texture defines the render target texture to unbind
  52252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52254. */
  52255. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52256. /**
  52257. * Creates a dynamic vertex buffer
  52258. * @param vertices the data for the dynamic vertex buffer
  52259. * @returns the new WebGL dynamic buffer
  52260. */
  52261. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52262. /**
  52263. * Update the content of a dynamic texture
  52264. * @param texture defines the texture to update
  52265. * @param canvas defines the canvas containing the source
  52266. * @param invertY defines if data must be stored with Y axis inverted
  52267. * @param premulAlpha defines if alpha is stored as premultiplied
  52268. * @param format defines the format of the data
  52269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52270. */
  52271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52272. /**
  52273. * Gets a boolean indicating if all created effects are ready
  52274. * @returns true if all effects are ready
  52275. */
  52276. areAllEffectsReady(): boolean;
  52277. /**
  52278. * @hidden
  52279. * Get the current error code of the webGL context
  52280. * @returns the error code
  52281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52282. */
  52283. getError(): number;
  52284. /** @hidden */
  52285. _getUnpackAlignement(): number;
  52286. /** @hidden */
  52287. _unpackFlipY(value: boolean): void;
  52288. /**
  52289. * Update a dynamic index buffer
  52290. * @param indexBuffer defines the target index buffer
  52291. * @param indices defines the data to update
  52292. * @param offset defines the offset in the target index buffer where update should start
  52293. */
  52294. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52295. /**
  52296. * Updates a dynamic vertex buffer.
  52297. * @param vertexBuffer the vertex buffer to update
  52298. * @param vertices the data used to update the vertex buffer
  52299. * @param byteOffset the byte offset of the data (optional)
  52300. * @param byteLength the byte length of the data (optional)
  52301. */
  52302. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52303. /** @hidden */
  52304. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52305. /** @hidden */
  52306. _bindTexture(channel: number, texture: InternalTexture): void;
  52307. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52308. /**
  52309. * 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
  52310. */
  52311. releaseEffects(): void;
  52312. displayLoadingUI(): void;
  52313. hideLoadingUI(): void;
  52314. /** @hidden */
  52315. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52316. /** @hidden */
  52317. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52318. /** @hidden */
  52319. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52320. /** @hidden */
  52321. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52322. }
  52323. }
  52324. declare module BABYLON {
  52325. /**
  52326. * @hidden
  52327. **/
  52328. export class _TimeToken {
  52329. _startTimeQuery: Nullable<WebGLQuery>;
  52330. _endTimeQuery: Nullable<WebGLQuery>;
  52331. _timeElapsedQuery: Nullable<WebGLQuery>;
  52332. _timeElapsedQueryEnded: boolean;
  52333. }
  52334. }
  52335. declare module BABYLON {
  52336. /** @hidden */
  52337. export class _OcclusionDataStorage {
  52338. /** @hidden */
  52339. occlusionInternalRetryCounter: number;
  52340. /** @hidden */
  52341. isOcclusionQueryInProgress: boolean;
  52342. /** @hidden */
  52343. isOccluded: boolean;
  52344. /** @hidden */
  52345. occlusionRetryCount: number;
  52346. /** @hidden */
  52347. occlusionType: number;
  52348. /** @hidden */
  52349. occlusionQueryAlgorithmType: number;
  52350. }
  52351. interface Engine {
  52352. /**
  52353. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52354. * @return the new query
  52355. */
  52356. createQuery(): WebGLQuery;
  52357. /**
  52358. * Delete and release a webGL query
  52359. * @param query defines the query to delete
  52360. * @return the current engine
  52361. */
  52362. deleteQuery(query: WebGLQuery): Engine;
  52363. /**
  52364. * Check if a given query has resolved and got its value
  52365. * @param query defines the query to check
  52366. * @returns true if the query got its value
  52367. */
  52368. isQueryResultAvailable(query: WebGLQuery): boolean;
  52369. /**
  52370. * Gets the value of a given query
  52371. * @param query defines the query to check
  52372. * @returns the value of the query
  52373. */
  52374. getQueryResult(query: WebGLQuery): number;
  52375. /**
  52376. * Initiates an occlusion query
  52377. * @param algorithmType defines the algorithm to use
  52378. * @param query defines the query to use
  52379. * @returns the current engine
  52380. * @see https://doc.babylonjs.com/features/occlusionquery
  52381. */
  52382. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52383. /**
  52384. * Ends an occlusion query
  52385. * @see https://doc.babylonjs.com/features/occlusionquery
  52386. * @param algorithmType defines the algorithm to use
  52387. * @returns the current engine
  52388. */
  52389. endOcclusionQuery(algorithmType: number): Engine;
  52390. /**
  52391. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52392. * Please note that only one query can be issued at a time
  52393. * @returns a time token used to track the time span
  52394. */
  52395. startTimeQuery(): Nullable<_TimeToken>;
  52396. /**
  52397. * Ends a time query
  52398. * @param token defines the token used to measure the time span
  52399. * @returns the time spent (in ns)
  52400. */
  52401. endTimeQuery(token: _TimeToken): int;
  52402. /** @hidden */
  52403. _currentNonTimestampToken: Nullable<_TimeToken>;
  52404. /** @hidden */
  52405. _createTimeQuery(): WebGLQuery;
  52406. /** @hidden */
  52407. _deleteTimeQuery(query: WebGLQuery): void;
  52408. /** @hidden */
  52409. _getGlAlgorithmType(algorithmType: number): number;
  52410. /** @hidden */
  52411. _getTimeQueryResult(query: WebGLQuery): any;
  52412. /** @hidden */
  52413. _getTimeQueryAvailability(query: WebGLQuery): any;
  52414. }
  52415. interface AbstractMesh {
  52416. /**
  52417. * Backing filed
  52418. * @hidden
  52419. */
  52420. __occlusionDataStorage: _OcclusionDataStorage;
  52421. /**
  52422. * Access property
  52423. * @hidden
  52424. */
  52425. _occlusionDataStorage: _OcclusionDataStorage;
  52426. /**
  52427. * 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.
  52428. * The default value is -1 which means don't break the query and wait till the result
  52429. * @see https://doc.babylonjs.com/features/occlusionquery
  52430. */
  52431. occlusionRetryCount: number;
  52432. /**
  52433. * 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:
  52434. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52435. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52436. * * 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.
  52437. * @see https://doc.babylonjs.com/features/occlusionquery
  52438. */
  52439. occlusionType: number;
  52440. /**
  52441. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52442. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52443. * * 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.
  52444. * @see https://doc.babylonjs.com/features/occlusionquery
  52445. */
  52446. occlusionQueryAlgorithmType: number;
  52447. /**
  52448. * 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
  52449. * @see https://doc.babylonjs.com/features/occlusionquery
  52450. */
  52451. isOccluded: boolean;
  52452. /**
  52453. * Flag to check the progress status of the query
  52454. * @see https://doc.babylonjs.com/features/occlusionquery
  52455. */
  52456. isOcclusionQueryInProgress: boolean;
  52457. }
  52458. }
  52459. declare module BABYLON {
  52460. /** @hidden */
  52461. export var _forceTransformFeedbackToBundle: boolean;
  52462. interface Engine {
  52463. /**
  52464. * Creates a webGL transform feedback object
  52465. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52466. * @returns the webGL transform feedback object
  52467. */
  52468. createTransformFeedback(): WebGLTransformFeedback;
  52469. /**
  52470. * Delete a webGL transform feedback object
  52471. * @param value defines the webGL transform feedback object to delete
  52472. */
  52473. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52474. /**
  52475. * Bind a webGL transform feedback object to the webgl context
  52476. * @param value defines the webGL transform feedback object to bind
  52477. */
  52478. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52479. /**
  52480. * Begins a transform feedback operation
  52481. * @param usePoints defines if points or triangles must be used
  52482. */
  52483. beginTransformFeedback(usePoints: boolean): void;
  52484. /**
  52485. * Ends a transform feedback operation
  52486. */
  52487. endTransformFeedback(): void;
  52488. /**
  52489. * Specify the varyings to use with transform feedback
  52490. * @param program defines the associated webGL program
  52491. * @param value defines the list of strings representing the varying names
  52492. */
  52493. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52494. /**
  52495. * Bind a webGL buffer for a transform feedback operation
  52496. * @param value defines the webGL buffer to bind
  52497. */
  52498. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * Class used to define an additional view for the engine
  52504. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52505. */
  52506. export class EngineView {
  52507. /** Defines the canvas where to render the view */
  52508. target: HTMLCanvasElement;
  52509. /** Defines an optional camera used to render the view (will use active camera else) */
  52510. camera?: Camera;
  52511. }
  52512. interface Engine {
  52513. /**
  52514. * Gets or sets the HTML element to use for attaching events
  52515. */
  52516. inputElement: Nullable<HTMLElement>;
  52517. /**
  52518. * Gets the current engine view
  52519. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52520. */
  52521. activeView: Nullable<EngineView>;
  52522. /** Gets or sets the list of views */
  52523. views: EngineView[];
  52524. /**
  52525. * Register a new child canvas
  52526. * @param canvas defines the canvas to register
  52527. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52528. * @returns the associated view
  52529. */
  52530. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52531. /**
  52532. * Remove a registered child canvas
  52533. * @param canvas defines the canvas to remove
  52534. * @returns the current engine
  52535. */
  52536. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52537. }
  52538. }
  52539. declare module BABYLON {
  52540. interface Engine {
  52541. /** @hidden */
  52542. _excludedCompressedTextures: string[];
  52543. /** @hidden */
  52544. _textureFormatInUse: string;
  52545. /**
  52546. * Gets the list of texture formats supported
  52547. */
  52548. readonly texturesSupported: Array<string>;
  52549. /**
  52550. * Gets the texture format in use
  52551. */
  52552. readonly textureFormatInUse: Nullable<string>;
  52553. /**
  52554. * Set the compressed texture extensions or file names to skip.
  52555. *
  52556. * @param skippedFiles defines the list of those texture files you want to skip
  52557. * Example: [".dds", ".env", "myfile.png"]
  52558. */
  52559. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52560. /**
  52561. * Set the compressed texture format to use, based on the formats you have, and the formats
  52562. * supported by the hardware / browser.
  52563. *
  52564. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52565. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52566. * to API arguments needed to compressed textures. This puts the burden on the container
  52567. * generator to house the arcane code for determining these for current & future formats.
  52568. *
  52569. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52570. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52571. *
  52572. * Note: The result of this call is not taken into account when a texture is base64.
  52573. *
  52574. * @param formatsAvailable defines the list of those format families you have created
  52575. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52576. *
  52577. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52578. * @returns The extension selected.
  52579. */
  52580. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52581. }
  52582. }
  52583. declare module BABYLON {
  52584. /**
  52585. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52586. */
  52587. export interface CubeMapInfo {
  52588. /**
  52589. * The pixel array for the front face.
  52590. * This is stored in format, left to right, up to down format.
  52591. */
  52592. front: Nullable<ArrayBufferView>;
  52593. /**
  52594. * The pixel array for the back face.
  52595. * This is stored in format, left to right, up to down format.
  52596. */
  52597. back: Nullable<ArrayBufferView>;
  52598. /**
  52599. * The pixel array for the left face.
  52600. * This is stored in format, left to right, up to down format.
  52601. */
  52602. left: Nullable<ArrayBufferView>;
  52603. /**
  52604. * The pixel array for the right face.
  52605. * This is stored in format, left to right, up to down format.
  52606. */
  52607. right: Nullable<ArrayBufferView>;
  52608. /**
  52609. * The pixel array for the up face.
  52610. * This is stored in format, left to right, up to down format.
  52611. */
  52612. up: Nullable<ArrayBufferView>;
  52613. /**
  52614. * The pixel array for the down face.
  52615. * This is stored in format, left to right, up to down format.
  52616. */
  52617. down: Nullable<ArrayBufferView>;
  52618. /**
  52619. * The size of the cubemap stored.
  52620. *
  52621. * Each faces will be size * size pixels.
  52622. */
  52623. size: number;
  52624. /**
  52625. * The format of the texture.
  52626. *
  52627. * RGBA, RGB.
  52628. */
  52629. format: number;
  52630. /**
  52631. * The type of the texture data.
  52632. *
  52633. * UNSIGNED_INT, FLOAT.
  52634. */
  52635. type: number;
  52636. /**
  52637. * Specifies whether the texture is in gamma space.
  52638. */
  52639. gammaSpace: boolean;
  52640. }
  52641. /**
  52642. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52643. */
  52644. export class PanoramaToCubeMapTools {
  52645. private static FACE_LEFT;
  52646. private static FACE_RIGHT;
  52647. private static FACE_FRONT;
  52648. private static FACE_BACK;
  52649. private static FACE_DOWN;
  52650. private static FACE_UP;
  52651. /**
  52652. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52653. *
  52654. * @param float32Array The source data.
  52655. * @param inputWidth The width of the input panorama.
  52656. * @param inputHeight The height of the input panorama.
  52657. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52658. * @return The cubemap data
  52659. */
  52660. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52661. private static CreateCubemapTexture;
  52662. private static CalcProjectionSpherical;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Helper class dealing with the extraction of spherical polynomial dataArray
  52668. * from a cube map.
  52669. */
  52670. export class CubeMapToSphericalPolynomialTools {
  52671. private static FileFaces;
  52672. /**
  52673. * Converts a texture to the according Spherical Polynomial data.
  52674. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52675. *
  52676. * @param texture The texture to extract the information from.
  52677. * @return The Spherical Polynomial data.
  52678. */
  52679. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52680. /**
  52681. * Converts a cubemap to the according Spherical Polynomial data.
  52682. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52683. *
  52684. * @param cubeInfo The Cube map to extract the information from.
  52685. * @return The Spherical Polynomial data.
  52686. */
  52687. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52688. }
  52689. }
  52690. declare module BABYLON {
  52691. interface BaseTexture {
  52692. /**
  52693. * Get the polynomial representation of the texture data.
  52694. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52695. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52696. */
  52697. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52698. }
  52699. }
  52700. declare module BABYLON {
  52701. /** @hidden */
  52702. export var rgbdEncodePixelShader: {
  52703. name: string;
  52704. shader: string;
  52705. };
  52706. }
  52707. declare module BABYLON {
  52708. /** @hidden */
  52709. export var rgbdDecodePixelShader: {
  52710. name: string;
  52711. shader: string;
  52712. };
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Raw texture data and descriptor sufficient for WebGL texture upload
  52717. */
  52718. export interface EnvironmentTextureInfo {
  52719. /**
  52720. * Version of the environment map
  52721. */
  52722. version: number;
  52723. /**
  52724. * Width of image
  52725. */
  52726. width: number;
  52727. /**
  52728. * Irradiance information stored in the file.
  52729. */
  52730. irradiance: any;
  52731. /**
  52732. * Specular information stored in the file.
  52733. */
  52734. specular: any;
  52735. }
  52736. /**
  52737. * Defines One Image in the file. It requires only the position in the file
  52738. * as well as the length.
  52739. */
  52740. interface BufferImageData {
  52741. /**
  52742. * Length of the image data.
  52743. */
  52744. length: number;
  52745. /**
  52746. * Position of the data from the null terminator delimiting the end of the JSON.
  52747. */
  52748. position: number;
  52749. }
  52750. /**
  52751. * Defines the specular data enclosed in the file.
  52752. * This corresponds to the version 1 of the data.
  52753. */
  52754. export interface EnvironmentTextureSpecularInfoV1 {
  52755. /**
  52756. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52757. */
  52758. specularDataPosition?: number;
  52759. /**
  52760. * This contains all the images data needed to reconstruct the cubemap.
  52761. */
  52762. mipmaps: Array<BufferImageData>;
  52763. /**
  52764. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52765. */
  52766. lodGenerationScale: number;
  52767. }
  52768. /**
  52769. * Sets of helpers addressing the serialization and deserialization of environment texture
  52770. * stored in a BabylonJS env file.
  52771. * Those files are usually stored as .env files.
  52772. */
  52773. export class EnvironmentTextureTools {
  52774. /**
  52775. * Magic number identifying the env file.
  52776. */
  52777. private static _MagicBytes;
  52778. /**
  52779. * Gets the environment info from an env file.
  52780. * @param data The array buffer containing the .env bytes.
  52781. * @returns the environment file info (the json header) if successfully parsed.
  52782. */
  52783. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52784. /**
  52785. * Creates an environment texture from a loaded cube texture.
  52786. * @param texture defines the cube texture to convert in env file
  52787. * @return a promise containing the environment data if succesfull.
  52788. */
  52789. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52790. /**
  52791. * Creates a JSON representation of the spherical data.
  52792. * @param texture defines the texture containing the polynomials
  52793. * @return the JSON representation of the spherical info
  52794. */
  52795. private static _CreateEnvTextureIrradiance;
  52796. /**
  52797. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52798. * @param data the image data
  52799. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52800. * @return the views described by info providing access to the underlying buffer
  52801. */
  52802. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52803. /**
  52804. * Uploads the texture info contained in the env file to the GPU.
  52805. * @param texture defines the internal texture to upload to
  52806. * @param data defines the data to load
  52807. * @param info defines the texture info retrieved through the GetEnvInfo method
  52808. * @returns a promise
  52809. */
  52810. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52811. private static _OnImageReadyAsync;
  52812. /**
  52813. * Uploads the levels of image data to the GPU.
  52814. * @param texture defines the internal texture to upload to
  52815. * @param imageData defines the array buffer views of image data [mipmap][face]
  52816. * @returns a promise
  52817. */
  52818. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52819. /**
  52820. * Uploads spherical polynomials information to the texture.
  52821. * @param texture defines the texture we are trying to upload the information to
  52822. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52823. */
  52824. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52825. /** @hidden */
  52826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52827. }
  52828. }
  52829. declare module BABYLON {
  52830. /**
  52831. * Class used to inline functions in shader code
  52832. */
  52833. export class ShaderCodeInliner {
  52834. private static readonly _RegexpFindFunctionNameAndType;
  52835. private _sourceCode;
  52836. private _functionDescr;
  52837. private _numMaxIterations;
  52838. /** Gets or sets the token used to mark the functions to inline */
  52839. inlineToken: string;
  52840. /** Gets or sets the debug mode */
  52841. debug: boolean;
  52842. /** Gets the code after the inlining process */
  52843. get code(): string;
  52844. /**
  52845. * Initializes the inliner
  52846. * @param sourceCode shader code source to inline
  52847. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52848. */
  52849. constructor(sourceCode: string, numMaxIterations?: number);
  52850. /**
  52851. * Start the processing of the shader code
  52852. */
  52853. processCode(): void;
  52854. private _collectFunctions;
  52855. private _processInlining;
  52856. private _extractBetweenMarkers;
  52857. private _skipWhitespaces;
  52858. private _removeComments;
  52859. private _replaceFunctionCallsByCode;
  52860. private _findBackward;
  52861. private _escapeRegExp;
  52862. private _replaceNames;
  52863. }
  52864. }
  52865. declare module BABYLON {
  52866. /**
  52867. * Container for accessors for natively-stored mesh data buffers.
  52868. */
  52869. class NativeDataBuffer extends DataBuffer {
  52870. /**
  52871. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52872. */
  52873. nativeIndexBuffer?: any;
  52874. /**
  52875. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52876. */
  52877. nativeVertexBuffer?: any;
  52878. }
  52879. /** @hidden */
  52880. class NativeTexture extends InternalTexture {
  52881. getInternalTexture(): InternalTexture;
  52882. getViewCount(): number;
  52883. }
  52884. /** @hidden */
  52885. export class NativeEngine extends Engine {
  52886. private readonly _native;
  52887. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52888. private readonly INVALID_HANDLE;
  52889. private _boundBuffersVertexArray;
  52890. getHardwareScalingLevel(): number;
  52891. constructor();
  52892. dispose(): void;
  52893. /**
  52894. * Can be used to override the current requestAnimationFrame requester.
  52895. * @hidden
  52896. */
  52897. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52898. /**
  52899. * Override default engine behavior.
  52900. * @param color
  52901. * @param backBuffer
  52902. * @param depth
  52903. * @param stencil
  52904. */
  52905. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52906. /**
  52907. * Gets host document
  52908. * @returns the host document object
  52909. */
  52910. getHostDocument(): Nullable<Document>;
  52911. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52912. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52913. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52914. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52915. [key: string]: VertexBuffer;
  52916. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52917. bindBuffers(vertexBuffers: {
  52918. [key: string]: VertexBuffer;
  52919. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52920. recordVertexArrayObject(vertexBuffers: {
  52921. [key: string]: VertexBuffer;
  52922. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52923. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52924. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52925. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52926. /**
  52927. * Draw a list of indexed primitives
  52928. * @param fillMode defines the primitive to use
  52929. * @param indexStart defines the starting index
  52930. * @param indexCount defines the number of index to draw
  52931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52932. */
  52933. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52934. /**
  52935. * Draw a list of unindexed primitives
  52936. * @param fillMode defines the primitive to use
  52937. * @param verticesStart defines the index of first vertex to draw
  52938. * @param verticesCount defines the count of vertices to draw
  52939. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52940. */
  52941. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52942. createPipelineContext(): IPipelineContext;
  52943. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52944. /** @hidden */
  52945. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52946. /** @hidden */
  52947. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52948. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52949. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52950. protected _setProgram(program: WebGLProgram): void;
  52951. _releaseEffect(effect: Effect): void;
  52952. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52953. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52954. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52955. bindSamplers(effect: Effect): void;
  52956. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52957. getRenderWidth(useScreen?: boolean): number;
  52958. getRenderHeight(useScreen?: boolean): number;
  52959. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52960. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52961. /**
  52962. * Set the z offset to apply to current rendering
  52963. * @param value defines the offset to apply
  52964. */
  52965. setZOffset(value: number): void;
  52966. /**
  52967. * Gets the current value of the zOffset
  52968. * @returns the current zOffset state
  52969. */
  52970. getZOffset(): number;
  52971. /**
  52972. * Enable or disable depth buffering
  52973. * @param enable defines the state to set
  52974. */
  52975. setDepthBuffer(enable: boolean): void;
  52976. /**
  52977. * Gets a boolean indicating if depth writing is enabled
  52978. * @returns the current depth writing state
  52979. */
  52980. getDepthWrite(): boolean;
  52981. /**
  52982. * Enable or disable depth writing
  52983. * @param enable defines the state to set
  52984. */
  52985. setDepthWrite(enable: boolean): void;
  52986. /**
  52987. * Enable or disable color writing
  52988. * @param enable defines the state to set
  52989. */
  52990. setColorWrite(enable: boolean): void;
  52991. /**
  52992. * Gets a boolean indicating if color writing is enabled
  52993. * @returns the current color writing state
  52994. */
  52995. getColorWrite(): boolean;
  52996. /**
  52997. * Sets alpha constants used by some alpha blending modes
  52998. * @param r defines the red component
  52999. * @param g defines the green component
  53000. * @param b defines the blue component
  53001. * @param a defines the alpha component
  53002. */
  53003. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53004. /**
  53005. * Sets the current alpha mode
  53006. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53007. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53008. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53009. */
  53010. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53011. /**
  53012. * Gets the current alpha mode
  53013. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53014. * @returns the current alpha mode
  53015. */
  53016. getAlphaMode(): number;
  53017. setInt(uniform: WebGLUniformLocation, int: number): void;
  53018. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53019. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53020. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53021. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53022. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53023. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53024. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53025. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53026. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53027. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53028. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53029. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53030. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53031. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53032. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53033. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53034. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53035. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53036. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53037. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53038. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53039. wipeCaches(bruteForce?: boolean): void;
  53040. _createTexture(): WebGLTexture;
  53041. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53042. /**
  53043. * Usually called from Texture.ts.
  53044. * Passed information to create a WebGLTexture
  53045. * @param url defines a value which contains one of the following:
  53046. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53047. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53048. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53049. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53050. * @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)
  53051. * @param scene needed for loading to the correct scene
  53052. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53053. * @param onLoad optional callback to be called upon successful completion
  53054. * @param onError optional callback to be called upon failure
  53055. * @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
  53056. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53057. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53058. * @param forcedExtension defines the extension to use to pick the right loader
  53059. * @param mimeType defines an optional mime type
  53060. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53061. */
  53062. 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;
  53063. /**
  53064. * Creates a cube texture
  53065. * @param rootUrl defines the url where the files to load is located
  53066. * @param scene defines the current scene
  53067. * @param files defines the list of files to load (1 per face)
  53068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53069. * @param onLoad defines an optional callback raised when the texture is loaded
  53070. * @param onError defines an optional callback raised if there is an issue to load the texture
  53071. * @param format defines the format of the data
  53072. * @param forcedExtension defines the extension to use to pick the right loader
  53073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53076. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53077. * @returns the cube texture as an InternalTexture
  53078. */
  53079. 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;
  53080. private _getSamplingFilter;
  53081. private static _GetNativeTextureFormat;
  53082. createRenderTargetTexture(size: number | {
  53083. width: number;
  53084. height: number;
  53085. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53087. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53089. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53090. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53091. /**
  53092. * Updates a dynamic vertex buffer.
  53093. * @param vertexBuffer the vertex buffer to update
  53094. * @param data the data used to update the vertex buffer
  53095. * @param byteOffset the byte offset of the data (optional)
  53096. * @param byteLength the byte length of the data (optional)
  53097. */
  53098. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53099. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53100. private _updateAnisotropicLevel;
  53101. private _getAddressMode;
  53102. /** @hidden */
  53103. _bindTexture(channel: number, texture: InternalTexture): void;
  53104. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53105. releaseEffects(): void;
  53106. /** @hidden */
  53107. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53108. /** @hidden */
  53109. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53110. /** @hidden */
  53111. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53112. /** @hidden */
  53113. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * Gather the list of clipboard event types as constants.
  53119. */
  53120. export class ClipboardEventTypes {
  53121. /**
  53122. * The clipboard event is fired when a copy command is active (pressed).
  53123. */
  53124. static readonly COPY: number;
  53125. /**
  53126. * The clipboard event is fired when a cut command is active (pressed).
  53127. */
  53128. static readonly CUT: number;
  53129. /**
  53130. * The clipboard event is fired when a paste command is active (pressed).
  53131. */
  53132. static readonly PASTE: number;
  53133. }
  53134. /**
  53135. * This class is used to store clipboard related info for the onClipboardObservable event.
  53136. */
  53137. export class ClipboardInfo {
  53138. /**
  53139. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53140. */
  53141. type: number;
  53142. /**
  53143. * Defines the related dom event
  53144. */
  53145. event: ClipboardEvent;
  53146. /**
  53147. *Creates an instance of ClipboardInfo.
  53148. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53149. * @param event Defines the related dom event
  53150. */
  53151. constructor(
  53152. /**
  53153. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53154. */
  53155. type: number,
  53156. /**
  53157. * Defines the related dom event
  53158. */
  53159. event: ClipboardEvent);
  53160. /**
  53161. * Get the clipboard event's type from the keycode.
  53162. * @param keyCode Defines the keyCode for the current keyboard event.
  53163. * @return {number}
  53164. */
  53165. static GetTypeFromCharacter(keyCode: number): number;
  53166. }
  53167. }
  53168. declare module BABYLON {
  53169. /**
  53170. * Google Daydream controller
  53171. */
  53172. export class DaydreamController extends WebVRController {
  53173. /**
  53174. * Base Url for the controller model.
  53175. */
  53176. static MODEL_BASE_URL: string;
  53177. /**
  53178. * File name for the controller model.
  53179. */
  53180. static MODEL_FILENAME: string;
  53181. /**
  53182. * Gamepad Id prefix used to identify Daydream Controller.
  53183. */
  53184. static readonly GAMEPAD_ID_PREFIX: string;
  53185. /**
  53186. * Creates a new DaydreamController from a gamepad
  53187. * @param vrGamepad the gamepad that the controller should be created from
  53188. */
  53189. constructor(vrGamepad: any);
  53190. /**
  53191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53192. * @param scene scene in which to add meshes
  53193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53194. */
  53195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53196. /**
  53197. * Called once for each button that changed state since the last frame
  53198. * @param buttonIdx Which button index changed
  53199. * @param state New state of the button
  53200. * @param changes Which properties on the state changed since last frame
  53201. */
  53202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53203. }
  53204. }
  53205. declare module BABYLON {
  53206. /**
  53207. * Gear VR Controller
  53208. */
  53209. export class GearVRController extends WebVRController {
  53210. /**
  53211. * Base Url for the controller model.
  53212. */
  53213. static MODEL_BASE_URL: string;
  53214. /**
  53215. * File name for the controller model.
  53216. */
  53217. static MODEL_FILENAME: string;
  53218. /**
  53219. * Gamepad Id prefix used to identify this controller.
  53220. */
  53221. static readonly GAMEPAD_ID_PREFIX: string;
  53222. private readonly _buttonIndexToObservableNameMap;
  53223. /**
  53224. * Creates a new GearVRController from a gamepad
  53225. * @param vrGamepad the gamepad that the controller should be created from
  53226. */
  53227. constructor(vrGamepad: any);
  53228. /**
  53229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53230. * @param scene scene in which to add meshes
  53231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53232. */
  53233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53234. /**
  53235. * Called once for each button that changed state since the last frame
  53236. * @param buttonIdx Which button index changed
  53237. * @param state New state of the button
  53238. * @param changes Which properties on the state changed since last frame
  53239. */
  53240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53241. }
  53242. }
  53243. declare module BABYLON {
  53244. /**
  53245. * Generic Controller
  53246. */
  53247. export class GenericController extends WebVRController {
  53248. /**
  53249. * Base Url for the controller model.
  53250. */
  53251. static readonly MODEL_BASE_URL: string;
  53252. /**
  53253. * File name for the controller model.
  53254. */
  53255. static readonly MODEL_FILENAME: string;
  53256. /**
  53257. * Creates a new GenericController from a gamepad
  53258. * @param vrGamepad the gamepad that the controller should be created from
  53259. */
  53260. constructor(vrGamepad: any);
  53261. /**
  53262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53263. * @param scene scene in which to add meshes
  53264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53265. */
  53266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53267. /**
  53268. * Called once for each button that changed state since the last frame
  53269. * @param buttonIdx Which button index changed
  53270. * @param state New state of the button
  53271. * @param changes Which properties on the state changed since last frame
  53272. */
  53273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53274. }
  53275. }
  53276. declare module BABYLON {
  53277. /**
  53278. * Oculus Touch Controller
  53279. */
  53280. export class OculusTouchController extends WebVRController {
  53281. /**
  53282. * Base Url for the controller model.
  53283. */
  53284. static MODEL_BASE_URL: string;
  53285. /**
  53286. * File name for the left controller model.
  53287. */
  53288. static MODEL_LEFT_FILENAME: string;
  53289. /**
  53290. * File name for the right controller model.
  53291. */
  53292. static MODEL_RIGHT_FILENAME: string;
  53293. /**
  53294. * Base Url for the Quest controller model.
  53295. */
  53296. static QUEST_MODEL_BASE_URL: string;
  53297. /**
  53298. * @hidden
  53299. * If the controllers are running on a device that needs the updated Quest controller models
  53300. */
  53301. static _IsQuest: boolean;
  53302. /**
  53303. * Fired when the secondary trigger on this controller is modified
  53304. */
  53305. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53306. /**
  53307. * Fired when the thumb rest on this controller is modified
  53308. */
  53309. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53310. /**
  53311. * Creates a new OculusTouchController from a gamepad
  53312. * @param vrGamepad the gamepad that the controller should be created from
  53313. */
  53314. constructor(vrGamepad: any);
  53315. /**
  53316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53317. * @param scene scene in which to add meshes
  53318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53319. */
  53320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53321. /**
  53322. * Fired when the A button on this controller is modified
  53323. */
  53324. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53325. /**
  53326. * Fired when the B button on this controller is modified
  53327. */
  53328. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53329. /**
  53330. * Fired when the X button on this controller is modified
  53331. */
  53332. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53333. /**
  53334. * Fired when the Y button on this controller is modified
  53335. */
  53336. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53337. /**
  53338. * Called once for each button that changed state since the last frame
  53339. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53340. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53341. * 2) secondary trigger (same)
  53342. * 3) A (right) X (left), touch, pressed = value
  53343. * 4) B / Y
  53344. * 5) thumb rest
  53345. * @param buttonIdx Which button index changed
  53346. * @param state New state of the button
  53347. * @param changes Which properties on the state changed since last frame
  53348. */
  53349. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53350. }
  53351. }
  53352. declare module BABYLON {
  53353. /**
  53354. * Vive Controller
  53355. */
  53356. export class ViveController extends WebVRController {
  53357. /**
  53358. * Base Url for the controller model.
  53359. */
  53360. static MODEL_BASE_URL: string;
  53361. /**
  53362. * File name for the controller model.
  53363. */
  53364. static MODEL_FILENAME: string;
  53365. /**
  53366. * Creates a new ViveController from a gamepad
  53367. * @param vrGamepad the gamepad that the controller should be created from
  53368. */
  53369. constructor(vrGamepad: any);
  53370. /**
  53371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53372. * @param scene scene in which to add meshes
  53373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53374. */
  53375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53376. /**
  53377. * Fired when the left button on this controller is modified
  53378. */
  53379. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53380. /**
  53381. * Fired when the right button on this controller is modified
  53382. */
  53383. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53384. /**
  53385. * Fired when the menu button on this controller is modified
  53386. */
  53387. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53388. /**
  53389. * Called once for each button that changed state since the last frame
  53390. * Vive mapping:
  53391. * 0: touchpad
  53392. * 1: trigger
  53393. * 2: left AND right buttons
  53394. * 3: menu button
  53395. * @param buttonIdx Which button index changed
  53396. * @param state New state of the button
  53397. * @param changes Which properties on the state changed since last frame
  53398. */
  53399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53400. }
  53401. }
  53402. declare module BABYLON {
  53403. /**
  53404. * Defines the WindowsMotionController object that the state of the windows motion controller
  53405. */
  53406. export class WindowsMotionController extends WebVRController {
  53407. /**
  53408. * The base url used to load the left and right controller models
  53409. */
  53410. static MODEL_BASE_URL: string;
  53411. /**
  53412. * The name of the left controller model file
  53413. */
  53414. static MODEL_LEFT_FILENAME: string;
  53415. /**
  53416. * The name of the right controller model file
  53417. */
  53418. static MODEL_RIGHT_FILENAME: string;
  53419. /**
  53420. * The controller name prefix for this controller type
  53421. */
  53422. static readonly GAMEPAD_ID_PREFIX: string;
  53423. /**
  53424. * The controller id pattern for this controller type
  53425. */
  53426. private static readonly GAMEPAD_ID_PATTERN;
  53427. private _loadedMeshInfo;
  53428. protected readonly _mapping: {
  53429. buttons: string[];
  53430. buttonMeshNames: {
  53431. trigger: string;
  53432. menu: string;
  53433. grip: string;
  53434. thumbstick: string;
  53435. trackpad: string;
  53436. };
  53437. buttonObservableNames: {
  53438. trigger: string;
  53439. menu: string;
  53440. grip: string;
  53441. thumbstick: string;
  53442. trackpad: string;
  53443. };
  53444. axisMeshNames: string[];
  53445. pointingPoseMeshName: string;
  53446. };
  53447. /**
  53448. * Fired when the trackpad on this controller is clicked
  53449. */
  53450. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53451. /**
  53452. * Fired when the trackpad on this controller is modified
  53453. */
  53454. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53455. /**
  53456. * The current x and y values of this controller's trackpad
  53457. */
  53458. trackpad: StickValues;
  53459. /**
  53460. * Creates a new WindowsMotionController from a gamepad
  53461. * @param vrGamepad the gamepad that the controller should be created from
  53462. */
  53463. constructor(vrGamepad: any);
  53464. /**
  53465. * Fired when the trigger on this controller is modified
  53466. */
  53467. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53468. /**
  53469. * Fired when the menu button on this controller is modified
  53470. */
  53471. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53472. /**
  53473. * Fired when the grip button on this controller is modified
  53474. */
  53475. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53476. /**
  53477. * Fired when the thumbstick button on this controller is modified
  53478. */
  53479. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53480. /**
  53481. * Fired when the touchpad button on this controller is modified
  53482. */
  53483. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53484. /**
  53485. * Fired when the touchpad values on this controller are modified
  53486. */
  53487. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53488. protected _updateTrackpad(): void;
  53489. /**
  53490. * Called once per frame by the engine.
  53491. */
  53492. update(): void;
  53493. /**
  53494. * Called once for each button that changed state since the last frame
  53495. * @param buttonIdx Which button index changed
  53496. * @param state New state of the button
  53497. * @param changes Which properties on the state changed since last frame
  53498. */
  53499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53500. /**
  53501. * Moves the buttons on the controller mesh based on their current state
  53502. * @param buttonName the name of the button to move
  53503. * @param buttonValue the value of the button which determines the buttons new position
  53504. */
  53505. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53506. /**
  53507. * Moves the axis on the controller mesh based on its current state
  53508. * @param axis the index of the axis
  53509. * @param axisValue the value of the axis which determines the meshes new position
  53510. * @hidden
  53511. */
  53512. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53513. /**
  53514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53515. * @param scene scene in which to add meshes
  53516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53517. */
  53518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53519. /**
  53520. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53521. * can be transformed by button presses and axes values, based on this._mapping.
  53522. *
  53523. * @param scene scene in which the meshes exist
  53524. * @param meshes list of meshes that make up the controller model to process
  53525. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53526. */
  53527. private processModel;
  53528. private createMeshInfo;
  53529. /**
  53530. * Gets the ray of the controller in the direction the controller is pointing
  53531. * @param length the length the resulting ray should be
  53532. * @returns a ray in the direction the controller is pointing
  53533. */
  53534. getForwardRay(length?: number): Ray;
  53535. /**
  53536. * Disposes of the controller
  53537. */
  53538. dispose(): void;
  53539. }
  53540. /**
  53541. * This class represents a new windows motion controller in XR.
  53542. */
  53543. export class XRWindowsMotionController extends WindowsMotionController {
  53544. /**
  53545. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53546. */
  53547. protected readonly _mapping: {
  53548. buttons: string[];
  53549. buttonMeshNames: {
  53550. trigger: string;
  53551. menu: string;
  53552. grip: string;
  53553. thumbstick: string;
  53554. trackpad: string;
  53555. };
  53556. buttonObservableNames: {
  53557. trigger: string;
  53558. menu: string;
  53559. grip: string;
  53560. thumbstick: string;
  53561. trackpad: string;
  53562. };
  53563. axisMeshNames: string[];
  53564. pointingPoseMeshName: string;
  53565. };
  53566. /**
  53567. * Construct a new XR-Based windows motion controller
  53568. *
  53569. * @param gamepadInfo the gamepad object from the browser
  53570. */
  53571. constructor(gamepadInfo: any);
  53572. /**
  53573. * holds the thumbstick values (X,Y)
  53574. */
  53575. thumbstickValues: StickValues;
  53576. /**
  53577. * Fired when the thumbstick on this controller is clicked
  53578. */
  53579. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53580. /**
  53581. * Fired when the thumbstick on this controller is modified
  53582. */
  53583. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53584. /**
  53585. * Fired when the touchpad button on this controller is modified
  53586. */
  53587. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53588. /**
  53589. * Fired when the touchpad values on this controller are modified
  53590. */
  53591. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53592. /**
  53593. * Fired when the thumbstick button on this controller is modified
  53594. * here to prevent breaking changes
  53595. */
  53596. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53597. /**
  53598. * updating the thumbstick(!) and not the trackpad.
  53599. * This is named this way due to the difference between WebVR and XR and to avoid
  53600. * changing the parent class.
  53601. */
  53602. protected _updateTrackpad(): void;
  53603. /**
  53604. * Disposes the class with joy
  53605. */
  53606. dispose(): void;
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. /**
  53611. * Class containing static functions to help procedurally build meshes
  53612. */
  53613. export class PolyhedronBuilder {
  53614. /**
  53615. * Creates a polyhedron mesh
  53616. * * 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
  53617. * * The parameter `size` (positive float, default 1) sets the polygon size
  53618. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53619. * * 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`
  53620. * * 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
  53621. * * 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)`)
  53622. * * 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
  53623. * * 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
  53624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53625. * * 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
  53626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53627. * @param name defines the name of the mesh
  53628. * @param options defines the options used to create the mesh
  53629. * @param scene defines the hosting scene
  53630. * @returns the polyhedron mesh
  53631. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53632. */
  53633. static CreatePolyhedron(name: string, options: {
  53634. type?: number;
  53635. size?: number;
  53636. sizeX?: number;
  53637. sizeY?: number;
  53638. sizeZ?: number;
  53639. custom?: any;
  53640. faceUV?: Vector4[];
  53641. faceColors?: Color4[];
  53642. flat?: boolean;
  53643. updatable?: boolean;
  53644. sideOrientation?: number;
  53645. frontUVs?: Vector4;
  53646. backUVs?: Vector4;
  53647. }, scene?: Nullable<Scene>): Mesh;
  53648. }
  53649. }
  53650. declare module BABYLON {
  53651. /**
  53652. * Gizmo that enables scaling a mesh along 3 axis
  53653. */
  53654. export class ScaleGizmo extends Gizmo {
  53655. /**
  53656. * Internal gizmo used for interactions on the x axis
  53657. */
  53658. xGizmo: AxisScaleGizmo;
  53659. /**
  53660. * Internal gizmo used for interactions on the y axis
  53661. */
  53662. yGizmo: AxisScaleGizmo;
  53663. /**
  53664. * Internal gizmo used for interactions on the z axis
  53665. */
  53666. zGizmo: AxisScaleGizmo;
  53667. /**
  53668. * Internal gizmo used to scale all axis equally
  53669. */
  53670. uniformScaleGizmo: AxisScaleGizmo;
  53671. private _meshAttached;
  53672. private _nodeAttached;
  53673. private _snapDistance;
  53674. private _uniformScalingMesh;
  53675. private _octahedron;
  53676. private _sensitivity;
  53677. /** Fires an event when any of it's sub gizmos are dragged */
  53678. onDragStartObservable: Observable<unknown>;
  53679. /** Fires an event when any of it's sub gizmos are released from dragging */
  53680. onDragEndObservable: Observable<unknown>;
  53681. get attachedMesh(): Nullable<AbstractMesh>;
  53682. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53683. get attachedNode(): Nullable<Node>;
  53684. set attachedNode(node: Nullable<Node>);
  53685. /**
  53686. * Creates a ScaleGizmo
  53687. * @param gizmoLayer The utility layer the gizmo will be added to
  53688. * @param thickness display gizmo axis thickness
  53689. */
  53690. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53691. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53692. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53693. /**
  53694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53695. */
  53696. set snapDistance(value: number);
  53697. get snapDistance(): number;
  53698. /**
  53699. * Ratio for the scale of the gizmo (Default: 1)
  53700. */
  53701. set scaleRatio(value: number);
  53702. get scaleRatio(): number;
  53703. /**
  53704. * Sensitivity factor for dragging (Default: 1)
  53705. */
  53706. set sensitivity(value: number);
  53707. get sensitivity(): number;
  53708. /**
  53709. * Disposes of the gizmo
  53710. */
  53711. dispose(): void;
  53712. }
  53713. }
  53714. declare module BABYLON {
  53715. /**
  53716. * Single axis scale gizmo
  53717. */
  53718. export class AxisScaleGizmo extends Gizmo {
  53719. /**
  53720. * Drag behavior responsible for the gizmos dragging interactions
  53721. */
  53722. dragBehavior: PointerDragBehavior;
  53723. private _pointerObserver;
  53724. /**
  53725. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53726. */
  53727. snapDistance: number;
  53728. /**
  53729. * Event that fires each time the gizmo snaps to a new location.
  53730. * * snapDistance is the the change in distance
  53731. */
  53732. onSnapObservable: Observable<{
  53733. snapDistance: number;
  53734. }>;
  53735. /**
  53736. * If the scaling operation should be done on all axis (default: false)
  53737. */
  53738. uniformScaling: boolean;
  53739. /**
  53740. * Custom sensitivity value for the drag strength
  53741. */
  53742. sensitivity: number;
  53743. private _isEnabled;
  53744. private _parent;
  53745. private _arrow;
  53746. private _coloredMaterial;
  53747. private _hoverMaterial;
  53748. /**
  53749. * Creates an AxisScaleGizmo
  53750. * @param gizmoLayer The utility layer the gizmo will be added to
  53751. * @param dragAxis The axis which the gizmo will be able to scale on
  53752. * @param color The color of the gizmo
  53753. * @param thickness display gizmo axis thickness
  53754. */
  53755. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53756. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53757. /**
  53758. * If the gizmo is enabled
  53759. */
  53760. set isEnabled(value: boolean);
  53761. get isEnabled(): boolean;
  53762. /**
  53763. * Disposes of the gizmo
  53764. */
  53765. dispose(): void;
  53766. /**
  53767. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53768. * @param mesh The mesh to replace the default mesh of the gizmo
  53769. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53770. */
  53771. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53772. }
  53773. }
  53774. declare module BABYLON {
  53775. /**
  53776. * Bounding box gizmo
  53777. */
  53778. export class BoundingBoxGizmo extends Gizmo {
  53779. private _lineBoundingBox;
  53780. private _rotateSpheresParent;
  53781. private _scaleBoxesParent;
  53782. private _boundingDimensions;
  53783. private _renderObserver;
  53784. private _pointerObserver;
  53785. private _scaleDragSpeed;
  53786. private _tmpQuaternion;
  53787. private _tmpVector;
  53788. private _tmpRotationMatrix;
  53789. /**
  53790. * 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)
  53791. */
  53792. ignoreChildren: boolean;
  53793. /**
  53794. * 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)
  53795. */
  53796. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53797. /**
  53798. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53799. */
  53800. rotationSphereSize: number;
  53801. /**
  53802. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53803. */
  53804. scaleBoxSize: number;
  53805. /**
  53806. * 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)
  53807. */
  53808. fixedDragMeshScreenSize: boolean;
  53809. /**
  53810. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53811. */
  53812. fixedDragMeshScreenSizeDistanceFactor: number;
  53813. /**
  53814. * Fired when a rotation sphere or scale box is dragged
  53815. */
  53816. onDragStartObservable: Observable<{}>;
  53817. /**
  53818. * Fired when a scale box is dragged
  53819. */
  53820. onScaleBoxDragObservable: Observable<{}>;
  53821. /**
  53822. * Fired when a scale box drag is ended
  53823. */
  53824. onScaleBoxDragEndObservable: Observable<{}>;
  53825. /**
  53826. * Fired when a rotation sphere is dragged
  53827. */
  53828. onRotationSphereDragObservable: Observable<{}>;
  53829. /**
  53830. * Fired when a rotation sphere drag is ended
  53831. */
  53832. onRotationSphereDragEndObservable: Observable<{}>;
  53833. /**
  53834. * 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)
  53835. */
  53836. scalePivot: Nullable<Vector3>;
  53837. /**
  53838. * Mesh used as a pivot to rotate the attached node
  53839. */
  53840. private _anchorMesh;
  53841. private _existingMeshScale;
  53842. private _dragMesh;
  53843. private pointerDragBehavior;
  53844. private coloredMaterial;
  53845. private hoverColoredMaterial;
  53846. /**
  53847. * Sets the color of the bounding box gizmo
  53848. * @param color the color to set
  53849. */
  53850. setColor(color: Color3): void;
  53851. /**
  53852. * Creates an BoundingBoxGizmo
  53853. * @param gizmoLayer The utility layer the gizmo will be added to
  53854. * @param color The color of the gizmo
  53855. */
  53856. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53857. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53858. private _selectNode;
  53859. /**
  53860. * Updates the bounding box information for the Gizmo
  53861. */
  53862. updateBoundingBox(): void;
  53863. private _updateRotationSpheres;
  53864. private _updateScaleBoxes;
  53865. /**
  53866. * Enables rotation on the specified axis and disables rotation on the others
  53867. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53868. */
  53869. setEnabledRotationAxis(axis: string): void;
  53870. /**
  53871. * Enables/disables scaling
  53872. * @param enable if scaling should be enabled
  53873. * @param homogeneousScaling defines if scaling should only be homogeneous
  53874. */
  53875. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53876. private _updateDummy;
  53877. /**
  53878. * Enables a pointer drag behavior on the bounding box of the gizmo
  53879. */
  53880. enableDragBehavior(): void;
  53881. /**
  53882. * Disposes of the gizmo
  53883. */
  53884. dispose(): void;
  53885. /**
  53886. * 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)
  53887. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53888. * @returns the bounding box mesh with the passed in mesh as a child
  53889. */
  53890. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53891. /**
  53892. * CustomMeshes are not supported by this gizmo
  53893. * @param mesh The mesh to replace the default mesh of the gizmo
  53894. */
  53895. setCustomMesh(mesh: Mesh): void;
  53896. }
  53897. }
  53898. declare module BABYLON {
  53899. /**
  53900. * Single plane rotation gizmo
  53901. */
  53902. export class PlaneRotationGizmo extends Gizmo {
  53903. /**
  53904. * Drag behavior responsible for the gizmos dragging interactions
  53905. */
  53906. dragBehavior: PointerDragBehavior;
  53907. private _pointerObserver;
  53908. /**
  53909. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53910. */
  53911. snapDistance: number;
  53912. /**
  53913. * Event that fires each time the gizmo snaps to a new location.
  53914. * * snapDistance is the the change in distance
  53915. */
  53916. onSnapObservable: Observable<{
  53917. snapDistance: number;
  53918. }>;
  53919. private _isEnabled;
  53920. private _parent;
  53921. /**
  53922. * Creates a PlaneRotationGizmo
  53923. * @param gizmoLayer The utility layer the gizmo will be added to
  53924. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53925. * @param color The color of the gizmo
  53926. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53927. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53928. * @param thickness display gizmo axis thickness
  53929. */
  53930. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53931. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53932. /**
  53933. * If the gizmo is enabled
  53934. */
  53935. set isEnabled(value: boolean);
  53936. get isEnabled(): boolean;
  53937. /**
  53938. * Disposes of the gizmo
  53939. */
  53940. dispose(): void;
  53941. }
  53942. }
  53943. declare module BABYLON {
  53944. /**
  53945. * Gizmo that enables rotating a mesh along 3 axis
  53946. */
  53947. export class RotationGizmo extends Gizmo {
  53948. /**
  53949. * Internal gizmo used for interactions on the x axis
  53950. */
  53951. xGizmo: PlaneRotationGizmo;
  53952. /**
  53953. * Internal gizmo used for interactions on the y axis
  53954. */
  53955. yGizmo: PlaneRotationGizmo;
  53956. /**
  53957. * Internal gizmo used for interactions on the z axis
  53958. */
  53959. zGizmo: PlaneRotationGizmo;
  53960. /** Fires an event when any of it's sub gizmos are dragged */
  53961. onDragStartObservable: Observable<unknown>;
  53962. /** Fires an event when any of it's sub gizmos are released from dragging */
  53963. onDragEndObservable: Observable<unknown>;
  53964. private _meshAttached;
  53965. private _nodeAttached;
  53966. get attachedMesh(): Nullable<AbstractMesh>;
  53967. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53968. get attachedNode(): Nullable<Node>;
  53969. set attachedNode(node: Nullable<Node>);
  53970. /**
  53971. * Creates a RotationGizmo
  53972. * @param gizmoLayer The utility layer the gizmo will be added to
  53973. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53974. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53975. * @param thickness display gizmo axis thickness
  53976. */
  53977. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53978. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53979. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53980. /**
  53981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53982. */
  53983. set snapDistance(value: number);
  53984. get snapDistance(): number;
  53985. /**
  53986. * Ratio for the scale of the gizmo (Default: 1)
  53987. */
  53988. set scaleRatio(value: number);
  53989. get scaleRatio(): number;
  53990. /**
  53991. * Disposes of the gizmo
  53992. */
  53993. dispose(): void;
  53994. /**
  53995. * CustomMeshes are not supported by this gizmo
  53996. * @param mesh The mesh to replace the default mesh of the gizmo
  53997. */
  53998. setCustomMesh(mesh: Mesh): void;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /**
  54003. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54004. */
  54005. export class GizmoManager implements IDisposable {
  54006. private scene;
  54007. /**
  54008. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54009. */
  54010. gizmos: {
  54011. positionGizmo: Nullable<PositionGizmo>;
  54012. rotationGizmo: Nullable<RotationGizmo>;
  54013. scaleGizmo: Nullable<ScaleGizmo>;
  54014. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54015. };
  54016. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54017. clearGizmoOnEmptyPointerEvent: boolean;
  54018. /** Fires an event when the manager is attached to a mesh */
  54019. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54020. /** Fires an event when the manager is attached to a node */
  54021. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54022. private _gizmosEnabled;
  54023. private _pointerObserver;
  54024. private _attachedMesh;
  54025. private _attachedNode;
  54026. private _boundingBoxColor;
  54027. private _defaultUtilityLayer;
  54028. private _defaultKeepDepthUtilityLayer;
  54029. private _thickness;
  54030. /**
  54031. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54032. */
  54033. boundingBoxDragBehavior: SixDofDragBehavior;
  54034. /**
  54035. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54036. */
  54037. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54038. /**
  54039. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54040. */
  54041. attachableNodes: Nullable<Array<Node>>;
  54042. /**
  54043. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54044. */
  54045. usePointerToAttachGizmos: boolean;
  54046. /**
  54047. * Utility layer that the bounding box gizmo belongs to
  54048. */
  54049. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54050. /**
  54051. * Utility layer that all gizmos besides bounding box belong to
  54052. */
  54053. get utilityLayer(): UtilityLayerRenderer;
  54054. /**
  54055. * Instatiates a gizmo manager
  54056. * @param scene the scene to overlay the gizmos on top of
  54057. * @param thickness display gizmo axis thickness
  54058. */
  54059. constructor(scene: Scene, thickness?: number);
  54060. /**
  54061. * Attaches a set of gizmos to the specified mesh
  54062. * @param mesh The mesh the gizmo's should be attached to
  54063. */
  54064. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54065. /**
  54066. * Attaches a set of gizmos to the specified node
  54067. * @param node The node the gizmo's should be attached to
  54068. */
  54069. attachToNode(node: Nullable<Node>): void;
  54070. /**
  54071. * If the position gizmo is enabled
  54072. */
  54073. set positionGizmoEnabled(value: boolean);
  54074. get positionGizmoEnabled(): boolean;
  54075. /**
  54076. * If the rotation gizmo is enabled
  54077. */
  54078. set rotationGizmoEnabled(value: boolean);
  54079. get rotationGizmoEnabled(): boolean;
  54080. /**
  54081. * If the scale gizmo is enabled
  54082. */
  54083. set scaleGizmoEnabled(value: boolean);
  54084. get scaleGizmoEnabled(): boolean;
  54085. /**
  54086. * If the boundingBox gizmo is enabled
  54087. */
  54088. set boundingBoxGizmoEnabled(value: boolean);
  54089. get boundingBoxGizmoEnabled(): boolean;
  54090. /**
  54091. * Disposes of the gizmo manager
  54092. */
  54093. dispose(): void;
  54094. }
  54095. }
  54096. declare module BABYLON {
  54097. /**
  54098. * A directional light is defined by a direction (what a surprise!).
  54099. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54100. * 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.
  54101. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54102. */
  54103. export class DirectionalLight extends ShadowLight {
  54104. private _shadowFrustumSize;
  54105. /**
  54106. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54107. */
  54108. get shadowFrustumSize(): number;
  54109. /**
  54110. * Specifies a fix frustum size for the shadow generation.
  54111. */
  54112. set shadowFrustumSize(value: number);
  54113. private _shadowOrthoScale;
  54114. /**
  54115. * Gets the shadow projection scale against the optimal computed one.
  54116. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54117. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54118. */
  54119. get shadowOrthoScale(): number;
  54120. /**
  54121. * Sets the shadow projection scale against the optimal computed one.
  54122. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54123. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54124. */
  54125. set shadowOrthoScale(value: number);
  54126. /**
  54127. * Automatically compute the projection matrix to best fit (including all the casters)
  54128. * on each frame.
  54129. */
  54130. autoUpdateExtends: boolean;
  54131. /**
  54132. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54133. * on each frame. autoUpdateExtends must be set to true for this to work
  54134. */
  54135. autoCalcShadowZBounds: boolean;
  54136. private _orthoLeft;
  54137. private _orthoRight;
  54138. private _orthoTop;
  54139. private _orthoBottom;
  54140. /**
  54141. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54142. * The directional light is emitted from everywhere in the given direction.
  54143. * It can cast shadows.
  54144. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54145. * @param name The friendly name of the light
  54146. * @param direction The direction of the light
  54147. * @param scene The scene the light belongs to
  54148. */
  54149. constructor(name: string, direction: Vector3, scene: Scene);
  54150. /**
  54151. * Returns the string "DirectionalLight".
  54152. * @return The class name
  54153. */
  54154. getClassName(): string;
  54155. /**
  54156. * Returns the integer 1.
  54157. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54158. */
  54159. getTypeID(): number;
  54160. /**
  54161. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54162. * Returns the DirectionalLight Shadow projection matrix.
  54163. */
  54164. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54165. /**
  54166. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54167. * Returns the DirectionalLight Shadow projection matrix.
  54168. */
  54169. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54170. /**
  54171. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54172. * Returns the DirectionalLight Shadow projection matrix.
  54173. */
  54174. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54175. protected _buildUniformLayout(): void;
  54176. /**
  54177. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54178. * @param effect The effect to update
  54179. * @param lightIndex The index of the light in the effect to update
  54180. * @returns The directional light
  54181. */
  54182. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54183. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54184. /**
  54185. * Gets the minZ used for shadow according to both the scene and the light.
  54186. *
  54187. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54188. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54189. * @param activeCamera The camera we are returning the min for
  54190. * @returns the depth min z
  54191. */
  54192. getDepthMinZ(activeCamera: Camera): number;
  54193. /**
  54194. * Gets the maxZ used for shadow according to both the scene and the light.
  54195. *
  54196. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54197. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54198. * @param activeCamera The camera we are returning the max for
  54199. * @returns the depth max z
  54200. */
  54201. getDepthMaxZ(activeCamera: Camera): number;
  54202. /**
  54203. * Prepares the list of defines specific to the light type.
  54204. * @param defines the list of defines
  54205. * @param lightIndex defines the index of the light for the effect
  54206. */
  54207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54208. }
  54209. }
  54210. declare module BABYLON {
  54211. /**
  54212. * Class containing static functions to help procedurally build meshes
  54213. */
  54214. export class HemisphereBuilder {
  54215. /**
  54216. * Creates a hemisphere mesh
  54217. * @param name defines the name of the mesh
  54218. * @param options defines the options used to create the mesh
  54219. * @param scene defines the hosting scene
  54220. * @returns the hemisphere mesh
  54221. */
  54222. static CreateHemisphere(name: string, options: {
  54223. segments?: number;
  54224. diameter?: number;
  54225. sideOrientation?: number;
  54226. }, scene: any): Mesh;
  54227. }
  54228. }
  54229. declare module BABYLON {
  54230. /**
  54231. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54232. * These values define a cone of light starting from the position, emitting toward the direction.
  54233. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54234. * and the exponent defines the speed of the decay of the light with distance (reach).
  54235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54236. */
  54237. export class SpotLight extends ShadowLight {
  54238. private _angle;
  54239. private _innerAngle;
  54240. private _cosHalfAngle;
  54241. private _lightAngleScale;
  54242. private _lightAngleOffset;
  54243. /**
  54244. * Gets the cone angle of the spot light in Radians.
  54245. */
  54246. get angle(): number;
  54247. /**
  54248. * Sets the cone angle of the spot light in Radians.
  54249. */
  54250. set angle(value: number);
  54251. /**
  54252. * Only used in gltf falloff mode, this defines the angle where
  54253. * the directional falloff will start before cutting at angle which could be seen
  54254. * as outer angle.
  54255. */
  54256. get innerAngle(): number;
  54257. /**
  54258. * Only used in gltf falloff mode, this defines the angle where
  54259. * the directional falloff will start before cutting at angle which could be seen
  54260. * as outer angle.
  54261. */
  54262. set innerAngle(value: number);
  54263. private _shadowAngleScale;
  54264. /**
  54265. * Allows scaling the angle of the light for shadow generation only.
  54266. */
  54267. get shadowAngleScale(): number;
  54268. /**
  54269. * Allows scaling the angle of the light for shadow generation only.
  54270. */
  54271. set shadowAngleScale(value: number);
  54272. /**
  54273. * The light decay speed with the distance from the emission spot.
  54274. */
  54275. exponent: number;
  54276. private _projectionTextureMatrix;
  54277. /**
  54278. * Allows reading the projecton texture
  54279. */
  54280. get projectionTextureMatrix(): Matrix;
  54281. protected _projectionTextureLightNear: number;
  54282. /**
  54283. * Gets the near clip of the Spotlight for texture projection.
  54284. */
  54285. get projectionTextureLightNear(): number;
  54286. /**
  54287. * Sets the near clip of the Spotlight for texture projection.
  54288. */
  54289. set projectionTextureLightNear(value: number);
  54290. protected _projectionTextureLightFar: number;
  54291. /**
  54292. * Gets the far clip of the Spotlight for texture projection.
  54293. */
  54294. get projectionTextureLightFar(): number;
  54295. /**
  54296. * Sets the far clip of the Spotlight for texture projection.
  54297. */
  54298. set projectionTextureLightFar(value: number);
  54299. protected _projectionTextureUpDirection: Vector3;
  54300. /**
  54301. * Gets the Up vector of the Spotlight for texture projection.
  54302. */
  54303. get projectionTextureUpDirection(): Vector3;
  54304. /**
  54305. * Sets the Up vector of the Spotlight for texture projection.
  54306. */
  54307. set projectionTextureUpDirection(value: Vector3);
  54308. private _projectionTexture;
  54309. /**
  54310. * Gets the projection texture of the light.
  54311. */
  54312. get projectionTexture(): Nullable<BaseTexture>;
  54313. /**
  54314. * Sets the projection texture of the light.
  54315. */
  54316. set projectionTexture(value: Nullable<BaseTexture>);
  54317. private _projectionTextureViewLightDirty;
  54318. private _projectionTextureProjectionLightDirty;
  54319. private _projectionTextureDirty;
  54320. private _projectionTextureViewTargetVector;
  54321. private _projectionTextureViewLightMatrix;
  54322. private _projectionTextureProjectionLightMatrix;
  54323. private _projectionTextureScalingMatrix;
  54324. /**
  54325. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54326. * It can cast shadows.
  54327. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54328. * @param name The light friendly name
  54329. * @param position The position of the spot light in the scene
  54330. * @param direction The direction of the light in the scene
  54331. * @param angle The cone angle of the light in Radians
  54332. * @param exponent The light decay speed with the distance from the emission spot
  54333. * @param scene The scene the lights belongs to
  54334. */
  54335. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54336. /**
  54337. * Returns the string "SpotLight".
  54338. * @returns the class name
  54339. */
  54340. getClassName(): string;
  54341. /**
  54342. * Returns the integer 2.
  54343. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54344. */
  54345. getTypeID(): number;
  54346. /**
  54347. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54348. */
  54349. protected _setDirection(value: Vector3): void;
  54350. /**
  54351. * Overrides the position setter to recompute the projection texture view light Matrix.
  54352. */
  54353. protected _setPosition(value: Vector3): void;
  54354. /**
  54355. * 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.
  54356. * Returns the SpotLight.
  54357. */
  54358. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54359. protected _computeProjectionTextureViewLightMatrix(): void;
  54360. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54361. /**
  54362. * Main function for light texture projection matrix computing.
  54363. */
  54364. protected _computeProjectionTextureMatrix(): void;
  54365. protected _buildUniformLayout(): void;
  54366. private _computeAngleValues;
  54367. /**
  54368. * Sets the passed Effect "effect" with the Light textures.
  54369. * @param effect The effect to update
  54370. * @param lightIndex The index of the light in the effect to update
  54371. * @returns The light
  54372. */
  54373. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54374. /**
  54375. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54376. * @param effect The effect to update
  54377. * @param lightIndex The index of the light in the effect to update
  54378. * @returns The spot light
  54379. */
  54380. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54381. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54382. /**
  54383. * Disposes the light and the associated resources.
  54384. */
  54385. dispose(): void;
  54386. /**
  54387. * Prepares the list of defines specific to the light type.
  54388. * @param defines the list of defines
  54389. * @param lightIndex defines the index of the light for the effect
  54390. */
  54391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54392. }
  54393. }
  54394. declare module BABYLON {
  54395. /**
  54396. * Gizmo that enables viewing a light
  54397. */
  54398. export class LightGizmo extends Gizmo {
  54399. private _lightMesh;
  54400. private _material;
  54401. private _cachedPosition;
  54402. private _cachedForward;
  54403. private _attachedMeshParent;
  54404. private _pointerObserver;
  54405. /**
  54406. * Event that fires each time the gizmo is clicked
  54407. */
  54408. onClickedObservable: Observable<Light>;
  54409. /**
  54410. * Creates a LightGizmo
  54411. * @param gizmoLayer The utility layer the gizmo will be added to
  54412. */
  54413. constructor(gizmoLayer?: UtilityLayerRenderer);
  54414. private _light;
  54415. /**
  54416. * The light that the gizmo is attached to
  54417. */
  54418. set light(light: Nullable<Light>);
  54419. get light(): Nullable<Light>;
  54420. /**
  54421. * Gets the material used to render the light gizmo
  54422. */
  54423. get material(): StandardMaterial;
  54424. /**
  54425. * @hidden
  54426. * Updates the gizmo to match the attached mesh's position/rotation
  54427. */
  54428. protected _update(): void;
  54429. private static _Scale;
  54430. /**
  54431. * Creates the lines for a light mesh
  54432. */
  54433. private static _CreateLightLines;
  54434. /**
  54435. * Disposes of the light gizmo
  54436. */
  54437. dispose(): void;
  54438. private static _CreateHemisphericLightMesh;
  54439. private static _CreatePointLightMesh;
  54440. private static _CreateSpotLightMesh;
  54441. private static _CreateDirectionalLightMesh;
  54442. }
  54443. }
  54444. declare module BABYLON {
  54445. /**
  54446. * Gizmo that enables viewing a camera
  54447. */
  54448. export class CameraGizmo extends Gizmo {
  54449. private _cameraMesh;
  54450. private _cameraLinesMesh;
  54451. private _material;
  54452. private _pointerObserver;
  54453. /**
  54454. * Event that fires each time the gizmo is clicked
  54455. */
  54456. onClickedObservable: Observable<Camera>;
  54457. /**
  54458. * Creates a CameraGizmo
  54459. * @param gizmoLayer The utility layer the gizmo will be added to
  54460. */
  54461. constructor(gizmoLayer?: UtilityLayerRenderer);
  54462. private _camera;
  54463. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54464. get displayFrustum(): boolean;
  54465. set displayFrustum(value: boolean);
  54466. /**
  54467. * The camera that the gizmo is attached to
  54468. */
  54469. set camera(camera: Nullable<Camera>);
  54470. get camera(): Nullable<Camera>;
  54471. /**
  54472. * Gets the material used to render the camera gizmo
  54473. */
  54474. get material(): StandardMaterial;
  54475. /**
  54476. * @hidden
  54477. * Updates the gizmo to match the attached mesh's position/rotation
  54478. */
  54479. protected _update(): void;
  54480. private static _Scale;
  54481. private _invProjection;
  54482. /**
  54483. * Disposes of the camera gizmo
  54484. */
  54485. dispose(): void;
  54486. private static _CreateCameraMesh;
  54487. private static _CreateCameraFrustum;
  54488. }
  54489. }
  54490. declare module BABYLON {
  54491. /** @hidden */
  54492. export var backgroundFragmentDeclaration: {
  54493. name: string;
  54494. shader: string;
  54495. };
  54496. }
  54497. declare module BABYLON {
  54498. /** @hidden */
  54499. export var backgroundUboDeclaration: {
  54500. name: string;
  54501. shader: string;
  54502. };
  54503. }
  54504. declare module BABYLON {
  54505. /** @hidden */
  54506. export var backgroundPixelShader: {
  54507. name: string;
  54508. shader: string;
  54509. };
  54510. }
  54511. declare module BABYLON {
  54512. /** @hidden */
  54513. export var backgroundVertexDeclaration: {
  54514. name: string;
  54515. shader: string;
  54516. };
  54517. }
  54518. declare module BABYLON {
  54519. /** @hidden */
  54520. export var backgroundVertexShader: {
  54521. name: string;
  54522. shader: string;
  54523. };
  54524. }
  54525. declare module BABYLON {
  54526. /**
  54527. * Background material used to create an efficient environement around your scene.
  54528. */
  54529. export class BackgroundMaterial extends PushMaterial {
  54530. /**
  54531. * Standard reflectance value at parallel view angle.
  54532. */
  54533. static StandardReflectance0: number;
  54534. /**
  54535. * Standard reflectance value at grazing angle.
  54536. */
  54537. static StandardReflectance90: number;
  54538. protected _primaryColor: Color3;
  54539. /**
  54540. * Key light Color (multiply against the environement texture)
  54541. */
  54542. primaryColor: Color3;
  54543. protected __perceptualColor: Nullable<Color3>;
  54544. /**
  54545. * Experimental Internal Use Only.
  54546. *
  54547. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54548. * This acts as a helper to set the primary color to a more "human friendly" value.
  54549. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54550. * output color as close as possible from the chosen value.
  54551. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54552. * part of lighting setup.)
  54553. */
  54554. get _perceptualColor(): Nullable<Color3>;
  54555. set _perceptualColor(value: Nullable<Color3>);
  54556. protected _primaryColorShadowLevel: float;
  54557. /**
  54558. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54559. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54560. */
  54561. get primaryColorShadowLevel(): float;
  54562. set primaryColorShadowLevel(value: float);
  54563. protected _primaryColorHighlightLevel: float;
  54564. /**
  54565. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54566. * The primary color is used at the level chosen to define what the white area would look.
  54567. */
  54568. get primaryColorHighlightLevel(): float;
  54569. set primaryColorHighlightLevel(value: float);
  54570. protected _reflectionTexture: Nullable<BaseTexture>;
  54571. /**
  54572. * Reflection Texture used in the material.
  54573. * Should be author in a specific way for the best result (refer to the documentation).
  54574. */
  54575. reflectionTexture: Nullable<BaseTexture>;
  54576. protected _reflectionBlur: float;
  54577. /**
  54578. * Reflection Texture level of blur.
  54579. *
  54580. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54581. * texture twice.
  54582. */
  54583. reflectionBlur: float;
  54584. protected _diffuseTexture: Nullable<BaseTexture>;
  54585. /**
  54586. * Diffuse Texture used in the material.
  54587. * Should be author in a specific way for the best result (refer to the documentation).
  54588. */
  54589. diffuseTexture: Nullable<BaseTexture>;
  54590. protected _shadowLights: Nullable<IShadowLight[]>;
  54591. /**
  54592. * Specify the list of lights casting shadow on the material.
  54593. * All scene shadow lights will be included if null.
  54594. */
  54595. shadowLights: Nullable<IShadowLight[]>;
  54596. protected _shadowLevel: float;
  54597. /**
  54598. * Helps adjusting the shadow to a softer level if required.
  54599. * 0 means black shadows and 1 means no shadows.
  54600. */
  54601. shadowLevel: float;
  54602. protected _sceneCenter: Vector3;
  54603. /**
  54604. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54605. * It is usually zero but might be interesting to modify according to your setup.
  54606. */
  54607. sceneCenter: Vector3;
  54608. protected _opacityFresnel: boolean;
  54609. /**
  54610. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54611. * This helps ensuring a nice transition when the camera goes under the ground.
  54612. */
  54613. opacityFresnel: boolean;
  54614. protected _reflectionFresnel: boolean;
  54615. /**
  54616. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54617. * This helps adding a mirror texture on the ground.
  54618. */
  54619. reflectionFresnel: boolean;
  54620. protected _reflectionFalloffDistance: number;
  54621. /**
  54622. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54623. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54624. */
  54625. reflectionFalloffDistance: number;
  54626. protected _reflectionAmount: number;
  54627. /**
  54628. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54629. */
  54630. reflectionAmount: number;
  54631. protected _reflectionReflectance0: number;
  54632. /**
  54633. * This specifies the weight of the reflection at grazing angle.
  54634. */
  54635. reflectionReflectance0: number;
  54636. protected _reflectionReflectance90: number;
  54637. /**
  54638. * This specifies the weight of the reflection at a perpendicular point of view.
  54639. */
  54640. reflectionReflectance90: number;
  54641. /**
  54642. * Sets the reflection reflectance fresnel values according to the default standard
  54643. * empirically know to work well :-)
  54644. */
  54645. set reflectionStandardFresnelWeight(value: number);
  54646. protected _useRGBColor: boolean;
  54647. /**
  54648. * Helps to directly use the maps channels instead of their level.
  54649. */
  54650. useRGBColor: boolean;
  54651. protected _enableNoise: boolean;
  54652. /**
  54653. * This helps reducing the banding effect that could occur on the background.
  54654. */
  54655. enableNoise: boolean;
  54656. /**
  54657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54658. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54659. * Recommended to be keep at 1.0 except for special cases.
  54660. */
  54661. get fovMultiplier(): number;
  54662. set fovMultiplier(value: number);
  54663. private _fovMultiplier;
  54664. /**
  54665. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54666. */
  54667. useEquirectangularFOV: boolean;
  54668. private _maxSimultaneousLights;
  54669. /**
  54670. * Number of Simultaneous lights allowed on the material.
  54671. */
  54672. maxSimultaneousLights: int;
  54673. private _shadowOnly;
  54674. /**
  54675. * Make the material only render shadows
  54676. */
  54677. shadowOnly: boolean;
  54678. /**
  54679. * Default configuration related to image processing available in the Background Material.
  54680. */
  54681. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54682. /**
  54683. * Keep track of the image processing observer to allow dispose and replace.
  54684. */
  54685. private _imageProcessingObserver;
  54686. /**
  54687. * Attaches a new image processing configuration to the PBR Material.
  54688. * @param configuration (if null the scene configuration will be use)
  54689. */
  54690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54691. /**
  54692. * Gets the image processing configuration used either in this material.
  54693. */
  54694. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54695. /**
  54696. * Sets the Default image processing configuration used either in the this material.
  54697. *
  54698. * If sets to null, the scene one is in use.
  54699. */
  54700. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54701. /**
  54702. * Gets wether the color curves effect is enabled.
  54703. */
  54704. get cameraColorCurvesEnabled(): boolean;
  54705. /**
  54706. * Sets wether the color curves effect is enabled.
  54707. */
  54708. set cameraColorCurvesEnabled(value: boolean);
  54709. /**
  54710. * Gets wether the color grading effect is enabled.
  54711. */
  54712. get cameraColorGradingEnabled(): boolean;
  54713. /**
  54714. * Gets wether the color grading effect is enabled.
  54715. */
  54716. set cameraColorGradingEnabled(value: boolean);
  54717. /**
  54718. * Gets wether tonemapping is enabled or not.
  54719. */
  54720. get cameraToneMappingEnabled(): boolean;
  54721. /**
  54722. * Sets wether tonemapping is enabled or not
  54723. */
  54724. set cameraToneMappingEnabled(value: boolean);
  54725. /**
  54726. * The camera exposure used on this material.
  54727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54728. * This corresponds to a photographic exposure.
  54729. */
  54730. get cameraExposure(): float;
  54731. /**
  54732. * The camera exposure used on this material.
  54733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54734. * This corresponds to a photographic exposure.
  54735. */
  54736. set cameraExposure(value: float);
  54737. /**
  54738. * Gets The camera contrast used on this material.
  54739. */
  54740. get cameraContrast(): float;
  54741. /**
  54742. * Sets The camera contrast used on this material.
  54743. */
  54744. set cameraContrast(value: float);
  54745. /**
  54746. * Gets the Color Grading 2D Lookup Texture.
  54747. */
  54748. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54749. /**
  54750. * Sets the Color Grading 2D Lookup Texture.
  54751. */
  54752. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54753. /**
  54754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54756. * 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;
  54757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54758. */
  54759. get cameraColorCurves(): Nullable<ColorCurves>;
  54760. /**
  54761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54763. * 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;
  54764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54765. */
  54766. set cameraColorCurves(value: Nullable<ColorCurves>);
  54767. /**
  54768. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54769. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54770. */
  54771. switchToBGR: boolean;
  54772. private _renderTargets;
  54773. private _reflectionControls;
  54774. private _white;
  54775. private _primaryShadowColor;
  54776. private _primaryHighlightColor;
  54777. /**
  54778. * Instantiates a Background Material in the given scene
  54779. * @param name The friendly name of the material
  54780. * @param scene The scene to add the material to
  54781. */
  54782. constructor(name: string, scene: Scene);
  54783. /**
  54784. * Gets a boolean indicating that current material needs to register RTT
  54785. */
  54786. get hasRenderTargetTextures(): boolean;
  54787. /**
  54788. * The entire material has been created in order to prevent overdraw.
  54789. * @returns false
  54790. */
  54791. needAlphaTesting(): boolean;
  54792. /**
  54793. * The entire material has been created in order to prevent overdraw.
  54794. * @returns true if blending is enable
  54795. */
  54796. needAlphaBlending(): boolean;
  54797. /**
  54798. * Checks wether the material is ready to be rendered for a given mesh.
  54799. * @param mesh The mesh to render
  54800. * @param subMesh The submesh to check against
  54801. * @param useInstances Specify wether or not the material is used with instances
  54802. * @returns true if all the dependencies are ready (Textures, Effects...)
  54803. */
  54804. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54805. /**
  54806. * Compute the primary color according to the chosen perceptual color.
  54807. */
  54808. private _computePrimaryColorFromPerceptualColor;
  54809. /**
  54810. * Compute the highlights and shadow colors according to their chosen levels.
  54811. */
  54812. private _computePrimaryColors;
  54813. /**
  54814. * Build the uniform buffer used in the material.
  54815. */
  54816. buildUniformLayout(): void;
  54817. /**
  54818. * Unbind the material.
  54819. */
  54820. unbind(): void;
  54821. /**
  54822. * Bind only the world matrix to the material.
  54823. * @param world The world matrix to bind.
  54824. */
  54825. bindOnlyWorldMatrix(world: Matrix): void;
  54826. /**
  54827. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54828. * @param world The world matrix to bind.
  54829. * @param subMesh The submesh to bind for.
  54830. */
  54831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54832. /**
  54833. * Checks to see if a texture is used in the material.
  54834. * @param texture - Base texture to use.
  54835. * @returns - Boolean specifying if a texture is used in the material.
  54836. */
  54837. hasTexture(texture: BaseTexture): boolean;
  54838. /**
  54839. * Dispose the material.
  54840. * @param forceDisposeEffect Force disposal of the associated effect.
  54841. * @param forceDisposeTextures Force disposal of the associated textures.
  54842. */
  54843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54844. /**
  54845. * Clones the material.
  54846. * @param name The cloned name.
  54847. * @returns The cloned material.
  54848. */
  54849. clone(name: string): BackgroundMaterial;
  54850. /**
  54851. * Serializes the current material to its JSON representation.
  54852. * @returns The JSON representation.
  54853. */
  54854. serialize(): any;
  54855. /**
  54856. * Gets the class name of the material
  54857. * @returns "BackgroundMaterial"
  54858. */
  54859. getClassName(): string;
  54860. /**
  54861. * Parse a JSON input to create back a background material.
  54862. * @param source The JSON data to parse
  54863. * @param scene The scene to create the parsed material in
  54864. * @param rootUrl The root url of the assets the material depends upon
  54865. * @returns the instantiated BackgroundMaterial.
  54866. */
  54867. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54868. }
  54869. }
  54870. declare module BABYLON {
  54871. /**
  54872. * Represents the different options available during the creation of
  54873. * a Environment helper.
  54874. *
  54875. * This can control the default ground, skybox and image processing setup of your scene.
  54876. */
  54877. export interface IEnvironmentHelperOptions {
  54878. /**
  54879. * Specifies whether or not to create a ground.
  54880. * True by default.
  54881. */
  54882. createGround: boolean;
  54883. /**
  54884. * Specifies the ground size.
  54885. * 15 by default.
  54886. */
  54887. groundSize: number;
  54888. /**
  54889. * The texture used on the ground for the main color.
  54890. * Comes from the BabylonJS CDN by default.
  54891. *
  54892. * Remarks: Can be either a texture or a url.
  54893. */
  54894. groundTexture: string | BaseTexture;
  54895. /**
  54896. * The color mixed in the ground texture by default.
  54897. * BabylonJS clearColor by default.
  54898. */
  54899. groundColor: Color3;
  54900. /**
  54901. * Specifies the ground opacity.
  54902. * 1 by default.
  54903. */
  54904. groundOpacity: number;
  54905. /**
  54906. * Enables the ground to receive shadows.
  54907. * True by default.
  54908. */
  54909. enableGroundShadow: boolean;
  54910. /**
  54911. * Helps preventing the shadow to be fully black on the ground.
  54912. * 0.5 by default.
  54913. */
  54914. groundShadowLevel: number;
  54915. /**
  54916. * Creates a mirror texture attach to the ground.
  54917. * false by default.
  54918. */
  54919. enableGroundMirror: boolean;
  54920. /**
  54921. * Specifies the ground mirror size ratio.
  54922. * 0.3 by default as the default kernel is 64.
  54923. */
  54924. groundMirrorSizeRatio: number;
  54925. /**
  54926. * Specifies the ground mirror blur kernel size.
  54927. * 64 by default.
  54928. */
  54929. groundMirrorBlurKernel: number;
  54930. /**
  54931. * Specifies the ground mirror visibility amount.
  54932. * 1 by default
  54933. */
  54934. groundMirrorAmount: number;
  54935. /**
  54936. * Specifies the ground mirror reflectance weight.
  54937. * This uses the standard weight of the background material to setup the fresnel effect
  54938. * of the mirror.
  54939. * 1 by default.
  54940. */
  54941. groundMirrorFresnelWeight: number;
  54942. /**
  54943. * Specifies the ground mirror Falloff distance.
  54944. * This can helps reducing the size of the reflection.
  54945. * 0 by Default.
  54946. */
  54947. groundMirrorFallOffDistance: number;
  54948. /**
  54949. * Specifies the ground mirror texture type.
  54950. * Unsigned Int by Default.
  54951. */
  54952. groundMirrorTextureType: number;
  54953. /**
  54954. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54955. * the shown objects.
  54956. */
  54957. groundYBias: number;
  54958. /**
  54959. * Specifies whether or not to create a skybox.
  54960. * True by default.
  54961. */
  54962. createSkybox: boolean;
  54963. /**
  54964. * Specifies the skybox size.
  54965. * 20 by default.
  54966. */
  54967. skyboxSize: number;
  54968. /**
  54969. * The texture used on the skybox for the main color.
  54970. * Comes from the BabylonJS CDN by default.
  54971. *
  54972. * Remarks: Can be either a texture or a url.
  54973. */
  54974. skyboxTexture: string | BaseTexture;
  54975. /**
  54976. * The color mixed in the skybox texture by default.
  54977. * BabylonJS clearColor by default.
  54978. */
  54979. skyboxColor: Color3;
  54980. /**
  54981. * The background rotation around the Y axis of the scene.
  54982. * This helps aligning the key lights of your scene with the background.
  54983. * 0 by default.
  54984. */
  54985. backgroundYRotation: number;
  54986. /**
  54987. * Compute automatically the size of the elements to best fit with the scene.
  54988. */
  54989. sizeAuto: boolean;
  54990. /**
  54991. * Default position of the rootMesh if autoSize is not true.
  54992. */
  54993. rootPosition: Vector3;
  54994. /**
  54995. * Sets up the image processing in the scene.
  54996. * true by default.
  54997. */
  54998. setupImageProcessing: boolean;
  54999. /**
  55000. * The texture used as your environment texture in the scene.
  55001. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55002. *
  55003. * Remarks: Can be either a texture or a url.
  55004. */
  55005. environmentTexture: string | BaseTexture;
  55006. /**
  55007. * The value of the exposure to apply to the scene.
  55008. * 0.6 by default if setupImageProcessing is true.
  55009. */
  55010. cameraExposure: number;
  55011. /**
  55012. * The value of the contrast to apply to the scene.
  55013. * 1.6 by default if setupImageProcessing is true.
  55014. */
  55015. cameraContrast: number;
  55016. /**
  55017. * Specifies whether or not tonemapping should be enabled in the scene.
  55018. * true by default if setupImageProcessing is true.
  55019. */
  55020. toneMappingEnabled: boolean;
  55021. }
  55022. /**
  55023. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55024. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55025. * It also helps with the default setup of your imageProcessing configuration.
  55026. */
  55027. export class EnvironmentHelper {
  55028. /**
  55029. * Default ground texture URL.
  55030. */
  55031. private static _groundTextureCDNUrl;
  55032. /**
  55033. * Default skybox texture URL.
  55034. */
  55035. private static _skyboxTextureCDNUrl;
  55036. /**
  55037. * Default environment texture URL.
  55038. */
  55039. private static _environmentTextureCDNUrl;
  55040. /**
  55041. * Creates the default options for the helper.
  55042. */
  55043. private static _getDefaultOptions;
  55044. private _rootMesh;
  55045. /**
  55046. * Gets the root mesh created by the helper.
  55047. */
  55048. get rootMesh(): Mesh;
  55049. private _skybox;
  55050. /**
  55051. * Gets the skybox created by the helper.
  55052. */
  55053. get skybox(): Nullable<Mesh>;
  55054. private _skyboxTexture;
  55055. /**
  55056. * Gets the skybox texture created by the helper.
  55057. */
  55058. get skyboxTexture(): Nullable<BaseTexture>;
  55059. private _skyboxMaterial;
  55060. /**
  55061. * Gets the skybox material created by the helper.
  55062. */
  55063. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55064. private _ground;
  55065. /**
  55066. * Gets the ground mesh created by the helper.
  55067. */
  55068. get ground(): Nullable<Mesh>;
  55069. private _groundTexture;
  55070. /**
  55071. * Gets the ground texture created by the helper.
  55072. */
  55073. get groundTexture(): Nullable<BaseTexture>;
  55074. private _groundMirror;
  55075. /**
  55076. * Gets the ground mirror created by the helper.
  55077. */
  55078. get groundMirror(): Nullable<MirrorTexture>;
  55079. /**
  55080. * Gets the ground mirror render list to helps pushing the meshes
  55081. * you wish in the ground reflection.
  55082. */
  55083. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55084. private _groundMaterial;
  55085. /**
  55086. * Gets the ground material created by the helper.
  55087. */
  55088. get groundMaterial(): Nullable<BackgroundMaterial>;
  55089. /**
  55090. * Stores the creation options.
  55091. */
  55092. private readonly _scene;
  55093. private _options;
  55094. /**
  55095. * This observable will be notified with any error during the creation of the environment,
  55096. * mainly texture creation errors.
  55097. */
  55098. onErrorObservable: Observable<{
  55099. message?: string;
  55100. exception?: any;
  55101. }>;
  55102. /**
  55103. * constructor
  55104. * @param options Defines the options we want to customize the helper
  55105. * @param scene The scene to add the material to
  55106. */
  55107. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55108. /**
  55109. * Updates the background according to the new options
  55110. * @param options
  55111. */
  55112. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55113. /**
  55114. * Sets the primary color of all the available elements.
  55115. * @param color the main color to affect to the ground and the background
  55116. */
  55117. setMainColor(color: Color3): void;
  55118. /**
  55119. * Setup the image processing according to the specified options.
  55120. */
  55121. private _setupImageProcessing;
  55122. /**
  55123. * Setup the environment texture according to the specified options.
  55124. */
  55125. private _setupEnvironmentTexture;
  55126. /**
  55127. * Setup the background according to the specified options.
  55128. */
  55129. private _setupBackground;
  55130. /**
  55131. * Get the scene sizes according to the setup.
  55132. */
  55133. private _getSceneSize;
  55134. /**
  55135. * Setup the ground according to the specified options.
  55136. */
  55137. private _setupGround;
  55138. /**
  55139. * Setup the ground material according to the specified options.
  55140. */
  55141. private _setupGroundMaterial;
  55142. /**
  55143. * Setup the ground diffuse texture according to the specified options.
  55144. */
  55145. private _setupGroundDiffuseTexture;
  55146. /**
  55147. * Setup the ground mirror texture according to the specified options.
  55148. */
  55149. private _setupGroundMirrorTexture;
  55150. /**
  55151. * Setup the ground to receive the mirror texture.
  55152. */
  55153. private _setupMirrorInGroundMaterial;
  55154. /**
  55155. * Setup the skybox according to the specified options.
  55156. */
  55157. private _setupSkybox;
  55158. /**
  55159. * Setup the skybox material according to the specified options.
  55160. */
  55161. private _setupSkyboxMaterial;
  55162. /**
  55163. * Setup the skybox reflection texture according to the specified options.
  55164. */
  55165. private _setupSkyboxReflectionTexture;
  55166. private _errorHandler;
  55167. /**
  55168. * Dispose all the elements created by the Helper.
  55169. */
  55170. dispose(): void;
  55171. }
  55172. }
  55173. declare module BABYLON {
  55174. /**
  55175. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55176. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55177. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55178. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55179. */
  55180. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55181. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55182. /**
  55183. * Define the source as a Monoscopic panoramic 360/180.
  55184. */
  55185. static readonly MODE_MONOSCOPIC: number;
  55186. /**
  55187. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55188. */
  55189. static readonly MODE_TOPBOTTOM: number;
  55190. /**
  55191. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55192. */
  55193. static readonly MODE_SIDEBYSIDE: number;
  55194. private _halfDome;
  55195. protected _useDirectMapping: boolean;
  55196. /**
  55197. * The texture being displayed on the sphere
  55198. */
  55199. protected _texture: T;
  55200. /**
  55201. * Gets the texture being displayed on the sphere
  55202. */
  55203. get texture(): T;
  55204. /**
  55205. * Sets the texture being displayed on the sphere
  55206. */
  55207. set texture(newTexture: T);
  55208. /**
  55209. * The skybox material
  55210. */
  55211. protected _material: BackgroundMaterial;
  55212. /**
  55213. * The surface used for the dome
  55214. */
  55215. protected _mesh: Mesh;
  55216. /**
  55217. * Gets the mesh used for the dome.
  55218. */
  55219. get mesh(): Mesh;
  55220. /**
  55221. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55222. */
  55223. private _halfDomeMask;
  55224. /**
  55225. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55226. * Also see the options.resolution property.
  55227. */
  55228. get fovMultiplier(): number;
  55229. set fovMultiplier(value: number);
  55230. protected _textureMode: number;
  55231. /**
  55232. * Gets or set the current texture mode for the texture. It can be:
  55233. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55234. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55235. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55236. */
  55237. get textureMode(): number;
  55238. /**
  55239. * Sets the current texture mode for the texture. It can be:
  55240. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55241. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55242. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55243. */
  55244. set textureMode(value: number);
  55245. /**
  55246. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55247. */
  55248. get halfDome(): boolean;
  55249. /**
  55250. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55251. */
  55252. set halfDome(enabled: boolean);
  55253. /**
  55254. * Oberserver used in Stereoscopic VR Mode.
  55255. */
  55256. private _onBeforeCameraRenderObserver;
  55257. /**
  55258. * Observable raised when an error occured while loading the 360 image
  55259. */
  55260. onLoadErrorObservable: Observable<string>;
  55261. /**
  55262. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55263. * @param name Element's name, child elements will append suffixes for their own names.
  55264. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55265. * @param options An object containing optional or exposed sub element properties
  55266. */
  55267. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55268. resolution?: number;
  55269. clickToPlay?: boolean;
  55270. autoPlay?: boolean;
  55271. loop?: boolean;
  55272. size?: number;
  55273. poster?: string;
  55274. faceForward?: boolean;
  55275. useDirectMapping?: boolean;
  55276. halfDomeMode?: boolean;
  55277. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55278. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55279. protected _changeTextureMode(value: number): void;
  55280. /**
  55281. * Releases resources associated with this node.
  55282. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55283. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55284. */
  55285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55286. }
  55287. }
  55288. declare module BABYLON {
  55289. /**
  55290. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55291. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55292. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55294. */
  55295. export class PhotoDome extends TextureDome<Texture> {
  55296. /**
  55297. * Define the image as a Monoscopic panoramic 360 image.
  55298. */
  55299. static readonly MODE_MONOSCOPIC: number;
  55300. /**
  55301. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55302. */
  55303. static readonly MODE_TOPBOTTOM: number;
  55304. /**
  55305. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55306. */
  55307. static readonly MODE_SIDEBYSIDE: number;
  55308. /**
  55309. * Gets or sets the texture being displayed on the sphere
  55310. */
  55311. get photoTexture(): Texture;
  55312. /**
  55313. * sets the texture being displayed on the sphere
  55314. */
  55315. set photoTexture(value: Texture);
  55316. /**
  55317. * Gets the current video mode for the video. It can be:
  55318. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55319. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55320. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55321. */
  55322. get imageMode(): number;
  55323. /**
  55324. * Sets the current video mode for the video. It can be:
  55325. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55326. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55327. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55328. */
  55329. set imageMode(value: number);
  55330. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55331. }
  55332. }
  55333. declare module BABYLON {
  55334. /**
  55335. * Class used to host RGBD texture specific utilities
  55336. */
  55337. export class RGBDTextureTools {
  55338. /**
  55339. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55340. * @param texture the texture to expand.
  55341. */
  55342. static ExpandRGBDTexture(texture: Texture): void;
  55343. }
  55344. }
  55345. declare module BABYLON {
  55346. /**
  55347. * Class used to host texture specific utilities
  55348. */
  55349. export class BRDFTextureTools {
  55350. /**
  55351. * Prevents texture cache collision
  55352. */
  55353. private static _instanceNumber;
  55354. /**
  55355. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55356. * @param scene defines the hosting scene
  55357. * @returns the environment BRDF texture
  55358. */
  55359. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55360. private static _environmentBRDFBase64Texture;
  55361. }
  55362. }
  55363. declare module BABYLON {
  55364. /**
  55365. * @hidden
  55366. */
  55367. export interface IMaterialClearCoatDefines {
  55368. CLEARCOAT: boolean;
  55369. CLEARCOAT_DEFAULTIOR: boolean;
  55370. CLEARCOAT_TEXTURE: boolean;
  55371. CLEARCOAT_TEXTUREDIRECTUV: number;
  55372. CLEARCOAT_BUMP: boolean;
  55373. CLEARCOAT_BUMPDIRECTUV: number;
  55374. CLEARCOAT_TINT: boolean;
  55375. CLEARCOAT_TINT_TEXTURE: boolean;
  55376. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55377. /** @hidden */
  55378. _areTexturesDirty: boolean;
  55379. }
  55380. /**
  55381. * Define the code related to the clear coat parameters of the pbr material.
  55382. */
  55383. export class PBRClearCoatConfiguration {
  55384. /**
  55385. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55386. * The default fits with a polyurethane material.
  55387. */
  55388. private static readonly _DefaultIndexOfRefraction;
  55389. private _isEnabled;
  55390. /**
  55391. * Defines if the clear coat is enabled in the material.
  55392. */
  55393. isEnabled: boolean;
  55394. /**
  55395. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55396. */
  55397. intensity: number;
  55398. /**
  55399. * Defines the clear coat layer roughness.
  55400. */
  55401. roughness: number;
  55402. private _indexOfRefraction;
  55403. /**
  55404. * Defines the index of refraction of the clear coat.
  55405. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55406. * The default fits with a polyurethane material.
  55407. * Changing the default value is more performance intensive.
  55408. */
  55409. indexOfRefraction: number;
  55410. private _texture;
  55411. /**
  55412. * Stores the clear coat values in a texture.
  55413. */
  55414. texture: Nullable<BaseTexture>;
  55415. private _bumpTexture;
  55416. /**
  55417. * Define the clear coat specific bump texture.
  55418. */
  55419. bumpTexture: Nullable<BaseTexture>;
  55420. private _isTintEnabled;
  55421. /**
  55422. * Defines if the clear coat tint is enabled in the material.
  55423. */
  55424. isTintEnabled: boolean;
  55425. /**
  55426. * Defines the clear coat tint of the material.
  55427. * This is only use if tint is enabled
  55428. */
  55429. tintColor: Color3;
  55430. /**
  55431. * Defines the distance at which the tint color should be found in the
  55432. * clear coat media.
  55433. * This is only use if tint is enabled
  55434. */
  55435. tintColorAtDistance: number;
  55436. /**
  55437. * Defines the clear coat layer thickness.
  55438. * This is only use if tint is enabled
  55439. */
  55440. tintThickness: number;
  55441. private _tintTexture;
  55442. /**
  55443. * Stores the clear tint values in a texture.
  55444. * rgb is tint
  55445. * a is a thickness factor
  55446. */
  55447. tintTexture: Nullable<BaseTexture>;
  55448. /** @hidden */
  55449. private _internalMarkAllSubMeshesAsTexturesDirty;
  55450. /** @hidden */
  55451. _markAllSubMeshesAsTexturesDirty(): void;
  55452. /**
  55453. * Instantiate a new istance of clear coat configuration.
  55454. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55455. */
  55456. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55457. /**
  55458. * Gets wehter the submesh is ready to be used or not.
  55459. * @param defines the list of "defines" to update.
  55460. * @param scene defines the scene the material belongs to.
  55461. * @param engine defines the engine the material belongs to.
  55462. * @param disableBumpMap defines wether the material disables bump or not.
  55463. * @returns - boolean indicating that the submesh is ready or not.
  55464. */
  55465. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55466. /**
  55467. * Checks to see if a texture is used in the material.
  55468. * @param defines the list of "defines" to update.
  55469. * @param scene defines the scene to the material belongs to.
  55470. */
  55471. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55472. /**
  55473. * Binds the material data.
  55474. * @param uniformBuffer defines the Uniform buffer to fill in.
  55475. * @param scene defines the scene the material belongs to.
  55476. * @param engine defines the engine the material belongs to.
  55477. * @param disableBumpMap defines wether the material disables bump or not.
  55478. * @param isFrozen defines wether the material is frozen or not.
  55479. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55480. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55481. */
  55482. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55483. /**
  55484. * Checks to see if a texture is used in the material.
  55485. * @param texture - Base texture to use.
  55486. * @returns - Boolean specifying if a texture is used in the material.
  55487. */
  55488. hasTexture(texture: BaseTexture): boolean;
  55489. /**
  55490. * Returns an array of the actively used textures.
  55491. * @param activeTextures Array of BaseTextures
  55492. */
  55493. getActiveTextures(activeTextures: BaseTexture[]): void;
  55494. /**
  55495. * Returns the animatable textures.
  55496. * @param animatables Array of animatable textures.
  55497. */
  55498. getAnimatables(animatables: IAnimatable[]): void;
  55499. /**
  55500. * Disposes the resources of the material.
  55501. * @param forceDisposeTextures - Forces the disposal of all textures.
  55502. */
  55503. dispose(forceDisposeTextures?: boolean): void;
  55504. /**
  55505. * Get the current class name of the texture useful for serialization or dynamic coding.
  55506. * @returns "PBRClearCoatConfiguration"
  55507. */
  55508. getClassName(): string;
  55509. /**
  55510. * Add fallbacks to the effect fallbacks list.
  55511. * @param defines defines the Base texture to use.
  55512. * @param fallbacks defines the current fallback list.
  55513. * @param currentRank defines the current fallback rank.
  55514. * @returns the new fallback rank.
  55515. */
  55516. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55517. /**
  55518. * Add the required uniforms to the current list.
  55519. * @param uniforms defines the current uniform list.
  55520. */
  55521. static AddUniforms(uniforms: string[]): void;
  55522. /**
  55523. * Add the required samplers to the current list.
  55524. * @param samplers defines the current sampler list.
  55525. */
  55526. static AddSamplers(samplers: string[]): void;
  55527. /**
  55528. * Add the required uniforms to the current buffer.
  55529. * @param uniformBuffer defines the current uniform buffer.
  55530. */
  55531. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55532. /**
  55533. * Makes a duplicate of the current configuration into another one.
  55534. * @param clearCoatConfiguration define the config where to copy the info
  55535. */
  55536. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55537. /**
  55538. * Serializes this clear coat configuration.
  55539. * @returns - An object with the serialized config.
  55540. */
  55541. serialize(): any;
  55542. /**
  55543. * Parses a anisotropy Configuration from a serialized object.
  55544. * @param source - Serialized object.
  55545. * @param scene Defines the scene we are parsing for
  55546. * @param rootUrl Defines the rootUrl to load from
  55547. */
  55548. parse(source: any, scene: Scene, rootUrl: string): void;
  55549. }
  55550. }
  55551. declare module BABYLON {
  55552. /**
  55553. * @hidden
  55554. */
  55555. export interface IMaterialAnisotropicDefines {
  55556. ANISOTROPIC: boolean;
  55557. ANISOTROPIC_TEXTURE: boolean;
  55558. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55559. MAINUV1: boolean;
  55560. _areTexturesDirty: boolean;
  55561. _needUVs: boolean;
  55562. }
  55563. /**
  55564. * Define the code related to the anisotropic parameters of the pbr material.
  55565. */
  55566. export class PBRAnisotropicConfiguration {
  55567. private _isEnabled;
  55568. /**
  55569. * Defines if the anisotropy is enabled in the material.
  55570. */
  55571. isEnabled: boolean;
  55572. /**
  55573. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55574. */
  55575. intensity: number;
  55576. /**
  55577. * Defines if the effect is along the tangents, bitangents or in between.
  55578. * By default, the effect is "strectching" the highlights along the tangents.
  55579. */
  55580. direction: Vector2;
  55581. private _texture;
  55582. /**
  55583. * Stores the anisotropy values in a texture.
  55584. * rg is direction (like normal from -1 to 1)
  55585. * b is a intensity
  55586. */
  55587. texture: Nullable<BaseTexture>;
  55588. /** @hidden */
  55589. private _internalMarkAllSubMeshesAsTexturesDirty;
  55590. /** @hidden */
  55591. _markAllSubMeshesAsTexturesDirty(): void;
  55592. /**
  55593. * Instantiate a new istance of anisotropy configuration.
  55594. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55595. */
  55596. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55597. /**
  55598. * Specifies that the submesh is ready to be used.
  55599. * @param defines the list of "defines" to update.
  55600. * @param scene defines the scene the material belongs to.
  55601. * @returns - boolean indicating that the submesh is ready or not.
  55602. */
  55603. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55604. /**
  55605. * Checks to see if a texture is used in the material.
  55606. * @param defines the list of "defines" to update.
  55607. * @param mesh the mesh we are preparing the defines for.
  55608. * @param scene defines the scene the material belongs to.
  55609. */
  55610. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55611. /**
  55612. * Binds the material data.
  55613. * @param uniformBuffer defines the Uniform buffer to fill in.
  55614. * @param scene defines the scene the material belongs to.
  55615. * @param isFrozen defines wether the material is frozen or not.
  55616. */
  55617. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55618. /**
  55619. * Checks to see if a texture is used in the material.
  55620. * @param texture - Base texture to use.
  55621. * @returns - Boolean specifying if a texture is used in the material.
  55622. */
  55623. hasTexture(texture: BaseTexture): boolean;
  55624. /**
  55625. * Returns an array of the actively used textures.
  55626. * @param activeTextures Array of BaseTextures
  55627. */
  55628. getActiveTextures(activeTextures: BaseTexture[]): void;
  55629. /**
  55630. * Returns the animatable textures.
  55631. * @param animatables Array of animatable textures.
  55632. */
  55633. getAnimatables(animatables: IAnimatable[]): void;
  55634. /**
  55635. * Disposes the resources of the material.
  55636. * @param forceDisposeTextures - Forces the disposal of all textures.
  55637. */
  55638. dispose(forceDisposeTextures?: boolean): void;
  55639. /**
  55640. * Get the current class name of the texture useful for serialization or dynamic coding.
  55641. * @returns "PBRAnisotropicConfiguration"
  55642. */
  55643. getClassName(): string;
  55644. /**
  55645. * Add fallbacks to the effect fallbacks list.
  55646. * @param defines defines the Base texture to use.
  55647. * @param fallbacks defines the current fallback list.
  55648. * @param currentRank defines the current fallback rank.
  55649. * @returns the new fallback rank.
  55650. */
  55651. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55652. /**
  55653. * Add the required uniforms to the current list.
  55654. * @param uniforms defines the current uniform list.
  55655. */
  55656. static AddUniforms(uniforms: string[]): void;
  55657. /**
  55658. * Add the required uniforms to the current buffer.
  55659. * @param uniformBuffer defines the current uniform buffer.
  55660. */
  55661. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55662. /**
  55663. * Add the required samplers to the current list.
  55664. * @param samplers defines the current sampler list.
  55665. */
  55666. static AddSamplers(samplers: string[]): void;
  55667. /**
  55668. * Makes a duplicate of the current configuration into another one.
  55669. * @param anisotropicConfiguration define the config where to copy the info
  55670. */
  55671. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55672. /**
  55673. * Serializes this anisotropy configuration.
  55674. * @returns - An object with the serialized config.
  55675. */
  55676. serialize(): any;
  55677. /**
  55678. * Parses a anisotropy Configuration from a serialized object.
  55679. * @param source - Serialized object.
  55680. * @param scene Defines the scene we are parsing for
  55681. * @param rootUrl Defines the rootUrl to load from
  55682. */
  55683. parse(source: any, scene: Scene, rootUrl: string): void;
  55684. }
  55685. }
  55686. declare module BABYLON {
  55687. /**
  55688. * @hidden
  55689. */
  55690. export interface IMaterialBRDFDefines {
  55691. BRDF_V_HEIGHT_CORRELATED: boolean;
  55692. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55693. SPHERICAL_HARMONICS: boolean;
  55694. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55695. /** @hidden */
  55696. _areMiscDirty: boolean;
  55697. }
  55698. /**
  55699. * Define the code related to the BRDF parameters of the pbr material.
  55700. */
  55701. export class PBRBRDFConfiguration {
  55702. /**
  55703. * Default value used for the energy conservation.
  55704. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55705. */
  55706. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55707. /**
  55708. * Default value used for the Smith Visibility Height Correlated mode.
  55709. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55710. */
  55711. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55712. /**
  55713. * Default value used for the IBL diffuse part.
  55714. * This can help switching back to the polynomials mode globally which is a tiny bit
  55715. * less GPU intensive at the drawback of a lower quality.
  55716. */
  55717. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55718. /**
  55719. * Default value used for activating energy conservation for the specular workflow.
  55720. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55721. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55722. */
  55723. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55724. private _useEnergyConservation;
  55725. /**
  55726. * Defines if the material uses energy conservation.
  55727. */
  55728. useEnergyConservation: boolean;
  55729. private _useSmithVisibilityHeightCorrelated;
  55730. /**
  55731. * LEGACY Mode set to false
  55732. * Defines if the material uses height smith correlated visibility term.
  55733. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55734. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55735. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55736. * Not relying on height correlated will also disable energy conservation.
  55737. */
  55738. useSmithVisibilityHeightCorrelated: boolean;
  55739. private _useSphericalHarmonics;
  55740. /**
  55741. * LEGACY Mode set to false
  55742. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55743. * diffuse part of the IBL.
  55744. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55745. * to the ground truth.
  55746. */
  55747. useSphericalHarmonics: boolean;
  55748. private _useSpecularGlossinessInputEnergyConservation;
  55749. /**
  55750. * Defines if the material uses energy conservation, when the specular workflow is active.
  55751. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55752. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55753. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55754. */
  55755. useSpecularGlossinessInputEnergyConservation: boolean;
  55756. /** @hidden */
  55757. private _internalMarkAllSubMeshesAsMiscDirty;
  55758. /** @hidden */
  55759. _markAllSubMeshesAsMiscDirty(): void;
  55760. /**
  55761. * Instantiate a new istance of clear coat configuration.
  55762. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55763. */
  55764. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55765. /**
  55766. * Checks to see if a texture is used in the material.
  55767. * @param defines the list of "defines" to update.
  55768. */
  55769. prepareDefines(defines: IMaterialBRDFDefines): void;
  55770. /**
  55771. * Get the current class name of the texture useful for serialization or dynamic coding.
  55772. * @returns "PBRClearCoatConfiguration"
  55773. */
  55774. getClassName(): string;
  55775. /**
  55776. * Makes a duplicate of the current configuration into another one.
  55777. * @param brdfConfiguration define the config where to copy the info
  55778. */
  55779. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55780. /**
  55781. * Serializes this BRDF configuration.
  55782. * @returns - An object with the serialized config.
  55783. */
  55784. serialize(): any;
  55785. /**
  55786. * Parses a anisotropy Configuration from a serialized object.
  55787. * @param source - Serialized object.
  55788. * @param scene Defines the scene we are parsing for
  55789. * @param rootUrl Defines the rootUrl to load from
  55790. */
  55791. parse(source: any, scene: Scene, rootUrl: string): void;
  55792. }
  55793. }
  55794. declare module BABYLON {
  55795. /**
  55796. * @hidden
  55797. */
  55798. export interface IMaterialSheenDefines {
  55799. SHEEN: boolean;
  55800. SHEEN_TEXTURE: boolean;
  55801. SHEEN_TEXTUREDIRECTUV: number;
  55802. SHEEN_LINKWITHALBEDO: boolean;
  55803. SHEEN_ROUGHNESS: boolean;
  55804. SHEEN_ALBEDOSCALING: boolean;
  55805. /** @hidden */
  55806. _areTexturesDirty: boolean;
  55807. }
  55808. /**
  55809. * Define the code related to the Sheen parameters of the pbr material.
  55810. */
  55811. export class PBRSheenConfiguration {
  55812. private _isEnabled;
  55813. /**
  55814. * Defines if the material uses sheen.
  55815. */
  55816. isEnabled: boolean;
  55817. private _linkSheenWithAlbedo;
  55818. /**
  55819. * Defines if the sheen is linked to the sheen color.
  55820. */
  55821. linkSheenWithAlbedo: boolean;
  55822. /**
  55823. * Defines the sheen intensity.
  55824. */
  55825. intensity: number;
  55826. /**
  55827. * Defines the sheen color.
  55828. */
  55829. color: Color3;
  55830. private _texture;
  55831. /**
  55832. * Stores the sheen tint values in a texture.
  55833. * rgb is tint
  55834. * a is a intensity or roughness if roughness has been defined
  55835. */
  55836. texture: Nullable<BaseTexture>;
  55837. private _roughness;
  55838. /**
  55839. * Defines the sheen roughness.
  55840. * It is not taken into account if linkSheenWithAlbedo is true.
  55841. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55842. */
  55843. roughness: Nullable<number>;
  55844. private _albedoScaling;
  55845. /**
  55846. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55847. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55848. * making it easier to setup and tweak the effect
  55849. */
  55850. albedoScaling: boolean;
  55851. /** @hidden */
  55852. private _internalMarkAllSubMeshesAsTexturesDirty;
  55853. /** @hidden */
  55854. _markAllSubMeshesAsTexturesDirty(): void;
  55855. /**
  55856. * Instantiate a new istance of clear coat configuration.
  55857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55858. */
  55859. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55860. /**
  55861. * Specifies that the submesh is ready to be used.
  55862. * @param defines the list of "defines" to update.
  55863. * @param scene defines the scene the material belongs to.
  55864. * @returns - boolean indicating that the submesh is ready or not.
  55865. */
  55866. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55867. /**
  55868. * Checks to see if a texture is used in the material.
  55869. * @param defines the list of "defines" to update.
  55870. * @param scene defines the scene the material belongs to.
  55871. */
  55872. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55873. /**
  55874. * Binds the material data.
  55875. * @param uniformBuffer defines the Uniform buffer to fill in.
  55876. * @param scene defines the scene the material belongs to.
  55877. * @param isFrozen defines wether the material is frozen or not.
  55878. */
  55879. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55880. /**
  55881. * Checks to see if a texture is used in the material.
  55882. * @param texture - Base texture to use.
  55883. * @returns - Boolean specifying if a texture is used in the material.
  55884. */
  55885. hasTexture(texture: BaseTexture): boolean;
  55886. /**
  55887. * Returns an array of the actively used textures.
  55888. * @param activeTextures Array of BaseTextures
  55889. */
  55890. getActiveTextures(activeTextures: BaseTexture[]): void;
  55891. /**
  55892. * Returns the animatable textures.
  55893. * @param animatables Array of animatable textures.
  55894. */
  55895. getAnimatables(animatables: IAnimatable[]): void;
  55896. /**
  55897. * Disposes the resources of the material.
  55898. * @param forceDisposeTextures - Forces the disposal of all textures.
  55899. */
  55900. dispose(forceDisposeTextures?: boolean): void;
  55901. /**
  55902. * Get the current class name of the texture useful for serialization or dynamic coding.
  55903. * @returns "PBRSheenConfiguration"
  55904. */
  55905. getClassName(): string;
  55906. /**
  55907. * Add fallbacks to the effect fallbacks list.
  55908. * @param defines defines the Base texture to use.
  55909. * @param fallbacks defines the current fallback list.
  55910. * @param currentRank defines the current fallback rank.
  55911. * @returns the new fallback rank.
  55912. */
  55913. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55914. /**
  55915. * Add the required uniforms to the current list.
  55916. * @param uniforms defines the current uniform list.
  55917. */
  55918. static AddUniforms(uniforms: string[]): void;
  55919. /**
  55920. * Add the required uniforms to the current buffer.
  55921. * @param uniformBuffer defines the current uniform buffer.
  55922. */
  55923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55924. /**
  55925. * Add the required samplers to the current list.
  55926. * @param samplers defines the current sampler list.
  55927. */
  55928. static AddSamplers(samplers: string[]): void;
  55929. /**
  55930. * Makes a duplicate of the current configuration into another one.
  55931. * @param sheenConfiguration define the config where to copy the info
  55932. */
  55933. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55934. /**
  55935. * Serializes this BRDF configuration.
  55936. * @returns - An object with the serialized config.
  55937. */
  55938. serialize(): any;
  55939. /**
  55940. * Parses a anisotropy Configuration from a serialized object.
  55941. * @param source - Serialized object.
  55942. * @param scene Defines the scene we are parsing for
  55943. * @param rootUrl Defines the rootUrl to load from
  55944. */
  55945. parse(source: any, scene: Scene, rootUrl: string): void;
  55946. }
  55947. }
  55948. declare module BABYLON {
  55949. /**
  55950. * @hidden
  55951. */
  55952. export interface IMaterialSubSurfaceDefines {
  55953. SUBSURFACE: boolean;
  55954. SS_REFRACTION: boolean;
  55955. SS_TRANSLUCENCY: boolean;
  55956. SS_SCATTERING: boolean;
  55957. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55958. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55959. SS_REFRACTIONMAP_3D: boolean;
  55960. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55961. SS_LODINREFRACTIONALPHA: boolean;
  55962. SS_GAMMAREFRACTION: boolean;
  55963. SS_RGBDREFRACTION: boolean;
  55964. SS_LINEARSPECULARREFRACTION: boolean;
  55965. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55966. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55967. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55968. /** @hidden */
  55969. _areTexturesDirty: boolean;
  55970. }
  55971. /**
  55972. * Define the code related to the sub surface parameters of the pbr material.
  55973. */
  55974. export class PBRSubSurfaceConfiguration {
  55975. private _isRefractionEnabled;
  55976. /**
  55977. * Defines if the refraction is enabled in the material.
  55978. */
  55979. isRefractionEnabled: boolean;
  55980. private _isTranslucencyEnabled;
  55981. /**
  55982. * Defines if the translucency is enabled in the material.
  55983. */
  55984. isTranslucencyEnabled: boolean;
  55985. private _isScatteringEnabled;
  55986. /**
  55987. * Defines if the sub surface scattering is enabled in the material.
  55988. */
  55989. isScatteringEnabled: boolean;
  55990. private _scatteringDiffusionProfileIndex;
  55991. /**
  55992. * Diffusion profile for subsurface scattering.
  55993. * Useful for better scattering in the skins or foliages.
  55994. */
  55995. get scatteringDiffusionProfile(): Nullable<Color3>;
  55996. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55997. /**
  55998. * Defines the refraction intensity of the material.
  55999. * The refraction when enabled replaces the Diffuse part of the material.
  56000. * The intensity helps transitionning between diffuse and refraction.
  56001. */
  56002. refractionIntensity: number;
  56003. /**
  56004. * Defines the translucency intensity of the material.
  56005. * When translucency has been enabled, this defines how much of the "translucency"
  56006. * is addded to the diffuse part of the material.
  56007. */
  56008. translucencyIntensity: number;
  56009. /**
  56010. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56011. */
  56012. useAlbedoToTintRefraction: boolean;
  56013. private _thicknessTexture;
  56014. /**
  56015. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56016. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56017. * 0 would mean minimumThickness
  56018. * 1 would mean maximumThickness
  56019. * The other channels might be use as a mask to vary the different effects intensity.
  56020. */
  56021. thicknessTexture: Nullable<BaseTexture>;
  56022. private _refractionTexture;
  56023. /**
  56024. * Defines the texture to use for refraction.
  56025. */
  56026. refractionTexture: Nullable<BaseTexture>;
  56027. private _indexOfRefraction;
  56028. /**
  56029. * Index of refraction of the material base layer.
  56030. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56031. *
  56032. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56033. *
  56034. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56035. */
  56036. indexOfRefraction: number;
  56037. private _volumeIndexOfRefraction;
  56038. /**
  56039. * Index of refraction of the material's volume.
  56040. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56041. *
  56042. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56043. * the volume will use the same IOR as the surface.
  56044. */
  56045. get volumeIndexOfRefraction(): number;
  56046. set volumeIndexOfRefraction(value: number);
  56047. private _invertRefractionY;
  56048. /**
  56049. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56050. */
  56051. invertRefractionY: boolean;
  56052. private _linkRefractionWithTransparency;
  56053. /**
  56054. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56055. * Materials half opaque for instance using refraction could benefit from this control.
  56056. */
  56057. linkRefractionWithTransparency: boolean;
  56058. /**
  56059. * Defines the minimum thickness stored in the thickness map.
  56060. * If no thickness map is defined, this value will be used to simulate thickness.
  56061. */
  56062. minimumThickness: number;
  56063. /**
  56064. * Defines the maximum thickness stored in the thickness map.
  56065. */
  56066. maximumThickness: number;
  56067. /**
  56068. * Defines the volume tint of the material.
  56069. * This is used for both translucency and scattering.
  56070. */
  56071. tintColor: Color3;
  56072. /**
  56073. * Defines the distance at which the tint color should be found in the media.
  56074. * This is used for refraction only.
  56075. */
  56076. tintColorAtDistance: number;
  56077. /**
  56078. * Defines how far each channel transmit through the media.
  56079. * It is defined as a color to simplify it selection.
  56080. */
  56081. diffusionDistance: Color3;
  56082. private _useMaskFromThicknessTexture;
  56083. /**
  56084. * Stores the intensity of the different subsurface effects in the thickness texture.
  56085. * * the green channel is the translucency intensity.
  56086. * * the blue channel is the scattering intensity.
  56087. * * the alpha channel is the refraction intensity.
  56088. */
  56089. useMaskFromThicknessTexture: boolean;
  56090. private _scene;
  56091. /** @hidden */
  56092. private _internalMarkAllSubMeshesAsTexturesDirty;
  56093. private _internalMarkScenePrePassDirty;
  56094. /** @hidden */
  56095. _markAllSubMeshesAsTexturesDirty(): void;
  56096. /** @hidden */
  56097. _markScenePrePassDirty(): void;
  56098. /**
  56099. * Instantiate a new istance of sub surface configuration.
  56100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56101. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56102. * @param scene The scene
  56103. */
  56104. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56105. /**
  56106. * Gets wehter the submesh is ready to be used or not.
  56107. * @param defines the list of "defines" to update.
  56108. * @param scene defines the scene the material belongs to.
  56109. * @returns - boolean indicating that the submesh is ready or not.
  56110. */
  56111. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56112. /**
  56113. * Checks to see if a texture is used in the material.
  56114. * @param defines the list of "defines" to update.
  56115. * @param scene defines the scene to the material belongs to.
  56116. */
  56117. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56118. /**
  56119. * Binds the material data.
  56120. * @param uniformBuffer defines the Uniform buffer to fill in.
  56121. * @param scene defines the scene the material belongs to.
  56122. * @param engine defines the engine the material belongs to.
  56123. * @param isFrozen defines whether the material is frozen or not.
  56124. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56125. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56126. */
  56127. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56128. /**
  56129. * Unbinds the material from the mesh.
  56130. * @param activeEffect defines the effect that should be unbound from.
  56131. * @returns true if unbound, otherwise false
  56132. */
  56133. unbind(activeEffect: Effect): boolean;
  56134. /**
  56135. * Returns the texture used for refraction or null if none is used.
  56136. * @param scene defines the scene the material belongs to.
  56137. * @returns - Refraction texture if present. If no refraction texture and refraction
  56138. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56139. */
  56140. private _getRefractionTexture;
  56141. /**
  56142. * Returns true if alpha blending should be disabled.
  56143. */
  56144. get disableAlphaBlending(): boolean;
  56145. /**
  56146. * Fills the list of render target textures.
  56147. * @param renderTargets the list of render targets to update
  56148. */
  56149. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56150. /**
  56151. * Checks to see if a texture is used in the material.
  56152. * @param texture - Base texture to use.
  56153. * @returns - Boolean specifying if a texture is used in the material.
  56154. */
  56155. hasTexture(texture: BaseTexture): boolean;
  56156. /**
  56157. * Gets a boolean indicating that current material needs to register RTT
  56158. * @returns true if this uses a render target otherwise false.
  56159. */
  56160. hasRenderTargetTextures(): boolean;
  56161. /**
  56162. * Returns an array of the actively used textures.
  56163. * @param activeTextures Array of BaseTextures
  56164. */
  56165. getActiveTextures(activeTextures: BaseTexture[]): void;
  56166. /**
  56167. * Returns the animatable textures.
  56168. * @param animatables Array of animatable textures.
  56169. */
  56170. getAnimatables(animatables: IAnimatable[]): void;
  56171. /**
  56172. * Disposes the resources of the material.
  56173. * @param forceDisposeTextures - Forces the disposal of all textures.
  56174. */
  56175. dispose(forceDisposeTextures?: boolean): void;
  56176. /**
  56177. * Get the current class name of the texture useful for serialization or dynamic coding.
  56178. * @returns "PBRSubSurfaceConfiguration"
  56179. */
  56180. getClassName(): string;
  56181. /**
  56182. * Add fallbacks to the effect fallbacks list.
  56183. * @param defines defines the Base texture to use.
  56184. * @param fallbacks defines the current fallback list.
  56185. * @param currentRank defines the current fallback rank.
  56186. * @returns the new fallback rank.
  56187. */
  56188. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56189. /**
  56190. * Add the required uniforms to the current list.
  56191. * @param uniforms defines the current uniform list.
  56192. */
  56193. static AddUniforms(uniforms: string[]): void;
  56194. /**
  56195. * Add the required samplers to the current list.
  56196. * @param samplers defines the current sampler list.
  56197. */
  56198. static AddSamplers(samplers: string[]): void;
  56199. /**
  56200. * Add the required uniforms to the current buffer.
  56201. * @param uniformBuffer defines the current uniform buffer.
  56202. */
  56203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56204. /**
  56205. * Makes a duplicate of the current configuration into another one.
  56206. * @param configuration define the config where to copy the info
  56207. */
  56208. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56209. /**
  56210. * Serializes this Sub Surface configuration.
  56211. * @returns - An object with the serialized config.
  56212. */
  56213. serialize(): any;
  56214. /**
  56215. * Parses a anisotropy Configuration from a serialized object.
  56216. * @param source - Serialized object.
  56217. * @param scene Defines the scene we are parsing for
  56218. * @param rootUrl Defines the rootUrl to load from
  56219. */
  56220. parse(source: any, scene: Scene, rootUrl: string): void;
  56221. }
  56222. }
  56223. declare module BABYLON {
  56224. /** @hidden */
  56225. export var pbrFragmentDeclaration: {
  56226. name: string;
  56227. shader: string;
  56228. };
  56229. }
  56230. declare module BABYLON {
  56231. /** @hidden */
  56232. export var pbrUboDeclaration: {
  56233. name: string;
  56234. shader: string;
  56235. };
  56236. }
  56237. declare module BABYLON {
  56238. /** @hidden */
  56239. export var pbrFragmentExtraDeclaration: {
  56240. name: string;
  56241. shader: string;
  56242. };
  56243. }
  56244. declare module BABYLON {
  56245. /** @hidden */
  56246. export var pbrFragmentSamplersDeclaration: {
  56247. name: string;
  56248. shader: string;
  56249. };
  56250. }
  56251. declare module BABYLON {
  56252. /** @hidden */
  56253. export var importanceSampling: {
  56254. name: string;
  56255. shader: string;
  56256. };
  56257. }
  56258. declare module BABYLON {
  56259. /** @hidden */
  56260. export var pbrHelperFunctions: {
  56261. name: string;
  56262. shader: string;
  56263. };
  56264. }
  56265. declare module BABYLON {
  56266. /** @hidden */
  56267. export var harmonicsFunctions: {
  56268. name: string;
  56269. shader: string;
  56270. };
  56271. }
  56272. declare module BABYLON {
  56273. /** @hidden */
  56274. export var pbrDirectLightingSetupFunctions: {
  56275. name: string;
  56276. shader: string;
  56277. };
  56278. }
  56279. declare module BABYLON {
  56280. /** @hidden */
  56281. export var pbrDirectLightingFalloffFunctions: {
  56282. name: string;
  56283. shader: string;
  56284. };
  56285. }
  56286. declare module BABYLON {
  56287. /** @hidden */
  56288. export var pbrBRDFFunctions: {
  56289. name: string;
  56290. shader: string;
  56291. };
  56292. }
  56293. declare module BABYLON {
  56294. /** @hidden */
  56295. export var hdrFilteringFunctions: {
  56296. name: string;
  56297. shader: string;
  56298. };
  56299. }
  56300. declare module BABYLON {
  56301. /** @hidden */
  56302. export var pbrDirectLightingFunctions: {
  56303. name: string;
  56304. shader: string;
  56305. };
  56306. }
  56307. declare module BABYLON {
  56308. /** @hidden */
  56309. export var pbrIBLFunctions: {
  56310. name: string;
  56311. shader: string;
  56312. };
  56313. }
  56314. declare module BABYLON {
  56315. /** @hidden */
  56316. export var pbrBlockAlbedoOpacity: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module BABYLON {
  56322. /** @hidden */
  56323. export var pbrBlockReflectivity: {
  56324. name: string;
  56325. shader: string;
  56326. };
  56327. }
  56328. declare module BABYLON {
  56329. /** @hidden */
  56330. export var pbrBlockAmbientOcclusion: {
  56331. name: string;
  56332. shader: string;
  56333. };
  56334. }
  56335. declare module BABYLON {
  56336. /** @hidden */
  56337. export var pbrBlockAlphaFresnel: {
  56338. name: string;
  56339. shader: string;
  56340. };
  56341. }
  56342. declare module BABYLON {
  56343. /** @hidden */
  56344. export var pbrBlockAnisotropic: {
  56345. name: string;
  56346. shader: string;
  56347. };
  56348. }
  56349. declare module BABYLON {
  56350. /** @hidden */
  56351. export var pbrBlockReflection: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module BABYLON {
  56357. /** @hidden */
  56358. export var pbrBlockSheen: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON {
  56364. /** @hidden */
  56365. export var pbrBlockClearcoat: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module BABYLON {
  56371. /** @hidden */
  56372. export var pbrBlockSubSurface: {
  56373. name: string;
  56374. shader: string;
  56375. };
  56376. }
  56377. declare module BABYLON {
  56378. /** @hidden */
  56379. export var pbrBlockNormalGeometric: {
  56380. name: string;
  56381. shader: string;
  56382. };
  56383. }
  56384. declare module BABYLON {
  56385. /** @hidden */
  56386. export var pbrBlockNormalFinal: {
  56387. name: string;
  56388. shader: string;
  56389. };
  56390. }
  56391. declare module BABYLON {
  56392. /** @hidden */
  56393. export var pbrBlockLightmapInit: {
  56394. name: string;
  56395. shader: string;
  56396. };
  56397. }
  56398. declare module BABYLON {
  56399. /** @hidden */
  56400. export var pbrBlockGeometryInfo: {
  56401. name: string;
  56402. shader: string;
  56403. };
  56404. }
  56405. declare module BABYLON {
  56406. /** @hidden */
  56407. export var pbrBlockReflectance0: {
  56408. name: string;
  56409. shader: string;
  56410. };
  56411. }
  56412. declare module BABYLON {
  56413. /** @hidden */
  56414. export var pbrBlockReflectance: {
  56415. name: string;
  56416. shader: string;
  56417. };
  56418. }
  56419. declare module BABYLON {
  56420. /** @hidden */
  56421. export var pbrBlockDirectLighting: {
  56422. name: string;
  56423. shader: string;
  56424. };
  56425. }
  56426. declare module BABYLON {
  56427. /** @hidden */
  56428. export var pbrBlockFinalLitComponents: {
  56429. name: string;
  56430. shader: string;
  56431. };
  56432. }
  56433. declare module BABYLON {
  56434. /** @hidden */
  56435. export var pbrBlockFinalUnlitComponents: {
  56436. name: string;
  56437. shader: string;
  56438. };
  56439. }
  56440. declare module BABYLON {
  56441. /** @hidden */
  56442. export var pbrBlockFinalColorComposition: {
  56443. name: string;
  56444. shader: string;
  56445. };
  56446. }
  56447. declare module BABYLON {
  56448. /** @hidden */
  56449. export var pbrBlockImageProcessing: {
  56450. name: string;
  56451. shader: string;
  56452. };
  56453. }
  56454. declare module BABYLON {
  56455. /** @hidden */
  56456. export var pbrDebug: {
  56457. name: string;
  56458. shader: string;
  56459. };
  56460. }
  56461. declare module BABYLON {
  56462. /** @hidden */
  56463. export var pbrPixelShader: {
  56464. name: string;
  56465. shader: string;
  56466. };
  56467. }
  56468. declare module BABYLON {
  56469. /** @hidden */
  56470. export var pbrVertexDeclaration: {
  56471. name: string;
  56472. shader: string;
  56473. };
  56474. }
  56475. declare module BABYLON {
  56476. /** @hidden */
  56477. export var pbrVertexShader: {
  56478. name: string;
  56479. shader: string;
  56480. };
  56481. }
  56482. declare module BABYLON {
  56483. /**
  56484. * Manages the defines for the PBR Material.
  56485. * @hidden
  56486. */
  56487. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56488. PBR: boolean;
  56489. NUM_SAMPLES: string;
  56490. REALTIME_FILTERING: boolean;
  56491. MAINUV1: boolean;
  56492. MAINUV2: boolean;
  56493. UV1: boolean;
  56494. UV2: boolean;
  56495. ALBEDO: boolean;
  56496. GAMMAALBEDO: boolean;
  56497. ALBEDODIRECTUV: number;
  56498. VERTEXCOLOR: boolean;
  56499. DETAIL: boolean;
  56500. DETAILDIRECTUV: number;
  56501. DETAIL_NORMALBLENDMETHOD: number;
  56502. AMBIENT: boolean;
  56503. AMBIENTDIRECTUV: number;
  56504. AMBIENTINGRAYSCALE: boolean;
  56505. OPACITY: boolean;
  56506. VERTEXALPHA: boolean;
  56507. OPACITYDIRECTUV: number;
  56508. OPACITYRGB: boolean;
  56509. ALPHATEST: boolean;
  56510. DEPTHPREPASS: boolean;
  56511. ALPHABLEND: boolean;
  56512. ALPHAFROMALBEDO: boolean;
  56513. ALPHATESTVALUE: string;
  56514. SPECULAROVERALPHA: boolean;
  56515. RADIANCEOVERALPHA: boolean;
  56516. ALPHAFRESNEL: boolean;
  56517. LINEARALPHAFRESNEL: boolean;
  56518. PREMULTIPLYALPHA: boolean;
  56519. EMISSIVE: boolean;
  56520. EMISSIVEDIRECTUV: number;
  56521. REFLECTIVITY: boolean;
  56522. REFLECTIVITYDIRECTUV: number;
  56523. SPECULARTERM: boolean;
  56524. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56525. MICROSURFACEAUTOMATIC: boolean;
  56526. LODBASEDMICROSFURACE: boolean;
  56527. MICROSURFACEMAP: boolean;
  56528. MICROSURFACEMAPDIRECTUV: number;
  56529. METALLICWORKFLOW: boolean;
  56530. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56531. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56532. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56533. AOSTOREINMETALMAPRED: boolean;
  56534. METALLIC_REFLECTANCE: boolean;
  56535. METALLIC_REFLECTANCEDIRECTUV: number;
  56536. ENVIRONMENTBRDF: boolean;
  56537. ENVIRONMENTBRDF_RGBD: boolean;
  56538. NORMAL: boolean;
  56539. TANGENT: boolean;
  56540. BUMP: boolean;
  56541. BUMPDIRECTUV: number;
  56542. OBJECTSPACE_NORMALMAP: boolean;
  56543. PARALLAX: boolean;
  56544. PARALLAXOCCLUSION: boolean;
  56545. NORMALXYSCALE: boolean;
  56546. LIGHTMAP: boolean;
  56547. LIGHTMAPDIRECTUV: number;
  56548. USELIGHTMAPASSHADOWMAP: boolean;
  56549. GAMMALIGHTMAP: boolean;
  56550. RGBDLIGHTMAP: boolean;
  56551. REFLECTION: boolean;
  56552. REFLECTIONMAP_3D: boolean;
  56553. REFLECTIONMAP_SPHERICAL: boolean;
  56554. REFLECTIONMAP_PLANAR: boolean;
  56555. REFLECTIONMAP_CUBIC: boolean;
  56556. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56557. REFLECTIONMAP_PROJECTION: boolean;
  56558. REFLECTIONMAP_SKYBOX: boolean;
  56559. REFLECTIONMAP_EXPLICIT: boolean;
  56560. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56561. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56562. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56563. INVERTCUBICMAP: boolean;
  56564. USESPHERICALFROMREFLECTIONMAP: boolean;
  56565. USEIRRADIANCEMAP: boolean;
  56566. SPHERICAL_HARMONICS: boolean;
  56567. USESPHERICALINVERTEX: boolean;
  56568. REFLECTIONMAP_OPPOSITEZ: boolean;
  56569. LODINREFLECTIONALPHA: boolean;
  56570. GAMMAREFLECTION: boolean;
  56571. RGBDREFLECTION: boolean;
  56572. LINEARSPECULARREFLECTION: boolean;
  56573. RADIANCEOCCLUSION: boolean;
  56574. HORIZONOCCLUSION: boolean;
  56575. INSTANCES: boolean;
  56576. THIN_INSTANCES: boolean;
  56577. PREPASS: boolean;
  56578. SCENE_MRT_COUNT: number;
  56579. NUM_BONE_INFLUENCERS: number;
  56580. BonesPerMesh: number;
  56581. BONETEXTURE: boolean;
  56582. NONUNIFORMSCALING: boolean;
  56583. MORPHTARGETS: boolean;
  56584. MORPHTARGETS_NORMAL: boolean;
  56585. MORPHTARGETS_TANGENT: boolean;
  56586. MORPHTARGETS_UV: boolean;
  56587. NUM_MORPH_INFLUENCERS: number;
  56588. IMAGEPROCESSING: boolean;
  56589. VIGNETTE: boolean;
  56590. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56591. VIGNETTEBLENDMODEOPAQUE: boolean;
  56592. TONEMAPPING: boolean;
  56593. TONEMAPPING_ACES: boolean;
  56594. CONTRAST: boolean;
  56595. COLORCURVES: boolean;
  56596. COLORGRADING: boolean;
  56597. COLORGRADING3D: boolean;
  56598. SAMPLER3DGREENDEPTH: boolean;
  56599. SAMPLER3DBGRMAP: boolean;
  56600. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56601. EXPOSURE: boolean;
  56602. MULTIVIEW: boolean;
  56603. USEPHYSICALLIGHTFALLOFF: boolean;
  56604. USEGLTFLIGHTFALLOFF: boolean;
  56605. TWOSIDEDLIGHTING: boolean;
  56606. SHADOWFLOAT: boolean;
  56607. CLIPPLANE: boolean;
  56608. CLIPPLANE2: boolean;
  56609. CLIPPLANE3: boolean;
  56610. CLIPPLANE4: boolean;
  56611. CLIPPLANE5: boolean;
  56612. CLIPPLANE6: boolean;
  56613. POINTSIZE: boolean;
  56614. FOG: boolean;
  56615. LOGARITHMICDEPTH: boolean;
  56616. FORCENORMALFORWARD: boolean;
  56617. SPECULARAA: boolean;
  56618. CLEARCOAT: boolean;
  56619. CLEARCOAT_DEFAULTIOR: boolean;
  56620. CLEARCOAT_TEXTURE: boolean;
  56621. CLEARCOAT_TEXTUREDIRECTUV: number;
  56622. CLEARCOAT_BUMP: boolean;
  56623. CLEARCOAT_BUMPDIRECTUV: number;
  56624. CLEARCOAT_TINT: boolean;
  56625. CLEARCOAT_TINT_TEXTURE: boolean;
  56626. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56627. ANISOTROPIC: boolean;
  56628. ANISOTROPIC_TEXTURE: boolean;
  56629. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56630. BRDF_V_HEIGHT_CORRELATED: boolean;
  56631. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56632. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56633. SHEEN: boolean;
  56634. SHEEN_TEXTURE: boolean;
  56635. SHEEN_TEXTUREDIRECTUV: number;
  56636. SHEEN_LINKWITHALBEDO: boolean;
  56637. SHEEN_ROUGHNESS: boolean;
  56638. SHEEN_ALBEDOSCALING: boolean;
  56639. SUBSURFACE: boolean;
  56640. SS_REFRACTION: boolean;
  56641. SS_TRANSLUCENCY: boolean;
  56642. SS_SCATTERING: boolean;
  56643. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56644. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56645. SS_REFRACTIONMAP_3D: boolean;
  56646. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56647. SS_LODINREFRACTIONALPHA: boolean;
  56648. SS_GAMMAREFRACTION: boolean;
  56649. SS_RGBDREFRACTION: boolean;
  56650. SS_LINEARSPECULARREFRACTION: boolean;
  56651. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56652. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56653. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56654. UNLIT: boolean;
  56655. DEBUGMODE: number;
  56656. /**
  56657. * Initializes the PBR Material defines.
  56658. */
  56659. constructor();
  56660. /**
  56661. * Resets the PBR Material defines.
  56662. */
  56663. reset(): void;
  56664. }
  56665. /**
  56666. * The Physically based material base class of BJS.
  56667. *
  56668. * This offers the main features of a standard PBR material.
  56669. * For more information, please refer to the documentation :
  56670. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56671. */
  56672. export abstract class PBRBaseMaterial extends PushMaterial {
  56673. /**
  56674. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56675. */
  56676. static readonly PBRMATERIAL_OPAQUE: number;
  56677. /**
  56678. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56679. */
  56680. static readonly PBRMATERIAL_ALPHATEST: number;
  56681. /**
  56682. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56683. */
  56684. static readonly PBRMATERIAL_ALPHABLEND: number;
  56685. /**
  56686. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56687. * They are also discarded below the alpha cutoff threshold to improve performances.
  56688. */
  56689. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56690. /**
  56691. * Defines the default value of how much AO map is occluding the analytical lights
  56692. * (point spot...).
  56693. */
  56694. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56695. /**
  56696. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56697. */
  56698. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56699. /**
  56700. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56701. * to enhance interoperability with other engines.
  56702. */
  56703. static readonly LIGHTFALLOFF_GLTF: number;
  56704. /**
  56705. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56706. * to enhance interoperability with other materials.
  56707. */
  56708. static readonly LIGHTFALLOFF_STANDARD: number;
  56709. /**
  56710. * Intensity of the direct lights e.g. the four lights available in your scene.
  56711. * This impacts both the direct diffuse and specular highlights.
  56712. */
  56713. protected _directIntensity: number;
  56714. /**
  56715. * Intensity of the emissive part of the material.
  56716. * This helps controlling the emissive effect without modifying the emissive color.
  56717. */
  56718. protected _emissiveIntensity: number;
  56719. /**
  56720. * Intensity of the environment e.g. how much the environment will light the object
  56721. * either through harmonics for rough material or through the refelction for shiny ones.
  56722. */
  56723. protected _environmentIntensity: number;
  56724. /**
  56725. * This is a special control allowing the reduction of the specular highlights coming from the
  56726. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56727. */
  56728. protected _specularIntensity: number;
  56729. /**
  56730. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56731. */
  56732. private _lightingInfos;
  56733. /**
  56734. * Debug Control allowing disabling the bump map on this material.
  56735. */
  56736. protected _disableBumpMap: boolean;
  56737. /**
  56738. * AKA Diffuse Texture in standard nomenclature.
  56739. */
  56740. protected _albedoTexture: Nullable<BaseTexture>;
  56741. /**
  56742. * AKA Occlusion Texture in other nomenclature.
  56743. */
  56744. protected _ambientTexture: Nullable<BaseTexture>;
  56745. /**
  56746. * AKA Occlusion Texture Intensity in other nomenclature.
  56747. */
  56748. protected _ambientTextureStrength: number;
  56749. /**
  56750. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56751. * 1 means it completely occludes it
  56752. * 0 mean it has no impact
  56753. */
  56754. protected _ambientTextureImpactOnAnalyticalLights: number;
  56755. /**
  56756. * Stores the alpha values in a texture.
  56757. */
  56758. protected _opacityTexture: Nullable<BaseTexture>;
  56759. /**
  56760. * Stores the reflection values in a texture.
  56761. */
  56762. protected _reflectionTexture: Nullable<BaseTexture>;
  56763. /**
  56764. * Stores the emissive values in a texture.
  56765. */
  56766. protected _emissiveTexture: Nullable<BaseTexture>;
  56767. /**
  56768. * AKA Specular texture in other nomenclature.
  56769. */
  56770. protected _reflectivityTexture: Nullable<BaseTexture>;
  56771. /**
  56772. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56773. */
  56774. protected _metallicTexture: Nullable<BaseTexture>;
  56775. /**
  56776. * Specifies the metallic scalar of the metallic/roughness workflow.
  56777. * Can also be used to scale the metalness values of the metallic texture.
  56778. */
  56779. protected _metallic: Nullable<number>;
  56780. /**
  56781. * Specifies the roughness scalar of the metallic/roughness workflow.
  56782. * Can also be used to scale the roughness values of the metallic texture.
  56783. */
  56784. protected _roughness: Nullable<number>;
  56785. /**
  56786. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56787. * By default the indexOfrefraction is used to compute F0;
  56788. *
  56789. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56790. *
  56791. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56792. * F90 = metallicReflectanceColor;
  56793. */
  56794. protected _metallicF0Factor: number;
  56795. /**
  56796. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56797. * By default the F90 is always 1;
  56798. *
  56799. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56800. *
  56801. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56802. * F90 = metallicReflectanceColor;
  56803. */
  56804. protected _metallicReflectanceColor: Color3;
  56805. /**
  56806. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56807. * This is multiply against the scalar values defined in the material.
  56808. */
  56809. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56810. /**
  56811. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56812. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56813. */
  56814. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56815. /**
  56816. * Stores surface normal data used to displace a mesh in a texture.
  56817. */
  56818. protected _bumpTexture: Nullable<BaseTexture>;
  56819. /**
  56820. * Stores the pre-calculated light information of a mesh in a texture.
  56821. */
  56822. protected _lightmapTexture: Nullable<BaseTexture>;
  56823. /**
  56824. * The color of a material in ambient lighting.
  56825. */
  56826. protected _ambientColor: Color3;
  56827. /**
  56828. * AKA Diffuse Color in other nomenclature.
  56829. */
  56830. protected _albedoColor: Color3;
  56831. /**
  56832. * AKA Specular Color in other nomenclature.
  56833. */
  56834. protected _reflectivityColor: Color3;
  56835. /**
  56836. * The color applied when light is reflected from a material.
  56837. */
  56838. protected _reflectionColor: Color3;
  56839. /**
  56840. * The color applied when light is emitted from a material.
  56841. */
  56842. protected _emissiveColor: Color3;
  56843. /**
  56844. * AKA Glossiness in other nomenclature.
  56845. */
  56846. protected _microSurface: number;
  56847. /**
  56848. * Specifies that the material will use the light map as a show map.
  56849. */
  56850. protected _useLightmapAsShadowmap: boolean;
  56851. /**
  56852. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56853. * makes the reflect vector face the model (under horizon).
  56854. */
  56855. protected _useHorizonOcclusion: boolean;
  56856. /**
  56857. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56858. * too much the area relying on ambient texture to define their ambient occlusion.
  56859. */
  56860. protected _useRadianceOcclusion: boolean;
  56861. /**
  56862. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56863. */
  56864. protected _useAlphaFromAlbedoTexture: boolean;
  56865. /**
  56866. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56867. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56868. */
  56869. protected _useSpecularOverAlpha: boolean;
  56870. /**
  56871. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56872. */
  56873. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56874. /**
  56875. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56876. */
  56877. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56878. /**
  56879. * Specifies if the metallic texture contains the roughness information in its green channel.
  56880. */
  56881. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56882. /**
  56883. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56884. */
  56885. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56886. /**
  56887. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56888. */
  56889. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56890. /**
  56891. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56892. */
  56893. protected _useAmbientInGrayScale: boolean;
  56894. /**
  56895. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56896. * The material will try to infer what glossiness each pixel should be.
  56897. */
  56898. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56899. /**
  56900. * Defines the falloff type used in this material.
  56901. * It by default is Physical.
  56902. */
  56903. protected _lightFalloff: number;
  56904. /**
  56905. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56906. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56907. */
  56908. protected _useRadianceOverAlpha: boolean;
  56909. /**
  56910. * Allows using an object space normal map (instead of tangent space).
  56911. */
  56912. protected _useObjectSpaceNormalMap: boolean;
  56913. /**
  56914. * Allows using the bump map in parallax mode.
  56915. */
  56916. protected _useParallax: boolean;
  56917. /**
  56918. * Allows using the bump map in parallax occlusion mode.
  56919. */
  56920. protected _useParallaxOcclusion: boolean;
  56921. /**
  56922. * Controls the scale bias of the parallax mode.
  56923. */
  56924. protected _parallaxScaleBias: number;
  56925. /**
  56926. * If sets to true, disables all the lights affecting the material.
  56927. */
  56928. protected _disableLighting: boolean;
  56929. /**
  56930. * Number of Simultaneous lights allowed on the material.
  56931. */
  56932. protected _maxSimultaneousLights: number;
  56933. /**
  56934. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56935. */
  56936. protected _invertNormalMapX: boolean;
  56937. /**
  56938. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56939. */
  56940. protected _invertNormalMapY: boolean;
  56941. /**
  56942. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56943. */
  56944. protected _twoSidedLighting: boolean;
  56945. /**
  56946. * Defines the alpha limits in alpha test mode.
  56947. */
  56948. protected _alphaCutOff: number;
  56949. /**
  56950. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56951. */
  56952. protected _forceAlphaTest: boolean;
  56953. /**
  56954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56955. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56956. */
  56957. protected _useAlphaFresnel: boolean;
  56958. /**
  56959. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56960. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56961. */
  56962. protected _useLinearAlphaFresnel: boolean;
  56963. /**
  56964. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56965. * from cos thetav and roughness:
  56966. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56967. */
  56968. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56969. /**
  56970. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56971. */
  56972. protected _forceIrradianceInFragment: boolean;
  56973. private _realTimeFiltering;
  56974. /**
  56975. * Enables realtime filtering on the texture.
  56976. */
  56977. get realTimeFiltering(): boolean;
  56978. set realTimeFiltering(b: boolean);
  56979. private _realTimeFilteringQuality;
  56980. /**
  56981. * Quality switch for realtime filtering
  56982. */
  56983. get realTimeFilteringQuality(): number;
  56984. set realTimeFilteringQuality(n: number);
  56985. /**
  56986. * Can this material render to several textures at once
  56987. */
  56988. get canRenderToMRT(): boolean;
  56989. /**
  56990. * Force normal to face away from face.
  56991. */
  56992. protected _forceNormalForward: boolean;
  56993. /**
  56994. * Enables specular anti aliasing in the PBR shader.
  56995. * It will both interacts on the Geometry for analytical and IBL lighting.
  56996. * It also prefilter the roughness map based on the bump values.
  56997. */
  56998. protected _enableSpecularAntiAliasing: boolean;
  56999. /**
  57000. * Default configuration related to image processing available in the PBR Material.
  57001. */
  57002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57003. /**
  57004. * Keep track of the image processing observer to allow dispose and replace.
  57005. */
  57006. private _imageProcessingObserver;
  57007. /**
  57008. * Attaches a new image processing configuration to the PBR Material.
  57009. * @param configuration
  57010. */
  57011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57012. /**
  57013. * Stores the available render targets.
  57014. */
  57015. private _renderTargets;
  57016. /**
  57017. * Sets the global ambient color for the material used in lighting calculations.
  57018. */
  57019. private _globalAmbientColor;
  57020. /**
  57021. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57022. */
  57023. private _useLogarithmicDepth;
  57024. /**
  57025. * If set to true, no lighting calculations will be applied.
  57026. */
  57027. private _unlit;
  57028. private _debugMode;
  57029. /**
  57030. * @hidden
  57031. * This is reserved for the inspector.
  57032. * Defines the material debug mode.
  57033. * It helps seeing only some components of the material while troubleshooting.
  57034. */
  57035. debugMode: number;
  57036. /**
  57037. * @hidden
  57038. * This is reserved for the inspector.
  57039. * Specify from where on screen the debug mode should start.
  57040. * The value goes from -1 (full screen) to 1 (not visible)
  57041. * It helps with side by side comparison against the final render
  57042. * This defaults to -1
  57043. */
  57044. private debugLimit;
  57045. /**
  57046. * @hidden
  57047. * This is reserved for the inspector.
  57048. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57049. * You can use the factor to better multiply the final value.
  57050. */
  57051. private debugFactor;
  57052. /**
  57053. * Defines the clear coat layer parameters for the material.
  57054. */
  57055. readonly clearCoat: PBRClearCoatConfiguration;
  57056. /**
  57057. * Defines the anisotropic parameters for the material.
  57058. */
  57059. readonly anisotropy: PBRAnisotropicConfiguration;
  57060. /**
  57061. * Defines the BRDF parameters for the material.
  57062. */
  57063. readonly brdf: PBRBRDFConfiguration;
  57064. /**
  57065. * Defines the Sheen parameters for the material.
  57066. */
  57067. readonly sheen: PBRSheenConfiguration;
  57068. /**
  57069. * Defines the SubSurface parameters for the material.
  57070. */
  57071. readonly subSurface: PBRSubSurfaceConfiguration;
  57072. /**
  57073. * Defines the detail map parameters for the material.
  57074. */
  57075. readonly detailMap: DetailMapConfiguration;
  57076. protected _rebuildInParallel: boolean;
  57077. /**
  57078. * Instantiates a new PBRMaterial instance.
  57079. *
  57080. * @param name The material name
  57081. * @param scene The scene the material will be use in.
  57082. */
  57083. constructor(name: string, scene: Scene);
  57084. /**
  57085. * Gets a boolean indicating that current material needs to register RTT
  57086. */
  57087. get hasRenderTargetTextures(): boolean;
  57088. /**
  57089. * Gets the name of the material class.
  57090. */
  57091. getClassName(): string;
  57092. /**
  57093. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57094. */
  57095. get useLogarithmicDepth(): boolean;
  57096. /**
  57097. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57098. */
  57099. set useLogarithmicDepth(value: boolean);
  57100. /**
  57101. * Returns true if alpha blending should be disabled.
  57102. */
  57103. protected get _disableAlphaBlending(): boolean;
  57104. /**
  57105. * Specifies whether or not this material should be rendered in alpha blend mode.
  57106. */
  57107. needAlphaBlending(): boolean;
  57108. /**
  57109. * Specifies whether or not this material should be rendered in alpha test mode.
  57110. */
  57111. needAlphaTesting(): boolean;
  57112. /**
  57113. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57114. */
  57115. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57116. /**
  57117. * Gets the texture used for the alpha test.
  57118. */
  57119. getAlphaTestTexture(): Nullable<BaseTexture>;
  57120. /**
  57121. * Specifies that the submesh is ready to be used.
  57122. * @param mesh - BJS mesh.
  57123. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57124. * @param useInstances - Specifies that instances should be used.
  57125. * @returns - boolean indicating that the submesh is ready or not.
  57126. */
  57127. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57128. /**
  57129. * Specifies if the material uses metallic roughness workflow.
  57130. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57131. */
  57132. isMetallicWorkflow(): boolean;
  57133. private _prepareEffect;
  57134. private _prepareDefines;
  57135. /**
  57136. * Force shader compilation
  57137. */
  57138. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57139. /**
  57140. * Initializes the uniform buffer layout for the shader.
  57141. */
  57142. buildUniformLayout(): void;
  57143. /**
  57144. * Unbinds the material from the mesh
  57145. */
  57146. unbind(): void;
  57147. /**
  57148. * Binds the submesh data.
  57149. * @param world - The world matrix.
  57150. * @param mesh - The BJS mesh.
  57151. * @param subMesh - A submesh of the BJS mesh.
  57152. */
  57153. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57154. /**
  57155. * Returns the animatable textures.
  57156. * @returns - Array of animatable textures.
  57157. */
  57158. getAnimatables(): IAnimatable[];
  57159. /**
  57160. * Returns the texture used for reflections.
  57161. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57162. */
  57163. private _getReflectionTexture;
  57164. /**
  57165. * Returns an array of the actively used textures.
  57166. * @returns - Array of BaseTextures
  57167. */
  57168. getActiveTextures(): BaseTexture[];
  57169. /**
  57170. * Checks to see if a texture is used in the material.
  57171. * @param texture - Base texture to use.
  57172. * @returns - Boolean specifying if a texture is used in the material.
  57173. */
  57174. hasTexture(texture: BaseTexture): boolean;
  57175. /**
  57176. * Sets the required values to the prepass renderer.
  57177. * @param prePassRenderer defines the prepass renderer to setup
  57178. */
  57179. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57180. /**
  57181. * Disposes the resources of the material.
  57182. * @param forceDisposeEffect - Forces the disposal of effects.
  57183. * @param forceDisposeTextures - Forces the disposal of all textures.
  57184. */
  57185. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57186. }
  57187. }
  57188. declare module BABYLON {
  57189. /**
  57190. * The Physically based material of BJS.
  57191. *
  57192. * This offers the main features of a standard PBR material.
  57193. * For more information, please refer to the documentation :
  57194. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57195. */
  57196. export class PBRMaterial extends PBRBaseMaterial {
  57197. /**
  57198. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57199. */
  57200. static readonly PBRMATERIAL_OPAQUE: number;
  57201. /**
  57202. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57203. */
  57204. static readonly PBRMATERIAL_ALPHATEST: number;
  57205. /**
  57206. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57207. */
  57208. static readonly PBRMATERIAL_ALPHABLEND: number;
  57209. /**
  57210. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57211. * They are also discarded below the alpha cutoff threshold to improve performances.
  57212. */
  57213. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57214. /**
  57215. * Defines the default value of how much AO map is occluding the analytical lights
  57216. * (point spot...).
  57217. */
  57218. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57219. /**
  57220. * Intensity of the direct lights e.g. the four lights available in your scene.
  57221. * This impacts both the direct diffuse and specular highlights.
  57222. */
  57223. directIntensity: number;
  57224. /**
  57225. * Intensity of the emissive part of the material.
  57226. * This helps controlling the emissive effect without modifying the emissive color.
  57227. */
  57228. emissiveIntensity: number;
  57229. /**
  57230. * Intensity of the environment e.g. how much the environment will light the object
  57231. * either through harmonics for rough material or through the refelction for shiny ones.
  57232. */
  57233. environmentIntensity: number;
  57234. /**
  57235. * This is a special control allowing the reduction of the specular highlights coming from the
  57236. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57237. */
  57238. specularIntensity: number;
  57239. /**
  57240. * Debug Control allowing disabling the bump map on this material.
  57241. */
  57242. disableBumpMap: boolean;
  57243. /**
  57244. * AKA Diffuse Texture in standard nomenclature.
  57245. */
  57246. albedoTexture: BaseTexture;
  57247. /**
  57248. * AKA Occlusion Texture in other nomenclature.
  57249. */
  57250. ambientTexture: BaseTexture;
  57251. /**
  57252. * AKA Occlusion Texture Intensity in other nomenclature.
  57253. */
  57254. ambientTextureStrength: number;
  57255. /**
  57256. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57257. * 1 means it completely occludes it
  57258. * 0 mean it has no impact
  57259. */
  57260. ambientTextureImpactOnAnalyticalLights: number;
  57261. /**
  57262. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57263. */
  57264. opacityTexture: BaseTexture;
  57265. /**
  57266. * Stores the reflection values in a texture.
  57267. */
  57268. reflectionTexture: Nullable<BaseTexture>;
  57269. /**
  57270. * Stores the emissive values in a texture.
  57271. */
  57272. emissiveTexture: BaseTexture;
  57273. /**
  57274. * AKA Specular texture in other nomenclature.
  57275. */
  57276. reflectivityTexture: BaseTexture;
  57277. /**
  57278. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57279. */
  57280. metallicTexture: BaseTexture;
  57281. /**
  57282. * Specifies the metallic scalar of the metallic/roughness workflow.
  57283. * Can also be used to scale the metalness values of the metallic texture.
  57284. */
  57285. metallic: Nullable<number>;
  57286. /**
  57287. * Specifies the roughness scalar of the metallic/roughness workflow.
  57288. * Can also be used to scale the roughness values of the metallic texture.
  57289. */
  57290. roughness: Nullable<number>;
  57291. /**
  57292. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57293. * By default the indexOfrefraction is used to compute F0;
  57294. *
  57295. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57296. *
  57297. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57298. * F90 = metallicReflectanceColor;
  57299. */
  57300. metallicF0Factor: number;
  57301. /**
  57302. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57303. * By default the F90 is always 1;
  57304. *
  57305. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57306. *
  57307. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57308. * F90 = metallicReflectanceColor;
  57309. */
  57310. metallicReflectanceColor: Color3;
  57311. /**
  57312. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57313. * This is multiply against the scalar values defined in the material.
  57314. */
  57315. metallicReflectanceTexture: Nullable<BaseTexture>;
  57316. /**
  57317. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57318. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57319. */
  57320. microSurfaceTexture: BaseTexture;
  57321. /**
  57322. * Stores surface normal data used to displace a mesh in a texture.
  57323. */
  57324. bumpTexture: BaseTexture;
  57325. /**
  57326. * Stores the pre-calculated light information of a mesh in a texture.
  57327. */
  57328. lightmapTexture: BaseTexture;
  57329. /**
  57330. * Stores the refracted light information in a texture.
  57331. */
  57332. get refractionTexture(): Nullable<BaseTexture>;
  57333. set refractionTexture(value: Nullable<BaseTexture>);
  57334. /**
  57335. * The color of a material in ambient lighting.
  57336. */
  57337. ambientColor: Color3;
  57338. /**
  57339. * AKA Diffuse Color in other nomenclature.
  57340. */
  57341. albedoColor: Color3;
  57342. /**
  57343. * AKA Specular Color in other nomenclature.
  57344. */
  57345. reflectivityColor: Color3;
  57346. /**
  57347. * The color reflected from the material.
  57348. */
  57349. reflectionColor: Color3;
  57350. /**
  57351. * The color emitted from the material.
  57352. */
  57353. emissiveColor: Color3;
  57354. /**
  57355. * AKA Glossiness in other nomenclature.
  57356. */
  57357. microSurface: number;
  57358. /**
  57359. * Index of refraction of the material base layer.
  57360. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57361. *
  57362. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57363. *
  57364. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57365. */
  57366. get indexOfRefraction(): number;
  57367. set indexOfRefraction(value: number);
  57368. /**
  57369. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57370. */
  57371. get invertRefractionY(): boolean;
  57372. set invertRefractionY(value: boolean);
  57373. /**
  57374. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57375. * Materials half opaque for instance using refraction could benefit from this control.
  57376. */
  57377. get linkRefractionWithTransparency(): boolean;
  57378. set linkRefractionWithTransparency(value: boolean);
  57379. /**
  57380. * If true, the light map contains occlusion information instead of lighting info.
  57381. */
  57382. useLightmapAsShadowmap: boolean;
  57383. /**
  57384. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57385. */
  57386. useAlphaFromAlbedoTexture: boolean;
  57387. /**
  57388. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57389. */
  57390. forceAlphaTest: boolean;
  57391. /**
  57392. * Defines the alpha limits in alpha test mode.
  57393. */
  57394. alphaCutOff: number;
  57395. /**
  57396. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57397. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57398. */
  57399. useSpecularOverAlpha: boolean;
  57400. /**
  57401. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57402. */
  57403. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57404. /**
  57405. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57406. */
  57407. useRoughnessFromMetallicTextureAlpha: boolean;
  57408. /**
  57409. * Specifies if the metallic texture contains the roughness information in its green channel.
  57410. */
  57411. useRoughnessFromMetallicTextureGreen: boolean;
  57412. /**
  57413. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57414. */
  57415. useMetallnessFromMetallicTextureBlue: boolean;
  57416. /**
  57417. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57418. */
  57419. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57420. /**
  57421. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57422. */
  57423. useAmbientInGrayScale: boolean;
  57424. /**
  57425. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57426. * The material will try to infer what glossiness each pixel should be.
  57427. */
  57428. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57429. /**
  57430. * BJS is using an harcoded light falloff based on a manually sets up range.
  57431. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57432. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57433. */
  57434. get usePhysicalLightFalloff(): boolean;
  57435. /**
  57436. * BJS is using an harcoded light falloff based on a manually sets up range.
  57437. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57438. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57439. */
  57440. set usePhysicalLightFalloff(value: boolean);
  57441. /**
  57442. * In order to support the falloff compatibility with gltf, a special mode has been added
  57443. * to reproduce the gltf light falloff.
  57444. */
  57445. get useGLTFLightFalloff(): boolean;
  57446. /**
  57447. * In order to support the falloff compatibility with gltf, a special mode has been added
  57448. * to reproduce the gltf light falloff.
  57449. */
  57450. set useGLTFLightFalloff(value: boolean);
  57451. /**
  57452. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57453. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57454. */
  57455. useRadianceOverAlpha: boolean;
  57456. /**
  57457. * Allows using an object space normal map (instead of tangent space).
  57458. */
  57459. useObjectSpaceNormalMap: boolean;
  57460. /**
  57461. * Allows using the bump map in parallax mode.
  57462. */
  57463. useParallax: boolean;
  57464. /**
  57465. * Allows using the bump map in parallax occlusion mode.
  57466. */
  57467. useParallaxOcclusion: boolean;
  57468. /**
  57469. * Controls the scale bias of the parallax mode.
  57470. */
  57471. parallaxScaleBias: number;
  57472. /**
  57473. * If sets to true, disables all the lights affecting the material.
  57474. */
  57475. disableLighting: boolean;
  57476. /**
  57477. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57478. */
  57479. forceIrradianceInFragment: boolean;
  57480. /**
  57481. * Number of Simultaneous lights allowed on the material.
  57482. */
  57483. maxSimultaneousLights: number;
  57484. /**
  57485. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57486. */
  57487. invertNormalMapX: boolean;
  57488. /**
  57489. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57490. */
  57491. invertNormalMapY: boolean;
  57492. /**
  57493. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57494. */
  57495. twoSidedLighting: boolean;
  57496. /**
  57497. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57498. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57499. */
  57500. useAlphaFresnel: boolean;
  57501. /**
  57502. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57503. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57504. */
  57505. useLinearAlphaFresnel: boolean;
  57506. /**
  57507. * Let user defines the brdf lookup texture used for IBL.
  57508. * A default 8bit version is embedded but you could point at :
  57509. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57510. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57511. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57512. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57513. */
  57514. environmentBRDFTexture: Nullable<BaseTexture>;
  57515. /**
  57516. * Force normal to face away from face.
  57517. */
  57518. forceNormalForward: boolean;
  57519. /**
  57520. * Enables specular anti aliasing in the PBR shader.
  57521. * It will both interacts on the Geometry for analytical and IBL lighting.
  57522. * It also prefilter the roughness map based on the bump values.
  57523. */
  57524. enableSpecularAntiAliasing: boolean;
  57525. /**
  57526. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57527. * makes the reflect vector face the model (under horizon).
  57528. */
  57529. useHorizonOcclusion: boolean;
  57530. /**
  57531. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57532. * too much the area relying on ambient texture to define their ambient occlusion.
  57533. */
  57534. useRadianceOcclusion: boolean;
  57535. /**
  57536. * If set to true, no lighting calculations will be applied.
  57537. */
  57538. unlit: boolean;
  57539. /**
  57540. * Gets the image processing configuration used either in this material.
  57541. */
  57542. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57543. /**
  57544. * Sets the Default image processing configuration used either in the this material.
  57545. *
  57546. * If sets to null, the scene one is in use.
  57547. */
  57548. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57549. /**
  57550. * Gets wether the color curves effect is enabled.
  57551. */
  57552. get cameraColorCurvesEnabled(): boolean;
  57553. /**
  57554. * Sets wether the color curves effect is enabled.
  57555. */
  57556. set cameraColorCurvesEnabled(value: boolean);
  57557. /**
  57558. * Gets wether the color grading effect is enabled.
  57559. */
  57560. get cameraColorGradingEnabled(): boolean;
  57561. /**
  57562. * Gets wether the color grading effect is enabled.
  57563. */
  57564. set cameraColorGradingEnabled(value: boolean);
  57565. /**
  57566. * Gets wether tonemapping is enabled or not.
  57567. */
  57568. get cameraToneMappingEnabled(): boolean;
  57569. /**
  57570. * Sets wether tonemapping is enabled or not
  57571. */
  57572. set cameraToneMappingEnabled(value: boolean);
  57573. /**
  57574. * The camera exposure used on this material.
  57575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57576. * This corresponds to a photographic exposure.
  57577. */
  57578. get cameraExposure(): number;
  57579. /**
  57580. * The camera exposure used on this material.
  57581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57582. * This corresponds to a photographic exposure.
  57583. */
  57584. set cameraExposure(value: number);
  57585. /**
  57586. * Gets The camera contrast used on this material.
  57587. */
  57588. get cameraContrast(): number;
  57589. /**
  57590. * Sets The camera contrast used on this material.
  57591. */
  57592. set cameraContrast(value: number);
  57593. /**
  57594. * Gets the Color Grading 2D Lookup Texture.
  57595. */
  57596. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57597. /**
  57598. * Sets the Color Grading 2D Lookup Texture.
  57599. */
  57600. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57601. /**
  57602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57604. * 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;
  57605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57606. */
  57607. get cameraColorCurves(): Nullable<ColorCurves>;
  57608. /**
  57609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57611. * 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;
  57612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57613. */
  57614. set cameraColorCurves(value: Nullable<ColorCurves>);
  57615. /**
  57616. * Instantiates a new PBRMaterial instance.
  57617. *
  57618. * @param name The material name
  57619. * @param scene The scene the material will be use in.
  57620. */
  57621. constructor(name: string, scene: Scene);
  57622. /**
  57623. * Returns the name of this material class.
  57624. */
  57625. getClassName(): string;
  57626. /**
  57627. * Makes a duplicate of the current material.
  57628. * @param name - name to use for the new material.
  57629. */
  57630. clone(name: string): PBRMaterial;
  57631. /**
  57632. * Serializes this PBR Material.
  57633. * @returns - An object with the serialized material.
  57634. */
  57635. serialize(): any;
  57636. /**
  57637. * Parses a PBR Material from a serialized object.
  57638. * @param source - Serialized object.
  57639. * @param scene - BJS scene instance.
  57640. * @param rootUrl - url for the scene object
  57641. * @returns - PBRMaterial
  57642. */
  57643. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57644. }
  57645. }
  57646. declare module BABYLON {
  57647. /**
  57648. * Direct draw surface info
  57649. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57650. */
  57651. export interface DDSInfo {
  57652. /**
  57653. * Width of the texture
  57654. */
  57655. width: number;
  57656. /**
  57657. * Width of the texture
  57658. */
  57659. height: number;
  57660. /**
  57661. * Number of Mipmaps for the texture
  57662. * @see https://en.wikipedia.org/wiki/Mipmap
  57663. */
  57664. mipmapCount: number;
  57665. /**
  57666. * If the textures format is a known fourCC format
  57667. * @see https://www.fourcc.org/
  57668. */
  57669. isFourCC: boolean;
  57670. /**
  57671. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57672. */
  57673. isRGB: boolean;
  57674. /**
  57675. * If the texture is a lumincance format
  57676. */
  57677. isLuminance: boolean;
  57678. /**
  57679. * If this is a cube texture
  57680. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57681. */
  57682. isCube: boolean;
  57683. /**
  57684. * If the texture is a compressed format eg. FOURCC_DXT1
  57685. */
  57686. isCompressed: boolean;
  57687. /**
  57688. * The dxgiFormat of the texture
  57689. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57690. */
  57691. dxgiFormat: number;
  57692. /**
  57693. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57694. */
  57695. textureType: number;
  57696. /**
  57697. * Sphericle polynomial created for the dds texture
  57698. */
  57699. sphericalPolynomial?: SphericalPolynomial;
  57700. }
  57701. /**
  57702. * Class used to provide DDS decompression tools
  57703. */
  57704. export class DDSTools {
  57705. /**
  57706. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57707. */
  57708. static StoreLODInAlphaChannel: boolean;
  57709. /**
  57710. * Gets DDS information from an array buffer
  57711. * @param data defines the array buffer view to read data from
  57712. * @returns the DDS information
  57713. */
  57714. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57715. private static _FloatView;
  57716. private static _Int32View;
  57717. private static _ToHalfFloat;
  57718. private static _FromHalfFloat;
  57719. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57720. private static _GetHalfFloatRGBAArrayBuffer;
  57721. private static _GetFloatRGBAArrayBuffer;
  57722. private static _GetFloatAsUIntRGBAArrayBuffer;
  57723. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57724. private static _GetRGBAArrayBuffer;
  57725. private static _ExtractLongWordOrder;
  57726. private static _GetRGBArrayBuffer;
  57727. private static _GetLuminanceArrayBuffer;
  57728. /**
  57729. * Uploads DDS Levels to a Babylon Texture
  57730. * @hidden
  57731. */
  57732. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57733. }
  57734. interface ThinEngine {
  57735. /**
  57736. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57737. * @param rootUrl defines the url where the file to load is located
  57738. * @param scene defines the current scene
  57739. * @param lodScale defines scale to apply to the mip map selection
  57740. * @param lodOffset defines offset to apply to the mip map selection
  57741. * @param onLoad defines an optional callback raised when the texture is loaded
  57742. * @param onError defines an optional callback raised if there is an issue to load the texture
  57743. * @param format defines the format of the data
  57744. * @param forcedExtension defines the extension to use to pick the right loader
  57745. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57746. * @returns the cube texture as an InternalTexture
  57747. */
  57748. 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;
  57749. }
  57750. }
  57751. declare module BABYLON {
  57752. /**
  57753. * Implementation of the DDS Texture Loader.
  57754. * @hidden
  57755. */
  57756. export class _DDSTextureLoader implements IInternalTextureLoader {
  57757. /**
  57758. * Defines wether the loader supports cascade loading the different faces.
  57759. */
  57760. readonly supportCascades: boolean;
  57761. /**
  57762. * This returns if the loader support the current file information.
  57763. * @param extension defines the file extension of the file being loaded
  57764. * @returns true if the loader can load the specified file
  57765. */
  57766. canLoad(extension: string): boolean;
  57767. /**
  57768. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57769. * @param data contains the texture data
  57770. * @param texture defines the BabylonJS internal texture
  57771. * @param createPolynomials will be true if polynomials have been requested
  57772. * @param onLoad defines the callback to trigger once the texture is ready
  57773. * @param onError defines the callback to trigger in case of error
  57774. */
  57775. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57776. /**
  57777. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57778. * @param data contains the texture data
  57779. * @param texture defines the BabylonJS internal texture
  57780. * @param callback defines the method to call once ready to upload
  57781. */
  57782. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57783. }
  57784. }
  57785. declare module BABYLON {
  57786. /**
  57787. * Implementation of the ENV Texture Loader.
  57788. * @hidden
  57789. */
  57790. export class _ENVTextureLoader implements IInternalTextureLoader {
  57791. /**
  57792. * Defines wether the loader supports cascade loading the different faces.
  57793. */
  57794. readonly supportCascades: boolean;
  57795. /**
  57796. * This returns if the loader support the current file information.
  57797. * @param extension defines the file extension of the file being loaded
  57798. * @returns true if the loader can load the specified file
  57799. */
  57800. canLoad(extension: string): boolean;
  57801. /**
  57802. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57803. * @param data contains the texture data
  57804. * @param texture defines the BabylonJS internal texture
  57805. * @param createPolynomials will be true if polynomials have been requested
  57806. * @param onLoad defines the callback to trigger once the texture is ready
  57807. * @param onError defines the callback to trigger in case of error
  57808. */
  57809. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57810. /**
  57811. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57812. * @param data contains the texture data
  57813. * @param texture defines the BabylonJS internal texture
  57814. * @param callback defines the method to call once ready to upload
  57815. */
  57816. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57817. }
  57818. }
  57819. declare module BABYLON {
  57820. /**
  57821. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57822. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57823. */
  57824. export class KhronosTextureContainer {
  57825. /** contents of the KTX container file */
  57826. data: ArrayBufferView;
  57827. private static HEADER_LEN;
  57828. private static COMPRESSED_2D;
  57829. private static COMPRESSED_3D;
  57830. private static TEX_2D;
  57831. private static TEX_3D;
  57832. /**
  57833. * Gets the openGL type
  57834. */
  57835. glType: number;
  57836. /**
  57837. * Gets the openGL type size
  57838. */
  57839. glTypeSize: number;
  57840. /**
  57841. * Gets the openGL format
  57842. */
  57843. glFormat: number;
  57844. /**
  57845. * Gets the openGL internal format
  57846. */
  57847. glInternalFormat: number;
  57848. /**
  57849. * Gets the base internal format
  57850. */
  57851. glBaseInternalFormat: number;
  57852. /**
  57853. * Gets image width in pixel
  57854. */
  57855. pixelWidth: number;
  57856. /**
  57857. * Gets image height in pixel
  57858. */
  57859. pixelHeight: number;
  57860. /**
  57861. * Gets image depth in pixels
  57862. */
  57863. pixelDepth: number;
  57864. /**
  57865. * Gets the number of array elements
  57866. */
  57867. numberOfArrayElements: number;
  57868. /**
  57869. * Gets the number of faces
  57870. */
  57871. numberOfFaces: number;
  57872. /**
  57873. * Gets the number of mipmap levels
  57874. */
  57875. numberOfMipmapLevels: number;
  57876. /**
  57877. * Gets the bytes of key value data
  57878. */
  57879. bytesOfKeyValueData: number;
  57880. /**
  57881. * Gets the load type
  57882. */
  57883. loadType: number;
  57884. /**
  57885. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57886. */
  57887. isInvalid: boolean;
  57888. /**
  57889. * Creates a new KhronosTextureContainer
  57890. * @param data contents of the KTX container file
  57891. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57892. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57893. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57894. */
  57895. constructor(
  57896. /** contents of the KTX container file */
  57897. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57898. /**
  57899. * Uploads KTX content to a Babylon Texture.
  57900. * It is assumed that the texture has already been created & is currently bound
  57901. * @hidden
  57902. */
  57903. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57904. private _upload2DCompressedLevels;
  57905. /**
  57906. * Checks if the given data starts with a KTX file identifier.
  57907. * @param data the data to check
  57908. * @returns true if the data is a KTX file or false otherwise
  57909. */
  57910. static IsValid(data: ArrayBufferView): boolean;
  57911. }
  57912. }
  57913. declare module BABYLON {
  57914. /**
  57915. * Helper class to push actions to a pool of workers.
  57916. */
  57917. export class WorkerPool implements IDisposable {
  57918. private _workerInfos;
  57919. private _pendingActions;
  57920. /**
  57921. * Constructor
  57922. * @param workers Array of workers to use for actions
  57923. */
  57924. constructor(workers: Array<Worker>);
  57925. /**
  57926. * Terminates all workers and clears any pending actions.
  57927. */
  57928. dispose(): void;
  57929. /**
  57930. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57931. * pended until a worker has completed its action.
  57932. * @param action The action to perform. Call onComplete when the action is complete.
  57933. */
  57934. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57935. private _execute;
  57936. }
  57937. }
  57938. declare module BABYLON {
  57939. /**
  57940. * Class for loading KTX2 files
  57941. * @hidden
  57942. */
  57943. export class KhronosTextureContainer2 {
  57944. private static _WorkerPoolPromise?;
  57945. private static _Initialized;
  57946. private static _Ktx2Decoder;
  57947. /**
  57948. * URL to use when loading the KTX2 decoder module
  57949. */
  57950. static JSModuleURL: string;
  57951. /**
  57952. * Default number of workers used to handle data decoding
  57953. */
  57954. static DefaultNumWorkers: number;
  57955. private static GetDefaultNumWorkers;
  57956. private _engine;
  57957. private static _CreateWorkerPool;
  57958. /**
  57959. * Constructor
  57960. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57961. */
  57962. constructor(engine: ThinEngine, numWorkers?: number);
  57963. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57964. /**
  57965. * Stop all async operations and release resources.
  57966. */
  57967. dispose(): void;
  57968. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57969. /**
  57970. * Checks if the given data starts with a KTX2 file identifier.
  57971. * @param data the data to check
  57972. * @returns true if the data is a KTX2 file or false otherwise
  57973. */
  57974. static IsValid(data: ArrayBufferView): boolean;
  57975. }
  57976. export function workerFunc(): void;
  57977. }
  57978. declare module BABYLON {
  57979. /**
  57980. * Implementation of the KTX Texture Loader.
  57981. * @hidden
  57982. */
  57983. export class _KTXTextureLoader implements IInternalTextureLoader {
  57984. /**
  57985. * Defines wether the loader supports cascade loading the different faces.
  57986. */
  57987. readonly supportCascades: boolean;
  57988. /**
  57989. * This returns if the loader support the current file information.
  57990. * @param extension defines the file extension of the file being loaded
  57991. * @param mimeType defines the optional mime type of the file being loaded
  57992. * @returns true if the loader can load the specified file
  57993. */
  57994. canLoad(extension: string, mimeType?: string): boolean;
  57995. /**
  57996. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57997. * @param data contains the texture data
  57998. * @param texture defines the BabylonJS internal texture
  57999. * @param createPolynomials will be true if polynomials have been requested
  58000. * @param onLoad defines the callback to trigger once the texture is ready
  58001. * @param onError defines the callback to trigger in case of error
  58002. */
  58003. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58004. /**
  58005. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58006. * @param data contains the texture data
  58007. * @param texture defines the BabylonJS internal texture
  58008. * @param callback defines the method to call once ready to upload
  58009. */
  58010. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58011. }
  58012. }
  58013. declare module BABYLON {
  58014. /** @hidden */
  58015. export var _forceSceneHelpersToBundle: boolean;
  58016. interface Scene {
  58017. /**
  58018. * Creates a default light for the scene.
  58019. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58020. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58021. */
  58022. createDefaultLight(replace?: boolean): void;
  58023. /**
  58024. * Creates a default camera for the scene.
  58025. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58026. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58027. * @param replace has default false, when true replaces the active camera in the scene
  58028. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58029. */
  58030. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58031. /**
  58032. * Creates a default camera and a default light.
  58033. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58034. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58035. * @param replace has the default false, when true replaces the active camera/light in the scene
  58036. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58037. */
  58038. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58039. /**
  58040. * Creates a new sky box
  58041. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58042. * @param environmentTexture defines the texture to use as environment texture
  58043. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58044. * @param scale defines the overall scale of the skybox
  58045. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58046. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58047. * @returns a new mesh holding the sky box
  58048. */
  58049. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58050. /**
  58051. * Creates a new environment
  58052. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58053. * @param options defines the options you can use to configure the environment
  58054. * @returns the new EnvironmentHelper
  58055. */
  58056. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58057. /**
  58058. * Creates a new VREXperienceHelper
  58059. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58060. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58061. * @returns a new VREXperienceHelper
  58062. */
  58063. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58064. /**
  58065. * Creates a new WebXRDefaultExperience
  58066. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58067. * @param options experience options
  58068. * @returns a promise for a new WebXRDefaultExperience
  58069. */
  58070. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58071. }
  58072. }
  58073. declare module BABYLON {
  58074. /**
  58075. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58076. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58077. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58078. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58079. */
  58080. export class VideoDome extends TextureDome<VideoTexture> {
  58081. /**
  58082. * Define the video source as a Monoscopic panoramic 360 video.
  58083. */
  58084. static readonly MODE_MONOSCOPIC: number;
  58085. /**
  58086. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58087. */
  58088. static readonly MODE_TOPBOTTOM: number;
  58089. /**
  58090. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58091. */
  58092. static readonly MODE_SIDEBYSIDE: number;
  58093. /**
  58094. * Get the video texture associated with this video dome
  58095. */
  58096. get videoTexture(): VideoTexture;
  58097. /**
  58098. * Get the video mode of this dome
  58099. */
  58100. get videoMode(): number;
  58101. /**
  58102. * Set the video mode of this dome.
  58103. * @see textureMode
  58104. */
  58105. set videoMode(value: number);
  58106. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58107. }
  58108. }
  58109. declare module BABYLON {
  58110. /**
  58111. * This class can be used to get instrumentation data from a Babylon engine
  58112. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58113. */
  58114. export class EngineInstrumentation implements IDisposable {
  58115. /**
  58116. * Define the instrumented engine.
  58117. */
  58118. engine: Engine;
  58119. private _captureGPUFrameTime;
  58120. private _gpuFrameTimeToken;
  58121. private _gpuFrameTime;
  58122. private _captureShaderCompilationTime;
  58123. private _shaderCompilationTime;
  58124. private _onBeginFrameObserver;
  58125. private _onEndFrameObserver;
  58126. private _onBeforeShaderCompilationObserver;
  58127. private _onAfterShaderCompilationObserver;
  58128. /**
  58129. * Gets the perf counter used for GPU frame time
  58130. */
  58131. get gpuFrameTimeCounter(): PerfCounter;
  58132. /**
  58133. * Gets the GPU frame time capture status
  58134. */
  58135. get captureGPUFrameTime(): boolean;
  58136. /**
  58137. * Enable or disable the GPU frame time capture
  58138. */
  58139. set captureGPUFrameTime(value: boolean);
  58140. /**
  58141. * Gets the perf counter used for shader compilation time
  58142. */
  58143. get shaderCompilationTimeCounter(): PerfCounter;
  58144. /**
  58145. * Gets the shader compilation time capture status
  58146. */
  58147. get captureShaderCompilationTime(): boolean;
  58148. /**
  58149. * Enable or disable the shader compilation time capture
  58150. */
  58151. set captureShaderCompilationTime(value: boolean);
  58152. /**
  58153. * Instantiates a new engine instrumentation.
  58154. * This class can be used to get instrumentation data from a Babylon engine
  58155. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58156. * @param engine Defines the engine to instrument
  58157. */
  58158. constructor(
  58159. /**
  58160. * Define the instrumented engine.
  58161. */
  58162. engine: Engine);
  58163. /**
  58164. * Dispose and release associated resources.
  58165. */
  58166. dispose(): void;
  58167. }
  58168. }
  58169. declare module BABYLON {
  58170. /**
  58171. * This class can be used to get instrumentation data from a Babylon engine
  58172. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58173. */
  58174. export class SceneInstrumentation implements IDisposable {
  58175. /**
  58176. * Defines the scene to instrument
  58177. */
  58178. scene: Scene;
  58179. private _captureActiveMeshesEvaluationTime;
  58180. private _activeMeshesEvaluationTime;
  58181. private _captureRenderTargetsRenderTime;
  58182. private _renderTargetsRenderTime;
  58183. private _captureFrameTime;
  58184. private _frameTime;
  58185. private _captureRenderTime;
  58186. private _renderTime;
  58187. private _captureInterFrameTime;
  58188. private _interFrameTime;
  58189. private _captureParticlesRenderTime;
  58190. private _particlesRenderTime;
  58191. private _captureSpritesRenderTime;
  58192. private _spritesRenderTime;
  58193. private _capturePhysicsTime;
  58194. private _physicsTime;
  58195. private _captureAnimationsTime;
  58196. private _animationsTime;
  58197. private _captureCameraRenderTime;
  58198. private _cameraRenderTime;
  58199. private _onBeforeActiveMeshesEvaluationObserver;
  58200. private _onAfterActiveMeshesEvaluationObserver;
  58201. private _onBeforeRenderTargetsRenderObserver;
  58202. private _onAfterRenderTargetsRenderObserver;
  58203. private _onAfterRenderObserver;
  58204. private _onBeforeDrawPhaseObserver;
  58205. private _onAfterDrawPhaseObserver;
  58206. private _onBeforeAnimationsObserver;
  58207. private _onBeforeParticlesRenderingObserver;
  58208. private _onAfterParticlesRenderingObserver;
  58209. private _onBeforeSpritesRenderingObserver;
  58210. private _onAfterSpritesRenderingObserver;
  58211. private _onBeforePhysicsObserver;
  58212. private _onAfterPhysicsObserver;
  58213. private _onAfterAnimationsObserver;
  58214. private _onBeforeCameraRenderObserver;
  58215. private _onAfterCameraRenderObserver;
  58216. /**
  58217. * Gets the perf counter used for active meshes evaluation time
  58218. */
  58219. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58220. /**
  58221. * Gets the active meshes evaluation time capture status
  58222. */
  58223. get captureActiveMeshesEvaluationTime(): boolean;
  58224. /**
  58225. * Enable or disable the active meshes evaluation time capture
  58226. */
  58227. set captureActiveMeshesEvaluationTime(value: boolean);
  58228. /**
  58229. * Gets the perf counter used for render targets render time
  58230. */
  58231. get renderTargetsRenderTimeCounter(): PerfCounter;
  58232. /**
  58233. * Gets the render targets render time capture status
  58234. */
  58235. get captureRenderTargetsRenderTime(): boolean;
  58236. /**
  58237. * Enable or disable the render targets render time capture
  58238. */
  58239. set captureRenderTargetsRenderTime(value: boolean);
  58240. /**
  58241. * Gets the perf counter used for particles render time
  58242. */
  58243. get particlesRenderTimeCounter(): PerfCounter;
  58244. /**
  58245. * Gets the particles render time capture status
  58246. */
  58247. get captureParticlesRenderTime(): boolean;
  58248. /**
  58249. * Enable or disable the particles render time capture
  58250. */
  58251. set captureParticlesRenderTime(value: boolean);
  58252. /**
  58253. * Gets the perf counter used for sprites render time
  58254. */
  58255. get spritesRenderTimeCounter(): PerfCounter;
  58256. /**
  58257. * Gets the sprites render time capture status
  58258. */
  58259. get captureSpritesRenderTime(): boolean;
  58260. /**
  58261. * Enable or disable the sprites render time capture
  58262. */
  58263. set captureSpritesRenderTime(value: boolean);
  58264. /**
  58265. * Gets the perf counter used for physics time
  58266. */
  58267. get physicsTimeCounter(): PerfCounter;
  58268. /**
  58269. * Gets the physics time capture status
  58270. */
  58271. get capturePhysicsTime(): boolean;
  58272. /**
  58273. * Enable or disable the physics time capture
  58274. */
  58275. set capturePhysicsTime(value: boolean);
  58276. /**
  58277. * Gets the perf counter used for animations time
  58278. */
  58279. get animationsTimeCounter(): PerfCounter;
  58280. /**
  58281. * Gets the animations time capture status
  58282. */
  58283. get captureAnimationsTime(): boolean;
  58284. /**
  58285. * Enable or disable the animations time capture
  58286. */
  58287. set captureAnimationsTime(value: boolean);
  58288. /**
  58289. * Gets the perf counter used for frame time capture
  58290. */
  58291. get frameTimeCounter(): PerfCounter;
  58292. /**
  58293. * Gets the frame time capture status
  58294. */
  58295. get captureFrameTime(): boolean;
  58296. /**
  58297. * Enable or disable the frame time capture
  58298. */
  58299. set captureFrameTime(value: boolean);
  58300. /**
  58301. * Gets the perf counter used for inter-frames time capture
  58302. */
  58303. get interFrameTimeCounter(): PerfCounter;
  58304. /**
  58305. * Gets the inter-frames time capture status
  58306. */
  58307. get captureInterFrameTime(): boolean;
  58308. /**
  58309. * Enable or disable the inter-frames time capture
  58310. */
  58311. set captureInterFrameTime(value: boolean);
  58312. /**
  58313. * Gets the perf counter used for render time capture
  58314. */
  58315. get renderTimeCounter(): PerfCounter;
  58316. /**
  58317. * Gets the render time capture status
  58318. */
  58319. get captureRenderTime(): boolean;
  58320. /**
  58321. * Enable or disable the render time capture
  58322. */
  58323. set captureRenderTime(value: boolean);
  58324. /**
  58325. * Gets the perf counter used for camera render time capture
  58326. */
  58327. get cameraRenderTimeCounter(): PerfCounter;
  58328. /**
  58329. * Gets the camera render time capture status
  58330. */
  58331. get captureCameraRenderTime(): boolean;
  58332. /**
  58333. * Enable or disable the camera render time capture
  58334. */
  58335. set captureCameraRenderTime(value: boolean);
  58336. /**
  58337. * Gets the perf counter used for draw calls
  58338. */
  58339. get drawCallsCounter(): PerfCounter;
  58340. /**
  58341. * Instantiates a new scene instrumentation.
  58342. * This class can be used to get instrumentation data from a Babylon engine
  58343. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58344. * @param scene Defines the scene to instrument
  58345. */
  58346. constructor(
  58347. /**
  58348. * Defines the scene to instrument
  58349. */
  58350. scene: Scene);
  58351. /**
  58352. * Dispose and release associated resources.
  58353. */
  58354. dispose(): void;
  58355. }
  58356. }
  58357. declare module BABYLON {
  58358. /** @hidden */
  58359. export var glowMapGenerationPixelShader: {
  58360. name: string;
  58361. shader: string;
  58362. };
  58363. }
  58364. declare module BABYLON {
  58365. /** @hidden */
  58366. export var glowMapGenerationVertexShader: {
  58367. name: string;
  58368. shader: string;
  58369. };
  58370. }
  58371. declare module BABYLON {
  58372. /**
  58373. * Effect layer options. This helps customizing the behaviour
  58374. * of the effect layer.
  58375. */
  58376. export interface IEffectLayerOptions {
  58377. /**
  58378. * Multiplication factor apply to the canvas size to compute the render target size
  58379. * used to generated the objects (the smaller the faster).
  58380. */
  58381. mainTextureRatio: number;
  58382. /**
  58383. * Enforces a fixed size texture to ensure effect stability across devices.
  58384. */
  58385. mainTextureFixedSize?: number;
  58386. /**
  58387. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58388. */
  58389. alphaBlendingMode: number;
  58390. /**
  58391. * The camera attached to the layer.
  58392. */
  58393. camera: Nullable<Camera>;
  58394. /**
  58395. * The rendering group to draw the layer in.
  58396. */
  58397. renderingGroupId: number;
  58398. }
  58399. /**
  58400. * The effect layer Helps adding post process effect blended with the main pass.
  58401. *
  58402. * This can be for instance use to generate glow or higlight effects on the scene.
  58403. *
  58404. * The effect layer class can not be used directly and is intented to inherited from to be
  58405. * customized per effects.
  58406. */
  58407. export abstract class EffectLayer {
  58408. private _vertexBuffers;
  58409. private _indexBuffer;
  58410. private _cachedDefines;
  58411. private _effectLayerMapGenerationEffect;
  58412. private _effectLayerOptions;
  58413. private _mergeEffect;
  58414. protected _scene: Scene;
  58415. protected _engine: Engine;
  58416. protected _maxSize: number;
  58417. protected _mainTextureDesiredSize: ISize;
  58418. protected _mainTexture: RenderTargetTexture;
  58419. protected _shouldRender: boolean;
  58420. protected _postProcesses: PostProcess[];
  58421. protected _textures: BaseTexture[];
  58422. protected _emissiveTextureAndColor: {
  58423. texture: Nullable<BaseTexture>;
  58424. color: Color4;
  58425. };
  58426. /**
  58427. * The name of the layer
  58428. */
  58429. name: string;
  58430. /**
  58431. * The clear color of the texture used to generate the glow map.
  58432. */
  58433. neutralColor: Color4;
  58434. /**
  58435. * Specifies whether the highlight layer is enabled or not.
  58436. */
  58437. isEnabled: boolean;
  58438. /**
  58439. * Gets the camera attached to the layer.
  58440. */
  58441. get camera(): Nullable<Camera>;
  58442. /**
  58443. * Gets the rendering group id the layer should render in.
  58444. */
  58445. get renderingGroupId(): number;
  58446. set renderingGroupId(renderingGroupId: number);
  58447. /**
  58448. * An event triggered when the effect layer has been disposed.
  58449. */
  58450. onDisposeObservable: Observable<EffectLayer>;
  58451. /**
  58452. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58453. */
  58454. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58455. /**
  58456. * An event triggered when the generated texture is being merged in the scene.
  58457. */
  58458. onBeforeComposeObservable: Observable<EffectLayer>;
  58459. /**
  58460. * An event triggered when the mesh is rendered into the effect render target.
  58461. */
  58462. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58463. /**
  58464. * An event triggered after the mesh has been rendered into the effect render target.
  58465. */
  58466. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58467. /**
  58468. * An event triggered when the generated texture has been merged in the scene.
  58469. */
  58470. onAfterComposeObservable: Observable<EffectLayer>;
  58471. /**
  58472. * An event triggered when the efffect layer changes its size.
  58473. */
  58474. onSizeChangedObservable: Observable<EffectLayer>;
  58475. /** @hidden */
  58476. static _SceneComponentInitialization: (scene: Scene) => void;
  58477. /**
  58478. * Instantiates a new effect Layer and references it in the scene.
  58479. * @param name The name of the layer
  58480. * @param scene The scene to use the layer in
  58481. */
  58482. constructor(
  58483. /** The Friendly of the effect in the scene */
  58484. name: string, scene: Scene);
  58485. /**
  58486. * Get the effect name of the layer.
  58487. * @return The effect name
  58488. */
  58489. abstract getEffectName(): string;
  58490. /**
  58491. * Checks for the readiness of the element composing the layer.
  58492. * @param subMesh the mesh to check for
  58493. * @param useInstances specify whether or not to use instances to render the mesh
  58494. * @return true if ready otherwise, false
  58495. */
  58496. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58497. /**
  58498. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58499. * @returns true if the effect requires stencil during the main canvas render pass.
  58500. */
  58501. abstract needStencil(): boolean;
  58502. /**
  58503. * Create the merge effect. This is the shader use to blit the information back
  58504. * to the main canvas at the end of the scene rendering.
  58505. * @returns The effect containing the shader used to merge the effect on the main canvas
  58506. */
  58507. protected abstract _createMergeEffect(): Effect;
  58508. /**
  58509. * Creates the render target textures and post processes used in the effect layer.
  58510. */
  58511. protected abstract _createTextureAndPostProcesses(): void;
  58512. /**
  58513. * Implementation specific of rendering the generating effect on the main canvas.
  58514. * @param effect The effect used to render through
  58515. */
  58516. protected abstract _internalRender(effect: Effect): void;
  58517. /**
  58518. * Sets the required values for both the emissive texture and and the main color.
  58519. */
  58520. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58521. /**
  58522. * Free any resources and references associated to a mesh.
  58523. * Internal use
  58524. * @param mesh The mesh to free.
  58525. */
  58526. abstract _disposeMesh(mesh: Mesh): void;
  58527. /**
  58528. * Serializes this layer (Glow or Highlight for example)
  58529. * @returns a serialized layer object
  58530. */
  58531. abstract serialize?(): any;
  58532. /**
  58533. * Initializes the effect layer with the required options.
  58534. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58535. */
  58536. protected _init(options: Partial<IEffectLayerOptions>): void;
  58537. /**
  58538. * Generates the index buffer of the full screen quad blending to the main canvas.
  58539. */
  58540. private _generateIndexBuffer;
  58541. /**
  58542. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58543. */
  58544. private _generateVertexBuffer;
  58545. /**
  58546. * Sets the main texture desired size which is the closest power of two
  58547. * of the engine canvas size.
  58548. */
  58549. private _setMainTextureSize;
  58550. /**
  58551. * Creates the main texture for the effect layer.
  58552. */
  58553. protected _createMainTexture(): void;
  58554. /**
  58555. * Adds specific effects defines.
  58556. * @param defines The defines to add specifics to.
  58557. */
  58558. protected _addCustomEffectDefines(defines: string[]): void;
  58559. /**
  58560. * Checks for the readiness of the element composing the layer.
  58561. * @param subMesh the mesh to check for
  58562. * @param useInstances specify whether or not to use instances to render the mesh
  58563. * @param emissiveTexture the associated emissive texture used to generate the glow
  58564. * @return true if ready otherwise, false
  58565. */
  58566. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58567. /**
  58568. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58569. */
  58570. render(): void;
  58571. /**
  58572. * Determine if a given mesh will be used in the current effect.
  58573. * @param mesh mesh to test
  58574. * @returns true if the mesh will be used
  58575. */
  58576. hasMesh(mesh: AbstractMesh): boolean;
  58577. /**
  58578. * Returns true if the layer contains information to display, otherwise false.
  58579. * @returns true if the glow layer should be rendered
  58580. */
  58581. shouldRender(): boolean;
  58582. /**
  58583. * Returns true if the mesh should render, otherwise false.
  58584. * @param mesh The mesh to render
  58585. * @returns true if it should render otherwise false
  58586. */
  58587. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58588. /**
  58589. * Returns true if the mesh can be rendered, otherwise false.
  58590. * @param mesh The mesh to render
  58591. * @param material The material used on the mesh
  58592. * @returns true if it can be rendered otherwise false
  58593. */
  58594. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58595. /**
  58596. * Returns true if the mesh should render, otherwise false.
  58597. * @param mesh The mesh to render
  58598. * @returns true if it should render otherwise false
  58599. */
  58600. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58601. /**
  58602. * Renders the submesh passed in parameter to the generation map.
  58603. */
  58604. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58605. /**
  58606. * Defines whether the current material of the mesh should be use to render the effect.
  58607. * @param mesh defines the current mesh to render
  58608. */
  58609. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58610. /**
  58611. * Rebuild the required buffers.
  58612. * @hidden Internal use only.
  58613. */
  58614. _rebuild(): void;
  58615. /**
  58616. * Dispose only the render target textures and post process.
  58617. */
  58618. private _disposeTextureAndPostProcesses;
  58619. /**
  58620. * Dispose the highlight layer and free resources.
  58621. */
  58622. dispose(): void;
  58623. /**
  58624. * Gets the class name of the effect layer
  58625. * @returns the string with the class name of the effect layer
  58626. */
  58627. getClassName(): string;
  58628. /**
  58629. * Creates an effect layer from parsed effect layer data
  58630. * @param parsedEffectLayer defines effect layer data
  58631. * @param scene defines the current scene
  58632. * @param rootUrl defines the root URL containing the effect layer information
  58633. * @returns a parsed effect Layer
  58634. */
  58635. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58636. }
  58637. }
  58638. declare module BABYLON {
  58639. interface AbstractScene {
  58640. /**
  58641. * The list of effect layers (highlights/glow) added to the scene
  58642. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58643. * @see https://doc.babylonjs.com/how_to/glow_layer
  58644. */
  58645. effectLayers: Array<EffectLayer>;
  58646. /**
  58647. * Removes the given effect layer from this scene.
  58648. * @param toRemove defines the effect layer to remove
  58649. * @returns the index of the removed effect layer
  58650. */
  58651. removeEffectLayer(toRemove: EffectLayer): number;
  58652. /**
  58653. * Adds the given effect layer to this scene
  58654. * @param newEffectLayer defines the effect layer to add
  58655. */
  58656. addEffectLayer(newEffectLayer: EffectLayer): void;
  58657. }
  58658. /**
  58659. * Defines the layer scene component responsible to manage any effect layers
  58660. * in a given scene.
  58661. */
  58662. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58663. /**
  58664. * The component name helpfull to identify the component in the list of scene components.
  58665. */
  58666. readonly name: string;
  58667. /**
  58668. * The scene the component belongs to.
  58669. */
  58670. scene: Scene;
  58671. private _engine;
  58672. private _renderEffects;
  58673. private _needStencil;
  58674. private _previousStencilState;
  58675. /**
  58676. * Creates a new instance of the component for the given scene
  58677. * @param scene Defines the scene to register the component in
  58678. */
  58679. constructor(scene: Scene);
  58680. /**
  58681. * Registers the component in a given scene
  58682. */
  58683. register(): void;
  58684. /**
  58685. * Rebuilds the elements related to this component in case of
  58686. * context lost for instance.
  58687. */
  58688. rebuild(): void;
  58689. /**
  58690. * Serializes the component data to the specified json object
  58691. * @param serializationObject The object to serialize to
  58692. */
  58693. serialize(serializationObject: any): void;
  58694. /**
  58695. * Adds all the elements from the container to the scene
  58696. * @param container the container holding the elements
  58697. */
  58698. addFromContainer(container: AbstractScene): void;
  58699. /**
  58700. * Removes all the elements in the container from the scene
  58701. * @param container contains the elements to remove
  58702. * @param dispose if the removed element should be disposed (default: false)
  58703. */
  58704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58705. /**
  58706. * Disposes the component and the associated ressources.
  58707. */
  58708. dispose(): void;
  58709. private _isReadyForMesh;
  58710. private _renderMainTexture;
  58711. private _setStencil;
  58712. private _setStencilBack;
  58713. private _draw;
  58714. private _drawCamera;
  58715. private _drawRenderingGroup;
  58716. }
  58717. }
  58718. declare module BABYLON {
  58719. /** @hidden */
  58720. export var glowMapMergePixelShader: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module BABYLON {
  58726. /** @hidden */
  58727. export var glowMapMergeVertexShader: {
  58728. name: string;
  58729. shader: string;
  58730. };
  58731. }
  58732. declare module BABYLON {
  58733. interface AbstractScene {
  58734. /**
  58735. * Return a the first highlight layer of the scene with a given name.
  58736. * @param name The name of the highlight layer to look for.
  58737. * @return The highlight layer if found otherwise null.
  58738. */
  58739. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58740. }
  58741. /**
  58742. * Glow layer options. This helps customizing the behaviour
  58743. * of the glow layer.
  58744. */
  58745. export interface IGlowLayerOptions {
  58746. /**
  58747. * Multiplication factor apply to the canvas size to compute the render target size
  58748. * used to generated the glowing objects (the smaller the faster).
  58749. */
  58750. mainTextureRatio: number;
  58751. /**
  58752. * Enforces a fixed size texture to ensure resize independant blur.
  58753. */
  58754. mainTextureFixedSize?: number;
  58755. /**
  58756. * How big is the kernel of the blur texture.
  58757. */
  58758. blurKernelSize: number;
  58759. /**
  58760. * The camera attached to the layer.
  58761. */
  58762. camera: Nullable<Camera>;
  58763. /**
  58764. * Enable MSAA by chosing the number of samples.
  58765. */
  58766. mainTextureSamples?: number;
  58767. /**
  58768. * The rendering group to draw the layer in.
  58769. */
  58770. renderingGroupId: number;
  58771. }
  58772. /**
  58773. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58774. *
  58775. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58776. *
  58777. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58778. */
  58779. export class GlowLayer extends EffectLayer {
  58780. /**
  58781. * Effect Name of the layer.
  58782. */
  58783. static readonly EffectName: string;
  58784. /**
  58785. * The default blur kernel size used for the glow.
  58786. */
  58787. static DefaultBlurKernelSize: number;
  58788. /**
  58789. * The default texture size ratio used for the glow.
  58790. */
  58791. static DefaultTextureRatio: number;
  58792. /**
  58793. * Sets the kernel size of the blur.
  58794. */
  58795. set blurKernelSize(value: number);
  58796. /**
  58797. * Gets the kernel size of the blur.
  58798. */
  58799. get blurKernelSize(): number;
  58800. /**
  58801. * Sets the glow intensity.
  58802. */
  58803. set intensity(value: number);
  58804. /**
  58805. * Gets the glow intensity.
  58806. */
  58807. get intensity(): number;
  58808. private _options;
  58809. private _intensity;
  58810. private _horizontalBlurPostprocess1;
  58811. private _verticalBlurPostprocess1;
  58812. private _horizontalBlurPostprocess2;
  58813. private _verticalBlurPostprocess2;
  58814. private _blurTexture1;
  58815. private _blurTexture2;
  58816. private _postProcesses1;
  58817. private _postProcesses2;
  58818. private _includedOnlyMeshes;
  58819. private _excludedMeshes;
  58820. private _meshesUsingTheirOwnMaterials;
  58821. /**
  58822. * Callback used to let the user override the color selection on a per mesh basis
  58823. */
  58824. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58825. /**
  58826. * Callback used to let the user override the texture selection on a per mesh basis
  58827. */
  58828. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58829. /**
  58830. * Instantiates a new glow Layer and references it to the scene.
  58831. * @param name The name of the layer
  58832. * @param scene The scene to use the layer in
  58833. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58834. */
  58835. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58836. /**
  58837. * Get the effect name of the layer.
  58838. * @return The effect name
  58839. */
  58840. getEffectName(): string;
  58841. /**
  58842. * Create the merge effect. This is the shader use to blit the information back
  58843. * to the main canvas at the end of the scene rendering.
  58844. */
  58845. protected _createMergeEffect(): Effect;
  58846. /**
  58847. * Creates the render target textures and post processes used in the glow layer.
  58848. */
  58849. protected _createTextureAndPostProcesses(): void;
  58850. /**
  58851. * Checks for the readiness of the element composing the layer.
  58852. * @param subMesh the mesh to check for
  58853. * @param useInstances specify wether or not to use instances to render the mesh
  58854. * @param emissiveTexture the associated emissive texture used to generate the glow
  58855. * @return true if ready otherwise, false
  58856. */
  58857. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58858. /**
  58859. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58860. */
  58861. needStencil(): boolean;
  58862. /**
  58863. * Returns true if the mesh can be rendered, otherwise false.
  58864. * @param mesh The mesh to render
  58865. * @param material The material used on the mesh
  58866. * @returns true if it can be rendered otherwise false
  58867. */
  58868. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58869. /**
  58870. * Implementation specific of rendering the generating effect on the main canvas.
  58871. * @param effect The effect used to render through
  58872. */
  58873. protected _internalRender(effect: Effect): void;
  58874. /**
  58875. * Sets the required values for both the emissive texture and and the main color.
  58876. */
  58877. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58878. /**
  58879. * Returns true if the mesh should render, otherwise false.
  58880. * @param mesh The mesh to render
  58881. * @returns true if it should render otherwise false
  58882. */
  58883. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58884. /**
  58885. * Adds specific effects defines.
  58886. * @param defines The defines to add specifics to.
  58887. */
  58888. protected _addCustomEffectDefines(defines: string[]): void;
  58889. /**
  58890. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58891. * @param mesh The mesh to exclude from the glow layer
  58892. */
  58893. addExcludedMesh(mesh: Mesh): void;
  58894. /**
  58895. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58896. * @param mesh The mesh to remove
  58897. */
  58898. removeExcludedMesh(mesh: Mesh): void;
  58899. /**
  58900. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58901. * @param mesh The mesh to include in the glow layer
  58902. */
  58903. addIncludedOnlyMesh(mesh: Mesh): void;
  58904. /**
  58905. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58906. * @param mesh The mesh to remove
  58907. */
  58908. removeIncludedOnlyMesh(mesh: Mesh): void;
  58909. /**
  58910. * Determine if a given mesh will be used in the glow layer
  58911. * @param mesh The mesh to test
  58912. * @returns true if the mesh will be highlighted by the current glow layer
  58913. */
  58914. hasMesh(mesh: AbstractMesh): boolean;
  58915. /**
  58916. * Defines whether the current material of the mesh should be use to render the effect.
  58917. * @param mesh defines the current mesh to render
  58918. */
  58919. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58920. /**
  58921. * Add a mesh to be rendered through its own material and not with emissive only.
  58922. * @param mesh The mesh for which we need to use its material
  58923. */
  58924. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58925. /**
  58926. * Remove a mesh from being rendered through its own material and not with emissive only.
  58927. * @param mesh The mesh for which we need to not use its material
  58928. */
  58929. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58930. /**
  58931. * Free any resources and references associated to a mesh.
  58932. * Internal use
  58933. * @param mesh The mesh to free.
  58934. * @hidden
  58935. */
  58936. _disposeMesh(mesh: Mesh): void;
  58937. /**
  58938. * Gets the class name of the effect layer
  58939. * @returns the string with the class name of the effect layer
  58940. */
  58941. getClassName(): string;
  58942. /**
  58943. * Serializes this glow layer
  58944. * @returns a serialized glow layer object
  58945. */
  58946. serialize(): any;
  58947. /**
  58948. * Creates a Glow Layer from parsed glow layer data
  58949. * @param parsedGlowLayer defines glow layer data
  58950. * @param scene defines the current scene
  58951. * @param rootUrl defines the root URL containing the glow layer information
  58952. * @returns a parsed Glow Layer
  58953. */
  58954. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58955. }
  58956. }
  58957. declare module BABYLON {
  58958. /** @hidden */
  58959. export var glowBlurPostProcessPixelShader: {
  58960. name: string;
  58961. shader: string;
  58962. };
  58963. }
  58964. declare module BABYLON {
  58965. interface AbstractScene {
  58966. /**
  58967. * Return a the first highlight layer of the scene with a given name.
  58968. * @param name The name of the highlight layer to look for.
  58969. * @return The highlight layer if found otherwise null.
  58970. */
  58971. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58972. }
  58973. /**
  58974. * Highlight layer options. This helps customizing the behaviour
  58975. * of the highlight layer.
  58976. */
  58977. export interface IHighlightLayerOptions {
  58978. /**
  58979. * Multiplication factor apply to the canvas size to compute the render target size
  58980. * used to generated the glowing objects (the smaller the faster).
  58981. */
  58982. mainTextureRatio: number;
  58983. /**
  58984. * Enforces a fixed size texture to ensure resize independant blur.
  58985. */
  58986. mainTextureFixedSize?: number;
  58987. /**
  58988. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58989. * of the picture to blur (the smaller the faster).
  58990. */
  58991. blurTextureSizeRatio: number;
  58992. /**
  58993. * How big in texel of the blur texture is the vertical blur.
  58994. */
  58995. blurVerticalSize: number;
  58996. /**
  58997. * How big in texel of the blur texture is the horizontal blur.
  58998. */
  58999. blurHorizontalSize: number;
  59000. /**
  59001. * Alpha blending mode used to apply the blur. Default is combine.
  59002. */
  59003. alphaBlendingMode: number;
  59004. /**
  59005. * The camera attached to the layer.
  59006. */
  59007. camera: Nullable<Camera>;
  59008. /**
  59009. * Should we display highlight as a solid stroke?
  59010. */
  59011. isStroke?: boolean;
  59012. /**
  59013. * The rendering group to draw the layer in.
  59014. */
  59015. renderingGroupId: number;
  59016. }
  59017. /**
  59018. * The highlight layer Helps adding a glow effect around a mesh.
  59019. *
  59020. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59021. * glowy meshes to your scene.
  59022. *
  59023. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59024. */
  59025. export class HighlightLayer extends EffectLayer {
  59026. name: string;
  59027. /**
  59028. * Effect Name of the highlight layer.
  59029. */
  59030. static readonly EffectName: string;
  59031. /**
  59032. * The neutral color used during the preparation of the glow effect.
  59033. * This is black by default as the blend operation is a blend operation.
  59034. */
  59035. static NeutralColor: Color4;
  59036. /**
  59037. * Stencil value used for glowing meshes.
  59038. */
  59039. static GlowingMeshStencilReference: number;
  59040. /**
  59041. * Stencil value used for the other meshes in the scene.
  59042. */
  59043. static NormalMeshStencilReference: number;
  59044. /**
  59045. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59046. */
  59047. innerGlow: boolean;
  59048. /**
  59049. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59050. */
  59051. outerGlow: boolean;
  59052. /**
  59053. * Specifies the horizontal size of the blur.
  59054. */
  59055. set blurHorizontalSize(value: number);
  59056. /**
  59057. * Specifies the vertical size of the blur.
  59058. */
  59059. set blurVerticalSize(value: number);
  59060. /**
  59061. * Gets the horizontal size of the blur.
  59062. */
  59063. get blurHorizontalSize(): number;
  59064. /**
  59065. * Gets the vertical size of the blur.
  59066. */
  59067. get blurVerticalSize(): number;
  59068. /**
  59069. * An event triggered when the highlight layer is being blurred.
  59070. */
  59071. onBeforeBlurObservable: Observable<HighlightLayer>;
  59072. /**
  59073. * An event triggered when the highlight layer has been blurred.
  59074. */
  59075. onAfterBlurObservable: Observable<HighlightLayer>;
  59076. private _instanceGlowingMeshStencilReference;
  59077. private _options;
  59078. private _downSamplePostprocess;
  59079. private _horizontalBlurPostprocess;
  59080. private _verticalBlurPostprocess;
  59081. private _blurTexture;
  59082. private _meshes;
  59083. private _excludedMeshes;
  59084. /**
  59085. * Instantiates a new highlight Layer and references it to the scene..
  59086. * @param name The name of the layer
  59087. * @param scene The scene to use the layer in
  59088. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59089. */
  59090. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59091. /**
  59092. * Get the effect name of the layer.
  59093. * @return The effect name
  59094. */
  59095. getEffectName(): string;
  59096. /**
  59097. * Create the merge effect. This is the shader use to blit the information back
  59098. * to the main canvas at the end of the scene rendering.
  59099. */
  59100. protected _createMergeEffect(): Effect;
  59101. /**
  59102. * Creates the render target textures and post processes used in the highlight layer.
  59103. */
  59104. protected _createTextureAndPostProcesses(): void;
  59105. /**
  59106. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59107. */
  59108. needStencil(): boolean;
  59109. /**
  59110. * Checks for the readiness of the element composing the layer.
  59111. * @param subMesh the mesh to check for
  59112. * @param useInstances specify wether or not to use instances to render the mesh
  59113. * @param emissiveTexture the associated emissive texture used to generate the glow
  59114. * @return true if ready otherwise, false
  59115. */
  59116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59117. /**
  59118. * Implementation specific of rendering the generating effect on the main canvas.
  59119. * @param effect The effect used to render through
  59120. */
  59121. protected _internalRender(effect: Effect): void;
  59122. /**
  59123. * Returns true if the layer contains information to display, otherwise false.
  59124. */
  59125. shouldRender(): boolean;
  59126. /**
  59127. * Returns true if the mesh should render, otherwise false.
  59128. * @param mesh The mesh to render
  59129. * @returns true if it should render otherwise false
  59130. */
  59131. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59132. /**
  59133. * Returns true if the mesh can be rendered, otherwise false.
  59134. * @param mesh The mesh to render
  59135. * @param material The material used on the mesh
  59136. * @returns true if it can be rendered otherwise false
  59137. */
  59138. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59139. /**
  59140. * Adds specific effects defines.
  59141. * @param defines The defines to add specifics to.
  59142. */
  59143. protected _addCustomEffectDefines(defines: string[]): void;
  59144. /**
  59145. * Sets the required values for both the emissive texture and and the main color.
  59146. */
  59147. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59148. /**
  59149. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59150. * @param mesh The mesh to exclude from the highlight layer
  59151. */
  59152. addExcludedMesh(mesh: Mesh): void;
  59153. /**
  59154. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59155. * @param mesh The mesh to highlight
  59156. */
  59157. removeExcludedMesh(mesh: Mesh): void;
  59158. /**
  59159. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59160. * @param mesh mesh to test
  59161. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59162. */
  59163. hasMesh(mesh: AbstractMesh): boolean;
  59164. /**
  59165. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59166. * @param mesh The mesh to highlight
  59167. * @param color The color of the highlight
  59168. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59169. */
  59170. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59171. /**
  59172. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59173. * @param mesh The mesh to highlight
  59174. */
  59175. removeMesh(mesh: Mesh): void;
  59176. /**
  59177. * Remove all the meshes currently referenced in the highlight layer
  59178. */
  59179. removeAllMeshes(): void;
  59180. /**
  59181. * Force the stencil to the normal expected value for none glowing parts
  59182. */
  59183. private _defaultStencilReference;
  59184. /**
  59185. * Free any resources and references associated to a mesh.
  59186. * Internal use
  59187. * @param mesh The mesh to free.
  59188. * @hidden
  59189. */
  59190. _disposeMesh(mesh: Mesh): void;
  59191. /**
  59192. * Dispose the highlight layer and free resources.
  59193. */
  59194. dispose(): void;
  59195. /**
  59196. * Gets the class name of the effect layer
  59197. * @returns the string with the class name of the effect layer
  59198. */
  59199. getClassName(): string;
  59200. /**
  59201. * Serializes this Highlight layer
  59202. * @returns a serialized Highlight layer object
  59203. */
  59204. serialize(): any;
  59205. /**
  59206. * Creates a Highlight layer from parsed Highlight layer data
  59207. * @param parsedHightlightLayer defines the Highlight layer data
  59208. * @param scene defines the current scene
  59209. * @param rootUrl defines the root URL containing the Highlight layer information
  59210. * @returns a parsed Highlight layer
  59211. */
  59212. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59213. }
  59214. }
  59215. declare module BABYLON {
  59216. interface AbstractScene {
  59217. /**
  59218. * The list of layers (background and foreground) of the scene
  59219. */
  59220. layers: Array<Layer>;
  59221. }
  59222. /**
  59223. * Defines the layer scene component responsible to manage any layers
  59224. * in a given scene.
  59225. */
  59226. export class LayerSceneComponent implements ISceneComponent {
  59227. /**
  59228. * The component name helpfull to identify the component in the list of scene components.
  59229. */
  59230. readonly name: string;
  59231. /**
  59232. * The scene the component belongs to.
  59233. */
  59234. scene: Scene;
  59235. private _engine;
  59236. /**
  59237. * Creates a new instance of the component for the given scene
  59238. * @param scene Defines the scene to register the component in
  59239. */
  59240. constructor(scene: Scene);
  59241. /**
  59242. * Registers the component in a given scene
  59243. */
  59244. register(): void;
  59245. /**
  59246. * Rebuilds the elements related to this component in case of
  59247. * context lost for instance.
  59248. */
  59249. rebuild(): void;
  59250. /**
  59251. * Disposes the component and the associated ressources.
  59252. */
  59253. dispose(): void;
  59254. private _draw;
  59255. private _drawCameraPredicate;
  59256. private _drawCameraBackground;
  59257. private _drawCameraForeground;
  59258. private _drawRenderTargetPredicate;
  59259. private _drawRenderTargetBackground;
  59260. private _drawRenderTargetForeground;
  59261. /**
  59262. * Adds all the elements from the container to the scene
  59263. * @param container the container holding the elements
  59264. */
  59265. addFromContainer(container: AbstractScene): void;
  59266. /**
  59267. * Removes all the elements in the container from the scene
  59268. * @param container contains the elements to remove
  59269. * @param dispose if the removed element should be disposed (default: false)
  59270. */
  59271. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59272. }
  59273. }
  59274. declare module BABYLON {
  59275. /** @hidden */
  59276. export var layerPixelShader: {
  59277. name: string;
  59278. shader: string;
  59279. };
  59280. }
  59281. declare module BABYLON {
  59282. /** @hidden */
  59283. export var layerVertexShader: {
  59284. name: string;
  59285. shader: string;
  59286. };
  59287. }
  59288. declare module BABYLON {
  59289. /**
  59290. * This represents a full screen 2d layer.
  59291. * This can be useful to display a picture in the background of your scene for instance.
  59292. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59293. */
  59294. export class Layer {
  59295. /**
  59296. * Define the name of the layer.
  59297. */
  59298. name: string;
  59299. /**
  59300. * Define the texture the layer should display.
  59301. */
  59302. texture: Nullable<Texture>;
  59303. /**
  59304. * Is the layer in background or foreground.
  59305. */
  59306. isBackground: boolean;
  59307. /**
  59308. * Define the color of the layer (instead of texture).
  59309. */
  59310. color: Color4;
  59311. /**
  59312. * Define the scale of the layer in order to zoom in out of the texture.
  59313. */
  59314. scale: Vector2;
  59315. /**
  59316. * Define an offset for the layer in order to shift the texture.
  59317. */
  59318. offset: Vector2;
  59319. /**
  59320. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59321. */
  59322. alphaBlendingMode: number;
  59323. /**
  59324. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59325. * Alpha test will not mix with the background color in case of transparency.
  59326. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59327. */
  59328. alphaTest: boolean;
  59329. /**
  59330. * Define a mask to restrict the layer to only some of the scene cameras.
  59331. */
  59332. layerMask: number;
  59333. /**
  59334. * Define the list of render target the layer is visible into.
  59335. */
  59336. renderTargetTextures: RenderTargetTexture[];
  59337. /**
  59338. * Define if the layer is only used in renderTarget or if it also
  59339. * renders in the main frame buffer of the canvas.
  59340. */
  59341. renderOnlyInRenderTargetTextures: boolean;
  59342. private _scene;
  59343. private _vertexBuffers;
  59344. private _indexBuffer;
  59345. private _effect;
  59346. private _previousDefines;
  59347. /**
  59348. * An event triggered when the layer is disposed.
  59349. */
  59350. onDisposeObservable: Observable<Layer>;
  59351. private _onDisposeObserver;
  59352. /**
  59353. * Back compatibility with callback before the onDisposeObservable existed.
  59354. * The set callback will be triggered when the layer has been disposed.
  59355. */
  59356. set onDispose(callback: () => void);
  59357. /**
  59358. * An event triggered before rendering the scene
  59359. */
  59360. onBeforeRenderObservable: Observable<Layer>;
  59361. private _onBeforeRenderObserver;
  59362. /**
  59363. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59364. * The set callback will be triggered just before rendering the layer.
  59365. */
  59366. set onBeforeRender(callback: () => void);
  59367. /**
  59368. * An event triggered after rendering the scene
  59369. */
  59370. onAfterRenderObservable: Observable<Layer>;
  59371. private _onAfterRenderObserver;
  59372. /**
  59373. * Back compatibility with callback before the onAfterRenderObservable existed.
  59374. * The set callback will be triggered just after rendering the layer.
  59375. */
  59376. set onAfterRender(callback: () => void);
  59377. /**
  59378. * Instantiates a new layer.
  59379. * This represents a full screen 2d layer.
  59380. * This can be useful to display a picture in the background of your scene for instance.
  59381. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59382. * @param name Define the name of the layer in the scene
  59383. * @param imgUrl Define the url of the texture to display in the layer
  59384. * @param scene Define the scene the layer belongs to
  59385. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59386. * @param color Defines a color for the layer
  59387. */
  59388. constructor(
  59389. /**
  59390. * Define the name of the layer.
  59391. */
  59392. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59393. private _createIndexBuffer;
  59394. /** @hidden */
  59395. _rebuild(): void;
  59396. /**
  59397. * Renders the layer in the scene.
  59398. */
  59399. render(): void;
  59400. /**
  59401. * Disposes and releases the associated ressources.
  59402. */
  59403. dispose(): void;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /** @hidden */
  59408. export var lensFlarePixelShader: {
  59409. name: string;
  59410. shader: string;
  59411. };
  59412. }
  59413. declare module BABYLON {
  59414. /** @hidden */
  59415. export var lensFlareVertexShader: {
  59416. name: string;
  59417. shader: string;
  59418. };
  59419. }
  59420. declare module BABYLON {
  59421. /**
  59422. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59423. * It is usually composed of several `lensFlare`.
  59424. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59425. */
  59426. export class LensFlareSystem {
  59427. /**
  59428. * Define the name of the lens flare system
  59429. */
  59430. name: string;
  59431. /**
  59432. * List of lens flares used in this system.
  59433. */
  59434. lensFlares: LensFlare[];
  59435. /**
  59436. * Define a limit from the border the lens flare can be visible.
  59437. */
  59438. borderLimit: number;
  59439. /**
  59440. * Define a viewport border we do not want to see the lens flare in.
  59441. */
  59442. viewportBorder: number;
  59443. /**
  59444. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59445. */
  59446. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59447. /**
  59448. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59449. */
  59450. layerMask: number;
  59451. /**
  59452. * Define the id of the lens flare system in the scene.
  59453. * (equal to name by default)
  59454. */
  59455. id: string;
  59456. private _scene;
  59457. private _emitter;
  59458. private _vertexBuffers;
  59459. private _indexBuffer;
  59460. private _effect;
  59461. private _positionX;
  59462. private _positionY;
  59463. private _isEnabled;
  59464. /** @hidden */
  59465. static _SceneComponentInitialization: (scene: Scene) => void;
  59466. /**
  59467. * Instantiates a lens flare system.
  59468. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59469. * It is usually composed of several `lensFlare`.
  59470. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59471. * @param name Define the name of the lens flare system in the scene
  59472. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59473. * @param scene Define the scene the lens flare system belongs to
  59474. */
  59475. constructor(
  59476. /**
  59477. * Define the name of the lens flare system
  59478. */
  59479. name: string, emitter: any, scene: Scene);
  59480. /**
  59481. * Define if the lens flare system is enabled.
  59482. */
  59483. get isEnabled(): boolean;
  59484. set isEnabled(value: boolean);
  59485. /**
  59486. * Get the scene the effects belongs to.
  59487. * @returns the scene holding the lens flare system
  59488. */
  59489. getScene(): Scene;
  59490. /**
  59491. * Get the emitter of the lens flare system.
  59492. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59493. * @returns the emitter of the lens flare system
  59494. */
  59495. getEmitter(): any;
  59496. /**
  59497. * Set the emitter of the lens flare system.
  59498. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59499. * @param newEmitter Define the new emitter of the system
  59500. */
  59501. setEmitter(newEmitter: any): void;
  59502. /**
  59503. * Get the lens flare system emitter position.
  59504. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59505. * @returns the position
  59506. */
  59507. getEmitterPosition(): Vector3;
  59508. /**
  59509. * @hidden
  59510. */
  59511. computeEffectivePosition(globalViewport: Viewport): boolean;
  59512. /** @hidden */
  59513. _isVisible(): boolean;
  59514. /**
  59515. * @hidden
  59516. */
  59517. render(): boolean;
  59518. /**
  59519. * Dispose and release the lens flare with its associated resources.
  59520. */
  59521. dispose(): void;
  59522. /**
  59523. * Parse a lens flare system from a JSON repressentation
  59524. * @param parsedLensFlareSystem Define the JSON to parse
  59525. * @param scene Define the scene the parsed system should be instantiated in
  59526. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59527. * @returns the parsed system
  59528. */
  59529. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59530. /**
  59531. * Serialize the current Lens Flare System into a JSON representation.
  59532. * @returns the serialized JSON
  59533. */
  59534. serialize(): any;
  59535. }
  59536. }
  59537. declare module BABYLON {
  59538. /**
  59539. * This represents one of the lens effect in a `lensFlareSystem`.
  59540. * It controls one of the indiviual texture used in the effect.
  59541. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59542. */
  59543. export class LensFlare {
  59544. /**
  59545. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59546. */
  59547. size: number;
  59548. /**
  59549. * 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.
  59550. */
  59551. position: number;
  59552. /**
  59553. * Define the lens color.
  59554. */
  59555. color: Color3;
  59556. /**
  59557. * Define the lens texture.
  59558. */
  59559. texture: Nullable<Texture>;
  59560. /**
  59561. * Define the alpha mode to render this particular lens.
  59562. */
  59563. alphaMode: number;
  59564. private _system;
  59565. /**
  59566. * Creates a new Lens Flare.
  59567. * This represents one of the lens effect in a `lensFlareSystem`.
  59568. * It controls one of the indiviual texture used in the effect.
  59569. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59570. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59571. * @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.
  59572. * @param color Define the lens color
  59573. * @param imgUrl Define the lens texture url
  59574. * @param system Define the `lensFlareSystem` this flare is part of
  59575. * @returns The newly created Lens Flare
  59576. */
  59577. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59578. /**
  59579. * Instantiates a new Lens Flare.
  59580. * This represents one of the lens effect in a `lensFlareSystem`.
  59581. * It controls one of the indiviual texture used in the effect.
  59582. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59583. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59584. * @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.
  59585. * @param color Define the lens color
  59586. * @param imgUrl Define the lens texture url
  59587. * @param system Define the `lensFlareSystem` this flare is part of
  59588. */
  59589. constructor(
  59590. /**
  59591. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59592. */
  59593. size: number,
  59594. /**
  59595. * 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.
  59596. */
  59597. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59598. /**
  59599. * Dispose and release the lens flare with its associated resources.
  59600. */
  59601. dispose(): void;
  59602. }
  59603. }
  59604. declare module BABYLON {
  59605. interface AbstractScene {
  59606. /**
  59607. * The list of lens flare system added to the scene
  59608. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59609. */
  59610. lensFlareSystems: Array<LensFlareSystem>;
  59611. /**
  59612. * Removes the given lens flare system from this scene.
  59613. * @param toRemove The lens flare system to remove
  59614. * @returns The index of the removed lens flare system
  59615. */
  59616. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59617. /**
  59618. * Adds the given lens flare system to this scene
  59619. * @param newLensFlareSystem The lens flare system to add
  59620. */
  59621. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59622. /**
  59623. * Gets a lens flare system using its name
  59624. * @param name defines the name to look for
  59625. * @returns the lens flare system or null if not found
  59626. */
  59627. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59628. /**
  59629. * Gets a lens flare system using its id
  59630. * @param id defines the id to look for
  59631. * @returns the lens flare system or null if not found
  59632. */
  59633. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59634. }
  59635. /**
  59636. * Defines the lens flare scene component responsible to manage any lens flares
  59637. * in a given scene.
  59638. */
  59639. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59640. /**
  59641. * The component name helpfull to identify the component in the list of scene components.
  59642. */
  59643. readonly name: string;
  59644. /**
  59645. * The scene the component belongs to.
  59646. */
  59647. scene: Scene;
  59648. /**
  59649. * Creates a new instance of the component for the given scene
  59650. * @param scene Defines the scene to register the component in
  59651. */
  59652. constructor(scene: Scene);
  59653. /**
  59654. * Registers the component in a given scene
  59655. */
  59656. register(): void;
  59657. /**
  59658. * Rebuilds the elements related to this component in case of
  59659. * context lost for instance.
  59660. */
  59661. rebuild(): void;
  59662. /**
  59663. * Adds all the elements from the container to the scene
  59664. * @param container the container holding the elements
  59665. */
  59666. addFromContainer(container: AbstractScene): void;
  59667. /**
  59668. * Removes all the elements in the container from the scene
  59669. * @param container contains the elements to remove
  59670. * @param dispose if the removed element should be disposed (default: false)
  59671. */
  59672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59673. /**
  59674. * Serializes the component data to the specified json object
  59675. * @param serializationObject The object to serialize to
  59676. */
  59677. serialize(serializationObject: any): void;
  59678. /**
  59679. * Disposes the component and the associated ressources.
  59680. */
  59681. dispose(): void;
  59682. private _draw;
  59683. }
  59684. }
  59685. declare module BABYLON {
  59686. /** @hidden */
  59687. export var depthPixelShader: {
  59688. name: string;
  59689. shader: string;
  59690. };
  59691. }
  59692. declare module BABYLON {
  59693. /** @hidden */
  59694. export var depthVertexShader: {
  59695. name: string;
  59696. shader: string;
  59697. };
  59698. }
  59699. declare module BABYLON {
  59700. /**
  59701. * This represents a depth renderer in Babylon.
  59702. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59703. */
  59704. export class DepthRenderer {
  59705. private _scene;
  59706. private _depthMap;
  59707. private _effect;
  59708. private readonly _storeNonLinearDepth;
  59709. private readonly _clearColor;
  59710. /** Get if the depth renderer is using packed depth or not */
  59711. readonly isPacked: boolean;
  59712. private _cachedDefines;
  59713. private _camera;
  59714. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59715. enabled: boolean;
  59716. /**
  59717. * Specifiess that the depth renderer will only be used within
  59718. * the camera it is created for.
  59719. * This can help forcing its rendering during the camera processing.
  59720. */
  59721. useOnlyInActiveCamera: boolean;
  59722. /** @hidden */
  59723. static _SceneComponentInitialization: (scene: Scene) => void;
  59724. /**
  59725. * Instantiates a depth renderer
  59726. * @param scene The scene the renderer belongs to
  59727. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59728. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59729. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59730. */
  59731. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59732. /**
  59733. * Creates the depth rendering effect and checks if the effect is ready.
  59734. * @param subMesh The submesh to be used to render the depth map of
  59735. * @param useInstances If multiple world instances should be used
  59736. * @returns if the depth renderer is ready to render the depth map
  59737. */
  59738. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59739. /**
  59740. * Gets the texture which the depth map will be written to.
  59741. * @returns The depth map texture
  59742. */
  59743. getDepthMap(): RenderTargetTexture;
  59744. /**
  59745. * Disposes of the depth renderer.
  59746. */
  59747. dispose(): void;
  59748. }
  59749. }
  59750. declare module BABYLON {
  59751. /** @hidden */
  59752. export var minmaxReduxPixelShader: {
  59753. name: string;
  59754. shader: string;
  59755. };
  59756. }
  59757. declare module BABYLON {
  59758. /**
  59759. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59760. * and maximum values from all values of the texture.
  59761. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59762. * The source values are read from the red channel of the texture.
  59763. */
  59764. export class MinMaxReducer {
  59765. /**
  59766. * Observable triggered when the computation has been performed
  59767. */
  59768. onAfterReductionPerformed: Observable<{
  59769. min: number;
  59770. max: number;
  59771. }>;
  59772. protected _camera: Camera;
  59773. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59774. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59775. protected _postProcessManager: PostProcessManager;
  59776. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59777. protected _forceFullscreenViewport: boolean;
  59778. /**
  59779. * Creates a min/max reducer
  59780. * @param camera The camera to use for the post processes
  59781. */
  59782. constructor(camera: Camera);
  59783. /**
  59784. * Gets the texture used to read the values from.
  59785. */
  59786. get sourceTexture(): Nullable<RenderTargetTexture>;
  59787. /**
  59788. * Sets the source texture to read the values from.
  59789. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59790. * because in such textures '1' value must not be taken into account to compute the maximum
  59791. * as this value is used to clear the texture.
  59792. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59793. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59794. * @param depthRedux Indicates if the texture is a depth texture or not
  59795. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59796. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59797. */
  59798. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59799. /**
  59800. * Defines the refresh rate of the computation.
  59801. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59802. */
  59803. get refreshRate(): number;
  59804. set refreshRate(value: number);
  59805. protected _activated: boolean;
  59806. /**
  59807. * Gets the activation status of the reducer
  59808. */
  59809. get activated(): boolean;
  59810. /**
  59811. * Activates the reduction computation.
  59812. * When activated, the observers registered in onAfterReductionPerformed are
  59813. * called after the compuation is performed
  59814. */
  59815. activate(): void;
  59816. /**
  59817. * Deactivates the reduction computation.
  59818. */
  59819. deactivate(): void;
  59820. /**
  59821. * Disposes the min/max reducer
  59822. * @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.
  59823. */
  59824. dispose(disposeAll?: boolean): void;
  59825. }
  59826. }
  59827. declare module BABYLON {
  59828. /**
  59829. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59830. */
  59831. export class DepthReducer extends MinMaxReducer {
  59832. private _depthRenderer;
  59833. private _depthRendererId;
  59834. /**
  59835. * Gets the depth renderer used for the computation.
  59836. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59837. */
  59838. get depthRenderer(): Nullable<DepthRenderer>;
  59839. /**
  59840. * Creates a depth reducer
  59841. * @param camera The camera used to render the depth texture
  59842. */
  59843. constructor(camera: Camera);
  59844. /**
  59845. * Sets the depth renderer to use to generate the depth map
  59846. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59847. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59848. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59849. */
  59850. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59851. /** @hidden */
  59852. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59853. /**
  59854. * Activates the reduction computation.
  59855. * When activated, the observers registered in onAfterReductionPerformed are
  59856. * called after the compuation is performed
  59857. */
  59858. activate(): void;
  59859. /**
  59860. * Deactivates the reduction computation.
  59861. */
  59862. deactivate(): void;
  59863. /**
  59864. * Disposes the depth reducer
  59865. * @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.
  59866. */
  59867. dispose(disposeAll?: boolean): void;
  59868. }
  59869. }
  59870. declare module BABYLON {
  59871. /**
  59872. * A CSM implementation allowing casting shadows on large scenes.
  59873. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59874. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59875. */
  59876. export class CascadedShadowGenerator extends ShadowGenerator {
  59877. private static readonly frustumCornersNDCSpace;
  59878. /**
  59879. * Name of the CSM class
  59880. */
  59881. static CLASSNAME: string;
  59882. /**
  59883. * Defines the default number of cascades used by the CSM.
  59884. */
  59885. static readonly DEFAULT_CASCADES_COUNT: number;
  59886. /**
  59887. * Defines the minimum number of cascades used by the CSM.
  59888. */
  59889. static readonly MIN_CASCADES_COUNT: number;
  59890. /**
  59891. * Defines the maximum number of cascades used by the CSM.
  59892. */
  59893. static readonly MAX_CASCADES_COUNT: number;
  59894. protected _validateFilter(filter: number): number;
  59895. /**
  59896. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59897. */
  59898. penumbraDarkness: number;
  59899. private _numCascades;
  59900. /**
  59901. * Gets or set the number of cascades used by the CSM.
  59902. */
  59903. get numCascades(): number;
  59904. set numCascades(value: number);
  59905. /**
  59906. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59907. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59908. */
  59909. stabilizeCascades: boolean;
  59910. private _freezeShadowCastersBoundingInfo;
  59911. private _freezeShadowCastersBoundingInfoObservable;
  59912. /**
  59913. * Enables or disables the shadow casters bounding info computation.
  59914. * If your shadow casters don't move, you can disable this feature.
  59915. * If it is enabled, the bounding box computation is done every frame.
  59916. */
  59917. get freezeShadowCastersBoundingInfo(): boolean;
  59918. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59919. private _scbiMin;
  59920. private _scbiMax;
  59921. protected _computeShadowCastersBoundingInfo(): void;
  59922. protected _shadowCastersBoundingInfo: BoundingInfo;
  59923. /**
  59924. * Gets or sets the shadow casters bounding info.
  59925. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59926. * so that the system won't overwrite the bounds you provide
  59927. */
  59928. get shadowCastersBoundingInfo(): BoundingInfo;
  59929. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59930. protected _breaksAreDirty: boolean;
  59931. protected _minDistance: number;
  59932. protected _maxDistance: number;
  59933. /**
  59934. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59935. *
  59936. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59937. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59938. * @param min minimal distance for the breaks (default to 0.)
  59939. * @param max maximal distance for the breaks (default to 1.)
  59940. */
  59941. setMinMaxDistance(min: number, max: number): void;
  59942. /** Gets the minimal distance used in the cascade break computation */
  59943. get minDistance(): number;
  59944. /** Gets the maximal distance used in the cascade break computation */
  59945. get maxDistance(): number;
  59946. /**
  59947. * Gets the class name of that object
  59948. * @returns "CascadedShadowGenerator"
  59949. */
  59950. getClassName(): string;
  59951. private _cascadeMinExtents;
  59952. private _cascadeMaxExtents;
  59953. /**
  59954. * Gets a cascade minimum extents
  59955. * @param cascadeIndex index of the cascade
  59956. * @returns the minimum cascade extents
  59957. */
  59958. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59959. /**
  59960. * Gets a cascade maximum extents
  59961. * @param cascadeIndex index of the cascade
  59962. * @returns the maximum cascade extents
  59963. */
  59964. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59965. private _cascades;
  59966. private _currentLayer;
  59967. private _viewSpaceFrustumsZ;
  59968. private _viewMatrices;
  59969. private _projectionMatrices;
  59970. private _transformMatrices;
  59971. private _transformMatricesAsArray;
  59972. private _frustumLengths;
  59973. private _lightSizeUVCorrection;
  59974. private _depthCorrection;
  59975. private _frustumCornersWorldSpace;
  59976. private _frustumCenter;
  59977. private _shadowCameraPos;
  59978. private _shadowMaxZ;
  59979. /**
  59980. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59981. * It defaults to camera.maxZ
  59982. */
  59983. get shadowMaxZ(): number;
  59984. /**
  59985. * Sets the shadow max z distance.
  59986. */
  59987. set shadowMaxZ(value: number);
  59988. protected _debug: boolean;
  59989. /**
  59990. * Gets or sets the debug flag.
  59991. * When enabled, the cascades are materialized by different colors on the screen.
  59992. */
  59993. get debug(): boolean;
  59994. set debug(dbg: boolean);
  59995. private _depthClamp;
  59996. /**
  59997. * Gets or sets the depth clamping value.
  59998. *
  59999. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60000. * to account for the shadow casters far away.
  60001. *
  60002. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60003. */
  60004. get depthClamp(): boolean;
  60005. set depthClamp(value: boolean);
  60006. private _cascadeBlendPercentage;
  60007. /**
  60008. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60009. * It defaults to 0.1 (10% blending).
  60010. */
  60011. get cascadeBlendPercentage(): number;
  60012. set cascadeBlendPercentage(value: number);
  60013. private _lambda;
  60014. /**
  60015. * Gets or set the lambda parameter.
  60016. * This parameter is used to split the camera frustum and create the cascades.
  60017. * 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.
  60018. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60019. */
  60020. get lambda(): number;
  60021. set lambda(value: number);
  60022. /**
  60023. * Gets the view matrix corresponding to a given cascade
  60024. * @param cascadeNum cascade to retrieve the view matrix from
  60025. * @returns the cascade view matrix
  60026. */
  60027. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60028. /**
  60029. * Gets the projection matrix corresponding to a given cascade
  60030. * @param cascadeNum cascade to retrieve the projection matrix from
  60031. * @returns the cascade projection matrix
  60032. */
  60033. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60034. /**
  60035. * Gets the transformation matrix corresponding to a given cascade
  60036. * @param cascadeNum cascade to retrieve the transformation matrix from
  60037. * @returns the cascade transformation matrix
  60038. */
  60039. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60040. private _depthRenderer;
  60041. /**
  60042. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60043. *
  60044. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60045. *
  60046. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60047. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60048. * @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
  60049. */
  60050. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60051. private _depthReducer;
  60052. private _autoCalcDepthBounds;
  60053. /**
  60054. * Gets or sets the autoCalcDepthBounds property.
  60055. *
  60056. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60057. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60058. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60059. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60060. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60061. */
  60062. get autoCalcDepthBounds(): boolean;
  60063. set autoCalcDepthBounds(value: boolean);
  60064. /**
  60065. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60066. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60067. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60068. * for setting the refresh rate on the renderer yourself!
  60069. */
  60070. get autoCalcDepthBoundsRefreshRate(): number;
  60071. set autoCalcDepthBoundsRefreshRate(value: number);
  60072. /**
  60073. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60074. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60075. * you change the camera near/far planes!
  60076. */
  60077. splitFrustum(): void;
  60078. private _splitFrustum;
  60079. private _computeMatrices;
  60080. private _computeFrustumInWorldSpace;
  60081. private _computeCascadeFrustum;
  60082. /**
  60083. * Support test.
  60084. */
  60085. static get IsSupported(): boolean;
  60086. /** @hidden */
  60087. static _SceneComponentInitialization: (scene: Scene) => void;
  60088. /**
  60089. * Creates a Cascaded Shadow Generator object.
  60090. * A ShadowGenerator is the required tool to use the shadows.
  60091. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60092. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60093. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60094. * @param light The directional light object generating the shadows.
  60095. * @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.
  60096. */
  60097. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60098. protected _initializeGenerator(): void;
  60099. protected _createTargetRenderTexture(): void;
  60100. protected _initializeShadowMap(): void;
  60101. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60102. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60103. /**
  60104. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60105. * @param defines Defines of the material we want to update
  60106. * @param lightIndex Index of the light in the enabled light list of the material
  60107. */
  60108. prepareDefines(defines: any, lightIndex: number): void;
  60109. /**
  60110. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60111. * defined in the generator but impacting the effect).
  60112. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60113. * @param effect The effect we are binfing the information for
  60114. */
  60115. bindShadowLight(lightIndex: string, effect: Effect): void;
  60116. /**
  60117. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60118. * (eq to view projection * shadow projection matrices)
  60119. * @returns The transform matrix used to create the shadow map
  60120. */
  60121. getTransformMatrix(): Matrix;
  60122. /**
  60123. * Disposes the ShadowGenerator.
  60124. * Returns nothing.
  60125. */
  60126. dispose(): void;
  60127. /**
  60128. * Serializes the shadow generator setup to a json object.
  60129. * @returns The serialized JSON object
  60130. */
  60131. serialize(): any;
  60132. /**
  60133. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60134. * @param parsedShadowGenerator The JSON object to parse
  60135. * @param scene The scene to create the shadow map for
  60136. * @returns The parsed shadow generator
  60137. */
  60138. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60139. }
  60140. }
  60141. declare module BABYLON {
  60142. /**
  60143. * Defines the shadow generator component responsible to manage any shadow generators
  60144. * in a given scene.
  60145. */
  60146. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60147. /**
  60148. * The component name helpfull to identify the component in the list of scene components.
  60149. */
  60150. readonly name: string;
  60151. /**
  60152. * The scene the component belongs to.
  60153. */
  60154. scene: Scene;
  60155. /**
  60156. * Creates a new instance of the component for the given scene
  60157. * @param scene Defines the scene to register the component in
  60158. */
  60159. constructor(scene: Scene);
  60160. /**
  60161. * Registers the component in a given scene
  60162. */
  60163. register(): void;
  60164. /**
  60165. * Rebuilds the elements related to this component in case of
  60166. * context lost for instance.
  60167. */
  60168. rebuild(): void;
  60169. /**
  60170. * Serializes the component data to the specified json object
  60171. * @param serializationObject The object to serialize to
  60172. */
  60173. serialize(serializationObject: any): void;
  60174. /**
  60175. * Adds all the elements from the container to the scene
  60176. * @param container the container holding the elements
  60177. */
  60178. addFromContainer(container: AbstractScene): void;
  60179. /**
  60180. * Removes all the elements in the container from the scene
  60181. * @param container contains the elements to remove
  60182. * @param dispose if the removed element should be disposed (default: false)
  60183. */
  60184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60185. /**
  60186. * Rebuilds the elements related to this component in case of
  60187. * context lost for instance.
  60188. */
  60189. dispose(): void;
  60190. private _gatherRenderTargets;
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /**
  60195. * A point light is a light defined by an unique point in world space.
  60196. * The light is emitted in every direction from this point.
  60197. * A good example of a point light is a standard light bulb.
  60198. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60199. */
  60200. export class PointLight extends ShadowLight {
  60201. private _shadowAngle;
  60202. /**
  60203. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60204. * This specifies what angle the shadow will use to be created.
  60205. *
  60206. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60207. */
  60208. get shadowAngle(): number;
  60209. /**
  60210. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60211. * This specifies what angle the shadow will use to be created.
  60212. *
  60213. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60214. */
  60215. set shadowAngle(value: number);
  60216. /**
  60217. * Gets the direction if it has been set.
  60218. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60219. */
  60220. get direction(): Vector3;
  60221. /**
  60222. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60223. */
  60224. set direction(value: Vector3);
  60225. /**
  60226. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60227. * A PointLight emits the light in every direction.
  60228. * It can cast shadows.
  60229. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60230. * ```javascript
  60231. * var pointLight = new PointLight("pl", camera.position, scene);
  60232. * ```
  60233. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60234. * @param name The light friendly name
  60235. * @param position The position of the point light in the scene
  60236. * @param scene The scene the lights belongs to
  60237. */
  60238. constructor(name: string, position: Vector3, scene: Scene);
  60239. /**
  60240. * Returns the string "PointLight"
  60241. * @returns the class name
  60242. */
  60243. getClassName(): string;
  60244. /**
  60245. * Returns the integer 0.
  60246. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60247. */
  60248. getTypeID(): number;
  60249. /**
  60250. * Specifies wether or not the shadowmap should be a cube texture.
  60251. * @returns true if the shadowmap needs to be a cube texture.
  60252. */
  60253. needCube(): boolean;
  60254. /**
  60255. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60256. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60257. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60258. */
  60259. getShadowDirection(faceIndex?: number): Vector3;
  60260. /**
  60261. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60262. * - fov = PI / 2
  60263. * - aspect ratio : 1.0
  60264. * - z-near and far equal to the active camera minZ and maxZ.
  60265. * Returns the PointLight.
  60266. */
  60267. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60268. protected _buildUniformLayout(): void;
  60269. /**
  60270. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60271. * @param effect The effect to update
  60272. * @param lightIndex The index of the light in the effect to update
  60273. * @returns The point light
  60274. */
  60275. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60276. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60277. /**
  60278. * Prepares the list of defines specific to the light type.
  60279. * @param defines the list of defines
  60280. * @param lightIndex defines the index of the light for the effect
  60281. */
  60282. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60283. }
  60284. }
  60285. declare module BABYLON {
  60286. /**
  60287. * Header information of HDR texture files.
  60288. */
  60289. export interface HDRInfo {
  60290. /**
  60291. * The height of the texture in pixels.
  60292. */
  60293. height: number;
  60294. /**
  60295. * The width of the texture in pixels.
  60296. */
  60297. width: number;
  60298. /**
  60299. * The index of the beginning of the data in the binary file.
  60300. */
  60301. dataPosition: number;
  60302. }
  60303. /**
  60304. * This groups tools to convert HDR texture to native colors array.
  60305. */
  60306. export class HDRTools {
  60307. private static Ldexp;
  60308. private static Rgbe2float;
  60309. private static readStringLine;
  60310. /**
  60311. * Reads header information from an RGBE texture stored in a native array.
  60312. * More information on this format are available here:
  60313. * https://en.wikipedia.org/wiki/RGBE_image_format
  60314. *
  60315. * @param uint8array The binary file stored in native array.
  60316. * @return The header information.
  60317. */
  60318. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60319. /**
  60320. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60321. * This RGBE texture needs to store the information as a panorama.
  60322. *
  60323. * More information on this format are available here:
  60324. * https://en.wikipedia.org/wiki/RGBE_image_format
  60325. *
  60326. * @param buffer The binary file stored in an array buffer.
  60327. * @param size The expected size of the extracted cubemap.
  60328. * @return The Cube Map information.
  60329. */
  60330. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60331. /**
  60332. * Returns the pixels data extracted from an RGBE texture.
  60333. * This pixels will be stored left to right up to down in the R G B order in one array.
  60334. *
  60335. * More information on this format are available here:
  60336. * https://en.wikipedia.org/wiki/RGBE_image_format
  60337. *
  60338. * @param uint8array The binary file stored in an array buffer.
  60339. * @param hdrInfo The header information of the file.
  60340. * @return The pixels data in RGB right to left up to down order.
  60341. */
  60342. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60343. private static RGBE_ReadPixels_RLE;
  60344. private static RGBE_ReadPixels_NOT_RLE;
  60345. }
  60346. }
  60347. declare module BABYLON {
  60348. /**
  60349. * Effect Render Options
  60350. */
  60351. export interface IEffectRendererOptions {
  60352. /**
  60353. * Defines the vertices positions.
  60354. */
  60355. positions?: number[];
  60356. /**
  60357. * Defines the indices.
  60358. */
  60359. indices?: number[];
  60360. }
  60361. /**
  60362. * Helper class to render one or more effects.
  60363. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60364. */
  60365. export class EffectRenderer {
  60366. private engine;
  60367. private static _DefaultOptions;
  60368. private _vertexBuffers;
  60369. private _indexBuffer;
  60370. private _fullscreenViewport;
  60371. /**
  60372. * Creates an effect renderer
  60373. * @param engine the engine to use for rendering
  60374. * @param options defines the options of the effect renderer
  60375. */
  60376. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60377. /**
  60378. * Sets the current viewport in normalized coordinates 0-1
  60379. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60380. */
  60381. setViewport(viewport?: Viewport): void;
  60382. /**
  60383. * Binds the embedded attributes buffer to the effect.
  60384. * @param effect Defines the effect to bind the attributes for
  60385. */
  60386. bindBuffers(effect: Effect): void;
  60387. /**
  60388. * Sets the current effect wrapper to use during draw.
  60389. * The effect needs to be ready before calling this api.
  60390. * This also sets the default full screen position attribute.
  60391. * @param effectWrapper Defines the effect to draw with
  60392. */
  60393. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60394. /**
  60395. * Restores engine states
  60396. */
  60397. restoreStates(): void;
  60398. /**
  60399. * Draws a full screen quad.
  60400. */
  60401. draw(): void;
  60402. private isRenderTargetTexture;
  60403. /**
  60404. * renders one or more effects to a specified texture
  60405. * @param effectWrapper the effect to renderer
  60406. * @param outputTexture texture to draw to, if null it will render to the screen.
  60407. */
  60408. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60409. /**
  60410. * Disposes of the effect renderer
  60411. */
  60412. dispose(): void;
  60413. }
  60414. /**
  60415. * Options to create an EffectWrapper
  60416. */
  60417. interface EffectWrapperCreationOptions {
  60418. /**
  60419. * Engine to use to create the effect
  60420. */
  60421. engine: ThinEngine;
  60422. /**
  60423. * Fragment shader for the effect
  60424. */
  60425. fragmentShader: string;
  60426. /**
  60427. * Use the shader store instead of direct source code
  60428. */
  60429. useShaderStore?: boolean;
  60430. /**
  60431. * Vertex shader for the effect
  60432. */
  60433. vertexShader?: string;
  60434. /**
  60435. * Attributes to use in the shader
  60436. */
  60437. attributeNames?: Array<string>;
  60438. /**
  60439. * Uniforms to use in the shader
  60440. */
  60441. uniformNames?: Array<string>;
  60442. /**
  60443. * Texture sampler names to use in the shader
  60444. */
  60445. samplerNames?: Array<string>;
  60446. /**
  60447. * Defines to use in the shader
  60448. */
  60449. defines?: Array<string>;
  60450. /**
  60451. * Callback when effect is compiled
  60452. */
  60453. onCompiled?: Nullable<(effect: Effect) => void>;
  60454. /**
  60455. * The friendly name of the effect displayed in Spector.
  60456. */
  60457. name?: string;
  60458. }
  60459. /**
  60460. * Wraps an effect to be used for rendering
  60461. */
  60462. export class EffectWrapper {
  60463. /**
  60464. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60465. */
  60466. onApplyObservable: Observable<{}>;
  60467. /**
  60468. * The underlying effect
  60469. */
  60470. effect: Effect;
  60471. /**
  60472. * Creates an effect to be renderer
  60473. * @param creationOptions options to create the effect
  60474. */
  60475. constructor(creationOptions: EffectWrapperCreationOptions);
  60476. /**
  60477. * Disposes of the effect wrapper
  60478. */
  60479. dispose(): void;
  60480. }
  60481. }
  60482. declare module BABYLON {
  60483. /** @hidden */
  60484. export var hdrFilteringVertexShader: {
  60485. name: string;
  60486. shader: string;
  60487. };
  60488. }
  60489. declare module BABYLON {
  60490. /** @hidden */
  60491. export var hdrFilteringPixelShader: {
  60492. name: string;
  60493. shader: string;
  60494. };
  60495. }
  60496. declare module BABYLON {
  60497. /**
  60498. * Options for texture filtering
  60499. */
  60500. interface IHDRFilteringOptions {
  60501. /**
  60502. * Scales pixel intensity for the input HDR map.
  60503. */
  60504. hdrScale?: number;
  60505. /**
  60506. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60507. */
  60508. quality?: number;
  60509. }
  60510. /**
  60511. * Filters HDR maps to get correct renderings of PBR reflections
  60512. */
  60513. export class HDRFiltering {
  60514. private _engine;
  60515. private _effectRenderer;
  60516. private _effectWrapper;
  60517. private _lodGenerationOffset;
  60518. private _lodGenerationScale;
  60519. /**
  60520. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60521. * you care about baking speed.
  60522. */
  60523. quality: number;
  60524. /**
  60525. * Scales pixel intensity for the input HDR map.
  60526. */
  60527. hdrScale: number;
  60528. /**
  60529. * Instantiates HDR filter for reflection maps
  60530. *
  60531. * @param engine Thin engine
  60532. * @param options Options
  60533. */
  60534. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60535. private _createRenderTarget;
  60536. private _prefilterInternal;
  60537. private _createEffect;
  60538. /**
  60539. * Get a value indicating if the filter is ready to be used
  60540. * @param texture Texture to filter
  60541. * @returns true if the filter is ready
  60542. */
  60543. isReady(texture: BaseTexture): boolean;
  60544. /**
  60545. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60546. * Prefiltering will be invoked at the end of next rendering pass.
  60547. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60548. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60549. * @param texture Texture to filter
  60550. * @param onFinished Callback when filtering is done
  60551. * @return Promise called when prefiltering is done
  60552. */
  60553. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60554. }
  60555. }
  60556. declare module BABYLON {
  60557. /**
  60558. * This represents a texture coming from an HDR input.
  60559. *
  60560. * The only supported format is currently panorama picture stored in RGBE format.
  60561. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60562. */
  60563. export class HDRCubeTexture extends BaseTexture {
  60564. private static _facesMapping;
  60565. private _generateHarmonics;
  60566. private _noMipmap;
  60567. private _prefilterOnLoad;
  60568. private _textureMatrix;
  60569. private _size;
  60570. private _onLoad;
  60571. private _onError;
  60572. /**
  60573. * The texture URL.
  60574. */
  60575. url: string;
  60576. protected _isBlocking: boolean;
  60577. /**
  60578. * Sets wether or not the texture is blocking during loading.
  60579. */
  60580. set isBlocking(value: boolean);
  60581. /**
  60582. * Gets wether or not the texture is blocking during loading.
  60583. */
  60584. get isBlocking(): boolean;
  60585. protected _rotationY: number;
  60586. /**
  60587. * Sets texture matrix rotation angle around Y axis in radians.
  60588. */
  60589. set rotationY(value: number);
  60590. /**
  60591. * Gets texture matrix rotation angle around Y axis radians.
  60592. */
  60593. get rotationY(): number;
  60594. /**
  60595. * Gets or sets the center of the bounding box associated with the cube texture
  60596. * It must define where the camera used to render the texture was set
  60597. */
  60598. boundingBoxPosition: Vector3;
  60599. private _boundingBoxSize;
  60600. /**
  60601. * Gets or sets the size of the bounding box associated with the cube texture
  60602. * When defined, the cubemap will switch to local mode
  60603. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60604. * @example https://www.babylonjs-playground.com/#RNASML
  60605. */
  60606. set boundingBoxSize(value: Vector3);
  60607. get boundingBoxSize(): Vector3;
  60608. /**
  60609. * Instantiates an HDRTexture from the following parameters.
  60610. *
  60611. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60612. * @param sceneOrEngine The scene or engine the texture will be used in
  60613. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60614. * @param noMipmap Forces to not generate the mipmap if true
  60615. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60616. * @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)
  60617. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60618. */
  60619. 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>);
  60620. /**
  60621. * Get the current class name of the texture useful for serialization or dynamic coding.
  60622. * @returns "HDRCubeTexture"
  60623. */
  60624. getClassName(): string;
  60625. /**
  60626. * Occurs when the file is raw .hdr file.
  60627. */
  60628. private loadTexture;
  60629. clone(): HDRCubeTexture;
  60630. delayLoad(): void;
  60631. /**
  60632. * Get the texture reflection matrix used to rotate/transform the reflection.
  60633. * @returns the reflection matrix
  60634. */
  60635. getReflectionTextureMatrix(): Matrix;
  60636. /**
  60637. * Set the texture reflection matrix used to rotate/transform the reflection.
  60638. * @param value Define the reflection matrix to set
  60639. */
  60640. setReflectionTextureMatrix(value: Matrix): void;
  60641. /**
  60642. * Parses a JSON representation of an HDR Texture in order to create the texture
  60643. * @param parsedTexture Define the JSON representation
  60644. * @param scene Define the scene the texture should be created in
  60645. * @param rootUrl Define the root url in case we need to load relative dependencies
  60646. * @returns the newly created texture after parsing
  60647. */
  60648. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60649. serialize(): any;
  60650. }
  60651. }
  60652. declare module BABYLON {
  60653. /**
  60654. * Class used to control physics engine
  60655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60656. */
  60657. export class PhysicsEngine implements IPhysicsEngine {
  60658. private _physicsPlugin;
  60659. /**
  60660. * Global value used to control the smallest number supported by the simulation
  60661. */
  60662. static Epsilon: number;
  60663. private _impostors;
  60664. private _joints;
  60665. private _subTimeStep;
  60666. /**
  60667. * Gets the gravity vector used by the simulation
  60668. */
  60669. gravity: Vector3;
  60670. /**
  60671. * Factory used to create the default physics plugin.
  60672. * @returns The default physics plugin
  60673. */
  60674. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60675. /**
  60676. * Creates a new Physics Engine
  60677. * @param gravity defines the gravity vector used by the simulation
  60678. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60679. */
  60680. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60681. /**
  60682. * Sets the gravity vector used by the simulation
  60683. * @param gravity defines the gravity vector to use
  60684. */
  60685. setGravity(gravity: Vector3): void;
  60686. /**
  60687. * Set the time step of the physics engine.
  60688. * Default is 1/60.
  60689. * To slow it down, enter 1/600 for example.
  60690. * To speed it up, 1/30
  60691. * @param newTimeStep defines the new timestep to apply to this world.
  60692. */
  60693. setTimeStep(newTimeStep?: number): void;
  60694. /**
  60695. * Get the time step of the physics engine.
  60696. * @returns the current time step
  60697. */
  60698. getTimeStep(): number;
  60699. /**
  60700. * Set the sub time step of the physics engine.
  60701. * Default is 0 meaning there is no sub steps
  60702. * To increase physics resolution precision, set a small value (like 1 ms)
  60703. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60704. */
  60705. setSubTimeStep(subTimeStep?: number): void;
  60706. /**
  60707. * Get the sub time step of the physics engine.
  60708. * @returns the current sub time step
  60709. */
  60710. getSubTimeStep(): number;
  60711. /**
  60712. * Release all resources
  60713. */
  60714. dispose(): void;
  60715. /**
  60716. * Gets the name of the current physics plugin
  60717. * @returns the name of the plugin
  60718. */
  60719. getPhysicsPluginName(): string;
  60720. /**
  60721. * Adding a new impostor for the impostor tracking.
  60722. * This will be done by the impostor itself.
  60723. * @param impostor the impostor to add
  60724. */
  60725. addImpostor(impostor: PhysicsImpostor): void;
  60726. /**
  60727. * Remove an impostor from the engine.
  60728. * This impostor and its mesh will not longer be updated by the physics engine.
  60729. * @param impostor the impostor to remove
  60730. */
  60731. removeImpostor(impostor: PhysicsImpostor): void;
  60732. /**
  60733. * Add a joint to the physics engine
  60734. * @param mainImpostor defines the main impostor to which the joint is added.
  60735. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60736. * @param joint defines the joint that will connect both impostors.
  60737. */
  60738. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60739. /**
  60740. * Removes a joint from the simulation
  60741. * @param mainImpostor defines the impostor used with the joint
  60742. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60743. * @param joint defines the joint to remove
  60744. */
  60745. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60746. /**
  60747. * Called by the scene. No need to call it.
  60748. * @param delta defines the timespam between frames
  60749. */
  60750. _step(delta: number): void;
  60751. /**
  60752. * Gets the current plugin used to run the simulation
  60753. * @returns current plugin
  60754. */
  60755. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60756. /**
  60757. * Gets the list of physic impostors
  60758. * @returns an array of PhysicsImpostor
  60759. */
  60760. getImpostors(): Array<PhysicsImpostor>;
  60761. /**
  60762. * Gets the impostor for a physics enabled object
  60763. * @param object defines the object impersonated by the impostor
  60764. * @returns the PhysicsImpostor or null if not found
  60765. */
  60766. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60767. /**
  60768. * Gets the impostor for a physics body object
  60769. * @param body defines physics body used by the impostor
  60770. * @returns the PhysicsImpostor or null if not found
  60771. */
  60772. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60773. /**
  60774. * Does a raycast in the physics world
  60775. * @param from when should the ray start?
  60776. * @param to when should the ray end?
  60777. * @returns PhysicsRaycastResult
  60778. */
  60779. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60780. }
  60781. }
  60782. declare module BABYLON {
  60783. /** @hidden */
  60784. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60785. private _useDeltaForWorldStep;
  60786. world: any;
  60787. name: string;
  60788. private _physicsMaterials;
  60789. private _fixedTimeStep;
  60790. private _cannonRaycastResult;
  60791. private _raycastResult;
  60792. private _physicsBodysToRemoveAfterStep;
  60793. private _firstFrame;
  60794. BJSCANNON: any;
  60795. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60796. setGravity(gravity: Vector3): void;
  60797. setTimeStep(timeStep: number): void;
  60798. getTimeStep(): number;
  60799. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60800. private _removeMarkedPhysicsBodiesFromWorld;
  60801. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60802. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60803. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60804. private _processChildMeshes;
  60805. removePhysicsBody(impostor: PhysicsImpostor): void;
  60806. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60807. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60808. private _addMaterial;
  60809. private _checkWithEpsilon;
  60810. private _createShape;
  60811. private _createHeightmap;
  60812. private _minus90X;
  60813. private _plus90X;
  60814. private _tmpPosition;
  60815. private _tmpDeltaPosition;
  60816. private _tmpUnityRotation;
  60817. private _updatePhysicsBodyTransformation;
  60818. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60819. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60820. isSupported(): boolean;
  60821. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60822. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60823. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60824. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60825. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60826. getBodyMass(impostor: PhysicsImpostor): number;
  60827. getBodyFriction(impostor: PhysicsImpostor): number;
  60828. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60829. getBodyRestitution(impostor: PhysicsImpostor): number;
  60830. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60831. sleepBody(impostor: PhysicsImpostor): void;
  60832. wakeUpBody(impostor: PhysicsImpostor): void;
  60833. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60834. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60835. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60836. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60837. getRadius(impostor: PhysicsImpostor): number;
  60838. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60839. dispose(): void;
  60840. private _extendNamespace;
  60841. /**
  60842. * Does a raycast in the physics world
  60843. * @param from when should the ray start?
  60844. * @param to when should the ray end?
  60845. * @returns PhysicsRaycastResult
  60846. */
  60847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60848. }
  60849. }
  60850. declare module BABYLON {
  60851. /** @hidden */
  60852. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60853. private _useDeltaForWorldStep;
  60854. world: any;
  60855. name: string;
  60856. BJSOIMO: any;
  60857. private _raycastResult;
  60858. private _fixedTimeStep;
  60859. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60860. setGravity(gravity: Vector3): void;
  60861. setTimeStep(timeStep: number): void;
  60862. getTimeStep(): number;
  60863. private _tmpImpostorsArray;
  60864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60866. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60867. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60868. private _tmpPositionVector;
  60869. removePhysicsBody(impostor: PhysicsImpostor): void;
  60870. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60871. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60872. isSupported(): boolean;
  60873. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60874. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60875. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60876. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60877. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60878. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60879. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60880. getBodyMass(impostor: PhysicsImpostor): number;
  60881. getBodyFriction(impostor: PhysicsImpostor): number;
  60882. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60883. getBodyRestitution(impostor: PhysicsImpostor): number;
  60884. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60885. sleepBody(impostor: PhysicsImpostor): void;
  60886. wakeUpBody(impostor: PhysicsImpostor): void;
  60887. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60888. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60889. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60890. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60891. getRadius(impostor: PhysicsImpostor): number;
  60892. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60893. dispose(): void;
  60894. /**
  60895. * Does a raycast in the physics world
  60896. * @param from when should the ray start?
  60897. * @param to when should the ray end?
  60898. * @returns PhysicsRaycastResult
  60899. */
  60900. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60901. }
  60902. }
  60903. declare module BABYLON {
  60904. /**
  60905. * AmmoJS Physics plugin
  60906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60907. * @see https://github.com/kripken/ammo.js/
  60908. */
  60909. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60910. private _useDeltaForWorldStep;
  60911. /**
  60912. * Reference to the Ammo library
  60913. */
  60914. bjsAMMO: any;
  60915. /**
  60916. * Created ammoJS world which physics bodies are added to
  60917. */
  60918. world: any;
  60919. /**
  60920. * Name of the plugin
  60921. */
  60922. name: string;
  60923. private _timeStep;
  60924. private _fixedTimeStep;
  60925. private _maxSteps;
  60926. private _tmpQuaternion;
  60927. private _tmpAmmoTransform;
  60928. private _tmpAmmoQuaternion;
  60929. private _tmpAmmoConcreteContactResultCallback;
  60930. private _collisionConfiguration;
  60931. private _dispatcher;
  60932. private _overlappingPairCache;
  60933. private _solver;
  60934. private _softBodySolver;
  60935. private _tmpAmmoVectorA;
  60936. private _tmpAmmoVectorB;
  60937. private _tmpAmmoVectorC;
  60938. private _tmpAmmoVectorD;
  60939. private _tmpContactCallbackResult;
  60940. private _tmpAmmoVectorRCA;
  60941. private _tmpAmmoVectorRCB;
  60942. private _raycastResult;
  60943. private static readonly DISABLE_COLLISION_FLAG;
  60944. private static readonly KINEMATIC_FLAG;
  60945. private static readonly DISABLE_DEACTIVATION_FLAG;
  60946. /**
  60947. * Initializes the ammoJS plugin
  60948. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60949. * @param ammoInjection can be used to inject your own ammo reference
  60950. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60951. */
  60952. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60953. /**
  60954. * Sets the gravity of the physics world (m/(s^2))
  60955. * @param gravity Gravity to set
  60956. */
  60957. setGravity(gravity: Vector3): void;
  60958. /**
  60959. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60960. * @param timeStep timestep to use in seconds
  60961. */
  60962. setTimeStep(timeStep: number): void;
  60963. /**
  60964. * 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)
  60965. * @param fixedTimeStep fixedTimeStep to use in seconds
  60966. */
  60967. setFixedTimeStep(fixedTimeStep: number): void;
  60968. /**
  60969. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60970. * @param maxSteps the maximum number of steps by the physics engine per frame
  60971. */
  60972. setMaxSteps(maxSteps: number): void;
  60973. /**
  60974. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60975. * @returns the current timestep in seconds
  60976. */
  60977. getTimeStep(): number;
  60978. /**
  60979. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60980. */
  60981. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60982. private _isImpostorInContact;
  60983. private _isImpostorPairInContact;
  60984. private _stepSimulation;
  60985. /**
  60986. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60987. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60988. * After the step the babylon meshes are set to the position of the physics imposters
  60989. * @param delta amount of time to step forward
  60990. * @param impostors array of imposters to update before/after the step
  60991. */
  60992. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60993. /**
  60994. * Update babylon mesh to match physics world object
  60995. * @param impostor imposter to match
  60996. */
  60997. private _afterSoftStep;
  60998. /**
  60999. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61000. * @param impostor imposter to match
  61001. */
  61002. private _ropeStep;
  61003. /**
  61004. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61005. * @param impostor imposter to match
  61006. */
  61007. private _softbodyOrClothStep;
  61008. private _tmpMatrix;
  61009. /**
  61010. * Applies an impulse on the imposter
  61011. * @param impostor imposter to apply impulse to
  61012. * @param force amount of force to be applied to the imposter
  61013. * @param contactPoint the location to apply the impulse on the imposter
  61014. */
  61015. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61016. /**
  61017. * Applies a force on the imposter
  61018. * @param impostor imposter to apply force
  61019. * @param force amount of force to be applied to the imposter
  61020. * @param contactPoint the location to apply the force on the imposter
  61021. */
  61022. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61023. /**
  61024. * Creates a physics body using the plugin
  61025. * @param impostor the imposter to create the physics body on
  61026. */
  61027. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61028. /**
  61029. * Removes the physics body from the imposter and disposes of the body's memory
  61030. * @param impostor imposter to remove the physics body from
  61031. */
  61032. removePhysicsBody(impostor: PhysicsImpostor): void;
  61033. /**
  61034. * Generates a joint
  61035. * @param impostorJoint the imposter joint to create the joint with
  61036. */
  61037. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61038. /**
  61039. * Removes a joint
  61040. * @param impostorJoint the imposter joint to remove the joint from
  61041. */
  61042. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61043. private _addMeshVerts;
  61044. /**
  61045. * Initialise the soft body vertices to match its object's (mesh) vertices
  61046. * Softbody vertices (nodes) are in world space and to match this
  61047. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61048. * @param impostor to create the softbody for
  61049. */
  61050. private _softVertexData;
  61051. /**
  61052. * Create an impostor's soft body
  61053. * @param impostor to create the softbody for
  61054. */
  61055. private _createSoftbody;
  61056. /**
  61057. * Create cloth for an impostor
  61058. * @param impostor to create the softbody for
  61059. */
  61060. private _createCloth;
  61061. /**
  61062. * Create rope for an impostor
  61063. * @param impostor to create the softbody for
  61064. */
  61065. private _createRope;
  61066. /**
  61067. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61068. * @param impostor to create the custom physics shape for
  61069. */
  61070. private _createCustom;
  61071. private _addHullVerts;
  61072. private _createShape;
  61073. /**
  61074. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61075. * @param impostor imposter containing the physics body and babylon object
  61076. */
  61077. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61078. /**
  61079. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61080. * @param impostor imposter containing the physics body and babylon object
  61081. * @param newPosition new position
  61082. * @param newRotation new rotation
  61083. */
  61084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61085. /**
  61086. * If this plugin is supported
  61087. * @returns true if its supported
  61088. */
  61089. isSupported(): boolean;
  61090. /**
  61091. * Sets the linear velocity of the physics body
  61092. * @param impostor imposter to set the velocity on
  61093. * @param velocity velocity to set
  61094. */
  61095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61096. /**
  61097. * Sets the angular velocity of the physics body
  61098. * @param impostor imposter to set the velocity on
  61099. * @param velocity velocity to set
  61100. */
  61101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61102. /**
  61103. * gets the linear velocity
  61104. * @param impostor imposter to get linear velocity from
  61105. * @returns linear velocity
  61106. */
  61107. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61108. /**
  61109. * gets the angular velocity
  61110. * @param impostor imposter to get angular velocity from
  61111. * @returns angular velocity
  61112. */
  61113. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61114. /**
  61115. * Sets the mass of physics body
  61116. * @param impostor imposter to set the mass on
  61117. * @param mass mass to set
  61118. */
  61119. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61120. /**
  61121. * Gets the mass of the physics body
  61122. * @param impostor imposter to get the mass from
  61123. * @returns mass
  61124. */
  61125. getBodyMass(impostor: PhysicsImpostor): number;
  61126. /**
  61127. * Gets friction of the impostor
  61128. * @param impostor impostor to get friction from
  61129. * @returns friction value
  61130. */
  61131. getBodyFriction(impostor: PhysicsImpostor): number;
  61132. /**
  61133. * Sets friction of the impostor
  61134. * @param impostor impostor to set friction on
  61135. * @param friction friction value
  61136. */
  61137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61138. /**
  61139. * Gets restitution of the impostor
  61140. * @param impostor impostor to get restitution from
  61141. * @returns restitution value
  61142. */
  61143. getBodyRestitution(impostor: PhysicsImpostor): number;
  61144. /**
  61145. * Sets resitution of the impostor
  61146. * @param impostor impostor to set resitution on
  61147. * @param restitution resitution value
  61148. */
  61149. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61150. /**
  61151. * Gets pressure inside the impostor
  61152. * @param impostor impostor to get pressure from
  61153. * @returns pressure value
  61154. */
  61155. getBodyPressure(impostor: PhysicsImpostor): number;
  61156. /**
  61157. * Sets pressure inside a soft body impostor
  61158. * Cloth and rope must remain 0 pressure
  61159. * @param impostor impostor to set pressure on
  61160. * @param pressure pressure value
  61161. */
  61162. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61163. /**
  61164. * Gets stiffness of the impostor
  61165. * @param impostor impostor to get stiffness from
  61166. * @returns pressure value
  61167. */
  61168. getBodyStiffness(impostor: PhysicsImpostor): number;
  61169. /**
  61170. * Sets stiffness of the impostor
  61171. * @param impostor impostor to set stiffness on
  61172. * @param stiffness stiffness value from 0 to 1
  61173. */
  61174. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61175. /**
  61176. * Gets velocityIterations of the impostor
  61177. * @param impostor impostor to get velocity iterations from
  61178. * @returns velocityIterations value
  61179. */
  61180. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61181. /**
  61182. * Sets velocityIterations of the impostor
  61183. * @param impostor impostor to set velocity iterations on
  61184. * @param velocityIterations velocityIterations value
  61185. */
  61186. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61187. /**
  61188. * Gets positionIterations of the impostor
  61189. * @param impostor impostor to get position iterations from
  61190. * @returns positionIterations value
  61191. */
  61192. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61193. /**
  61194. * Sets positionIterations of the impostor
  61195. * @param impostor impostor to set position on
  61196. * @param positionIterations positionIterations value
  61197. */
  61198. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61199. /**
  61200. * Append an anchor to a cloth object
  61201. * @param impostor is the cloth impostor to add anchor to
  61202. * @param otherImpostor is the rigid impostor to anchor to
  61203. * @param width ratio across width from 0 to 1
  61204. * @param height ratio up height from 0 to 1
  61205. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61206. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61207. */
  61208. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61209. /**
  61210. * Append an hook to a rope object
  61211. * @param impostor is the rope impostor to add hook to
  61212. * @param otherImpostor is the rigid impostor to hook to
  61213. * @param length ratio along the rope from 0 to 1
  61214. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61215. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61216. */
  61217. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61218. /**
  61219. * Sleeps the physics body and stops it from being active
  61220. * @param impostor impostor to sleep
  61221. */
  61222. sleepBody(impostor: PhysicsImpostor): void;
  61223. /**
  61224. * Activates the physics body
  61225. * @param impostor impostor to activate
  61226. */
  61227. wakeUpBody(impostor: PhysicsImpostor): void;
  61228. /**
  61229. * Updates the distance parameters of the joint
  61230. * @param joint joint to update
  61231. * @param maxDistance maximum distance of the joint
  61232. * @param minDistance minimum distance of the joint
  61233. */
  61234. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61235. /**
  61236. * Sets a motor on the joint
  61237. * @param joint joint to set motor on
  61238. * @param speed speed of the motor
  61239. * @param maxForce maximum force of the motor
  61240. * @param motorIndex index of the motor
  61241. */
  61242. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61243. /**
  61244. * Sets the motors limit
  61245. * @param joint joint to set limit on
  61246. * @param upperLimit upper limit
  61247. * @param lowerLimit lower limit
  61248. */
  61249. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61250. /**
  61251. * Syncs the position and rotation of a mesh with the impostor
  61252. * @param mesh mesh to sync
  61253. * @param impostor impostor to update the mesh with
  61254. */
  61255. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61256. /**
  61257. * Gets the radius of the impostor
  61258. * @param impostor impostor to get radius from
  61259. * @returns the radius
  61260. */
  61261. getRadius(impostor: PhysicsImpostor): number;
  61262. /**
  61263. * Gets the box size of the impostor
  61264. * @param impostor impostor to get box size from
  61265. * @param result the resulting box size
  61266. */
  61267. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61268. /**
  61269. * Disposes of the impostor
  61270. */
  61271. dispose(): void;
  61272. /**
  61273. * Does a raycast in the physics world
  61274. * @param from when should the ray start?
  61275. * @param to when should the ray end?
  61276. * @returns PhysicsRaycastResult
  61277. */
  61278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61279. }
  61280. }
  61281. declare module BABYLON {
  61282. interface AbstractScene {
  61283. /**
  61284. * The list of reflection probes added to the scene
  61285. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61286. */
  61287. reflectionProbes: Array<ReflectionProbe>;
  61288. /**
  61289. * Removes the given reflection probe from this scene.
  61290. * @param toRemove The reflection probe to remove
  61291. * @returns The index of the removed reflection probe
  61292. */
  61293. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61294. /**
  61295. * Adds the given reflection probe to this scene.
  61296. * @param newReflectionProbe The reflection probe to add
  61297. */
  61298. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61299. }
  61300. /**
  61301. * Class used to generate realtime reflection / refraction cube textures
  61302. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61303. */
  61304. export class ReflectionProbe {
  61305. /** defines the name of the probe */
  61306. name: string;
  61307. private _scene;
  61308. private _renderTargetTexture;
  61309. private _projectionMatrix;
  61310. private _viewMatrix;
  61311. private _target;
  61312. private _add;
  61313. private _attachedMesh;
  61314. private _invertYAxis;
  61315. /** Gets or sets probe position (center of the cube map) */
  61316. position: Vector3;
  61317. /**
  61318. * Creates a new reflection probe
  61319. * @param name defines the name of the probe
  61320. * @param size defines the texture resolution (for each face)
  61321. * @param scene defines the hosting scene
  61322. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61323. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61324. */
  61325. constructor(
  61326. /** defines the name of the probe */
  61327. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61328. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61329. get samples(): number;
  61330. set samples(value: number);
  61331. /** Gets or sets the refresh rate to use (on every frame by default) */
  61332. get refreshRate(): number;
  61333. set refreshRate(value: number);
  61334. /**
  61335. * Gets the hosting scene
  61336. * @returns a Scene
  61337. */
  61338. getScene(): Scene;
  61339. /** Gets the internal CubeTexture used to render to */
  61340. get cubeTexture(): RenderTargetTexture;
  61341. /** Gets the list of meshes to render */
  61342. get renderList(): Nullable<AbstractMesh[]>;
  61343. /**
  61344. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61345. * @param mesh defines the mesh to attach to
  61346. */
  61347. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61348. /**
  61349. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61350. * @param renderingGroupId The rendering group id corresponding to its index
  61351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61352. */
  61353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61354. /**
  61355. * Clean all associated resources
  61356. */
  61357. dispose(): void;
  61358. /**
  61359. * Converts the reflection probe information to a readable string for debug purpose.
  61360. * @param fullDetails Supports for multiple levels of logging within scene loading
  61361. * @returns the human readable reflection probe info
  61362. */
  61363. toString(fullDetails?: boolean): string;
  61364. /**
  61365. * Get the class name of the relfection probe.
  61366. * @returns "ReflectionProbe"
  61367. */
  61368. getClassName(): string;
  61369. /**
  61370. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61371. * @returns The JSON representation of the texture
  61372. */
  61373. serialize(): any;
  61374. /**
  61375. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61376. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61377. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61378. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61379. * @returns The parsed reflection probe if successful
  61380. */
  61381. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61382. }
  61383. }
  61384. declare module BABYLON {
  61385. /** @hidden */
  61386. export var _BabylonLoaderRegistered: boolean;
  61387. /**
  61388. * Helps setting up some configuration for the babylon file loader.
  61389. */
  61390. export class BabylonFileLoaderConfiguration {
  61391. /**
  61392. * The loader does not allow injecting custom physix engine into the plugins.
  61393. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61394. * So you could set this variable to your engine import to make it work.
  61395. */
  61396. static LoaderInjectedPhysicsEngine: any;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /**
  61401. * The Physically based simple base material of BJS.
  61402. *
  61403. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61404. * It is used as the base class for both the specGloss and metalRough conventions.
  61405. */
  61406. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61407. /**
  61408. * Number of Simultaneous lights allowed on the material.
  61409. */
  61410. maxSimultaneousLights: number;
  61411. /**
  61412. * If sets to true, disables all the lights affecting the material.
  61413. */
  61414. disableLighting: boolean;
  61415. /**
  61416. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61417. */
  61418. environmentTexture: BaseTexture;
  61419. /**
  61420. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61421. */
  61422. invertNormalMapX: boolean;
  61423. /**
  61424. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61425. */
  61426. invertNormalMapY: boolean;
  61427. /**
  61428. * Normal map used in the model.
  61429. */
  61430. normalTexture: BaseTexture;
  61431. /**
  61432. * Emissivie color used to self-illuminate the model.
  61433. */
  61434. emissiveColor: Color3;
  61435. /**
  61436. * Emissivie texture used to self-illuminate the model.
  61437. */
  61438. emissiveTexture: BaseTexture;
  61439. /**
  61440. * Occlusion Channel Strenght.
  61441. */
  61442. occlusionStrength: number;
  61443. /**
  61444. * Occlusion Texture of the material (adding extra occlusion effects).
  61445. */
  61446. occlusionTexture: BaseTexture;
  61447. /**
  61448. * Defines the alpha limits in alpha test mode.
  61449. */
  61450. alphaCutOff: number;
  61451. /**
  61452. * Gets the current double sided mode.
  61453. */
  61454. get doubleSided(): boolean;
  61455. /**
  61456. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61457. */
  61458. set doubleSided(value: boolean);
  61459. /**
  61460. * Stores the pre-calculated light information of a mesh in a texture.
  61461. */
  61462. lightmapTexture: BaseTexture;
  61463. /**
  61464. * If true, the light map contains occlusion information instead of lighting info.
  61465. */
  61466. useLightmapAsShadowmap: boolean;
  61467. /**
  61468. * Instantiates a new PBRMaterial instance.
  61469. *
  61470. * @param name The material name
  61471. * @param scene The scene the material will be use in.
  61472. */
  61473. constructor(name: string, scene: Scene);
  61474. getClassName(): string;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * The PBR material of BJS following the metal roughness convention.
  61480. *
  61481. * This fits to the PBR convention in the GLTF definition:
  61482. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61483. */
  61484. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61485. /**
  61486. * The base color has two different interpretations depending on the value of metalness.
  61487. * When the material is a metal, the base color is the specific measured reflectance value
  61488. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61489. * of the material.
  61490. */
  61491. baseColor: Color3;
  61492. /**
  61493. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61494. * well as opacity information in the alpha channel.
  61495. */
  61496. baseTexture: BaseTexture;
  61497. /**
  61498. * Specifies the metallic scalar value of the material.
  61499. * Can also be used to scale the metalness values of the metallic texture.
  61500. */
  61501. metallic: number;
  61502. /**
  61503. * Specifies the roughness scalar value of the material.
  61504. * Can also be used to scale the roughness values of the metallic texture.
  61505. */
  61506. roughness: number;
  61507. /**
  61508. * Texture containing both the metallic value in the B channel and the
  61509. * roughness value in the G channel to keep better precision.
  61510. */
  61511. metallicRoughnessTexture: BaseTexture;
  61512. /**
  61513. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61514. *
  61515. * @param name The material name
  61516. * @param scene The scene the material will be use in.
  61517. */
  61518. constructor(name: string, scene: Scene);
  61519. /**
  61520. * Return the currrent class name of the material.
  61521. */
  61522. getClassName(): string;
  61523. /**
  61524. * Makes a duplicate of the current material.
  61525. * @param name - name to use for the new material.
  61526. */
  61527. clone(name: string): PBRMetallicRoughnessMaterial;
  61528. /**
  61529. * Serialize the material to a parsable JSON object.
  61530. */
  61531. serialize(): any;
  61532. /**
  61533. * Parses a JSON object correponding to the serialize function.
  61534. */
  61535. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /**
  61540. * The PBR material of BJS following the specular glossiness convention.
  61541. *
  61542. * This fits to the PBR convention in the GLTF definition:
  61543. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61544. */
  61545. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61546. /**
  61547. * Specifies the diffuse color of the material.
  61548. */
  61549. diffuseColor: Color3;
  61550. /**
  61551. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61552. * channel.
  61553. */
  61554. diffuseTexture: BaseTexture;
  61555. /**
  61556. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61557. */
  61558. specularColor: Color3;
  61559. /**
  61560. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61561. */
  61562. glossiness: number;
  61563. /**
  61564. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61565. */
  61566. specularGlossinessTexture: BaseTexture;
  61567. /**
  61568. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61569. *
  61570. * @param name The material name
  61571. * @param scene The scene the material will be use in.
  61572. */
  61573. constructor(name: string, scene: Scene);
  61574. /**
  61575. * Return the currrent class name of the material.
  61576. */
  61577. getClassName(): string;
  61578. /**
  61579. * Makes a duplicate of the current material.
  61580. * @param name - name to use for the new material.
  61581. */
  61582. clone(name: string): PBRSpecularGlossinessMaterial;
  61583. /**
  61584. * Serialize the material to a parsable JSON object.
  61585. */
  61586. serialize(): any;
  61587. /**
  61588. * Parses a JSON object correponding to the serialize function.
  61589. */
  61590. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61591. }
  61592. }
  61593. declare module BABYLON {
  61594. /**
  61595. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61596. * It can help converting any input color in a desired output one. This can then be used to create effects
  61597. * from sepia, black and white to sixties or futuristic rendering...
  61598. *
  61599. * The only supported format is currently 3dl.
  61600. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61601. */
  61602. export class ColorGradingTexture extends BaseTexture {
  61603. /**
  61604. * The texture URL.
  61605. */
  61606. url: string;
  61607. /**
  61608. * Empty line regex stored for GC.
  61609. */
  61610. private static _noneEmptyLineRegex;
  61611. private _textureMatrix;
  61612. private _onLoad;
  61613. /**
  61614. * Instantiates a ColorGradingTexture from the following parameters.
  61615. *
  61616. * @param url The location of the color gradind data (currently only supporting 3dl)
  61617. * @param sceneOrEngine The scene or engine the texture will be used in
  61618. * @param onLoad defines a callback triggered when the texture has been loaded
  61619. */
  61620. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61621. /**
  61622. * Fires the onload event from the constructor if requested.
  61623. */
  61624. private _triggerOnLoad;
  61625. /**
  61626. * Returns the texture matrix used in most of the material.
  61627. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61628. */
  61629. getTextureMatrix(): Matrix;
  61630. /**
  61631. * Occurs when the file being loaded is a .3dl LUT file.
  61632. */
  61633. private load3dlTexture;
  61634. /**
  61635. * Starts the loading process of the texture.
  61636. */
  61637. private loadTexture;
  61638. /**
  61639. * Clones the color gradind texture.
  61640. */
  61641. clone(): ColorGradingTexture;
  61642. /**
  61643. * Called during delayed load for textures.
  61644. */
  61645. delayLoad(): void;
  61646. /**
  61647. * Parses a color grading texture serialized by Babylon.
  61648. * @param parsedTexture The texture information being parsedTexture
  61649. * @param scene The scene to load the texture in
  61650. * @param rootUrl The root url of the data assets to load
  61651. * @return A color gradind texture
  61652. */
  61653. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61654. /**
  61655. * Serializes the LUT texture to json format.
  61656. */
  61657. serialize(): any;
  61658. }
  61659. }
  61660. declare module BABYLON {
  61661. /**
  61662. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61663. */
  61664. export class EquiRectangularCubeTexture extends BaseTexture {
  61665. /** The six faces of the cube. */
  61666. private static _FacesMapping;
  61667. private _noMipmap;
  61668. private _onLoad;
  61669. private _onError;
  61670. /** The size of the cubemap. */
  61671. private _size;
  61672. /** The buffer of the image. */
  61673. private _buffer;
  61674. /** The width of the input image. */
  61675. private _width;
  61676. /** The height of the input image. */
  61677. private _height;
  61678. /** The URL to the image. */
  61679. url: string;
  61680. /**
  61681. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61682. * @param url The location of the image
  61683. * @param scene The scene the texture will be used in
  61684. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61685. * @param noMipmap Forces to not generate the mipmap if true
  61686. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61687. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61688. * @param onLoad — defines a callback called when texture is loaded
  61689. * @param onError — defines a callback called if there is an error
  61690. */
  61691. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61692. /**
  61693. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61694. */
  61695. private loadImage;
  61696. /**
  61697. * Convert the image buffer into a cubemap and create a CubeTexture.
  61698. */
  61699. private loadTexture;
  61700. /**
  61701. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61702. * @param buffer The ArrayBuffer that should be converted.
  61703. * @returns The buffer as Float32Array.
  61704. */
  61705. private getFloat32ArrayFromArrayBuffer;
  61706. /**
  61707. * Get the current class name of the texture useful for serialization or dynamic coding.
  61708. * @returns "EquiRectangularCubeTexture"
  61709. */
  61710. getClassName(): string;
  61711. /**
  61712. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61713. * @returns A clone of the current EquiRectangularCubeTexture.
  61714. */
  61715. clone(): EquiRectangularCubeTexture;
  61716. }
  61717. }
  61718. declare module BABYLON {
  61719. /**
  61720. * Defines the options related to the creation of an HtmlElementTexture
  61721. */
  61722. export interface IHtmlElementTextureOptions {
  61723. /**
  61724. * Defines wether mip maps should be created or not.
  61725. */
  61726. generateMipMaps?: boolean;
  61727. /**
  61728. * Defines the sampling mode of the texture.
  61729. */
  61730. samplingMode?: number;
  61731. /**
  61732. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61733. */
  61734. engine: Nullable<ThinEngine>;
  61735. /**
  61736. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61737. */
  61738. scene: Nullable<Scene>;
  61739. }
  61740. /**
  61741. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61742. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61743. * is automatically managed.
  61744. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61745. * in your application.
  61746. *
  61747. * As the update is not automatic, you need to call them manually.
  61748. */
  61749. export class HtmlElementTexture extends BaseTexture {
  61750. /**
  61751. * The texture URL.
  61752. */
  61753. element: HTMLVideoElement | HTMLCanvasElement;
  61754. private static readonly DefaultOptions;
  61755. private _textureMatrix;
  61756. private _isVideo;
  61757. private _generateMipMaps;
  61758. private _samplingMode;
  61759. /**
  61760. * Instantiates a HtmlElementTexture from the following parameters.
  61761. *
  61762. * @param name Defines the name of the texture
  61763. * @param element Defines the video or canvas the texture is filled with
  61764. * @param options Defines the other none mandatory texture creation options
  61765. */
  61766. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61767. private _createInternalTexture;
  61768. /**
  61769. * Returns the texture matrix used in most of the material.
  61770. */
  61771. getTextureMatrix(): Matrix;
  61772. /**
  61773. * Updates the content of the texture.
  61774. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61775. */
  61776. update(invertY?: Nullable<boolean>): void;
  61777. }
  61778. }
  61779. declare module BABYLON {
  61780. /**
  61781. * Based on jsTGALoader - Javascript loader for TGA file
  61782. * By Vincent Thibault
  61783. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61784. */
  61785. export class TGATools {
  61786. private static _TYPE_INDEXED;
  61787. private static _TYPE_RGB;
  61788. private static _TYPE_GREY;
  61789. private static _TYPE_RLE_INDEXED;
  61790. private static _TYPE_RLE_RGB;
  61791. private static _TYPE_RLE_GREY;
  61792. private static _ORIGIN_MASK;
  61793. private static _ORIGIN_SHIFT;
  61794. private static _ORIGIN_BL;
  61795. private static _ORIGIN_BR;
  61796. private static _ORIGIN_UL;
  61797. private static _ORIGIN_UR;
  61798. /**
  61799. * Gets the header of a TGA file
  61800. * @param data defines the TGA data
  61801. * @returns the header
  61802. */
  61803. static GetTGAHeader(data: Uint8Array): any;
  61804. /**
  61805. * Uploads TGA content to a Babylon Texture
  61806. * @hidden
  61807. */
  61808. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61809. /** @hidden */
  61810. 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;
  61811. /** @hidden */
  61812. 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;
  61813. /** @hidden */
  61814. 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;
  61815. /** @hidden */
  61816. 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;
  61817. /** @hidden */
  61818. 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;
  61819. /** @hidden */
  61820. 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;
  61821. }
  61822. }
  61823. declare module BABYLON {
  61824. /**
  61825. * Implementation of the TGA Texture Loader.
  61826. * @hidden
  61827. */
  61828. export class _TGATextureLoader implements IInternalTextureLoader {
  61829. /**
  61830. * Defines wether the loader supports cascade loading the different faces.
  61831. */
  61832. readonly supportCascades: boolean;
  61833. /**
  61834. * This returns if the loader support the current file information.
  61835. * @param extension defines the file extension of the file being loaded
  61836. * @returns true if the loader can load the specified file
  61837. */
  61838. canLoad(extension: string): boolean;
  61839. /**
  61840. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61841. * @param data contains the texture data
  61842. * @param texture defines the BabylonJS internal texture
  61843. * @param createPolynomials will be true if polynomials have been requested
  61844. * @param onLoad defines the callback to trigger once the texture is ready
  61845. * @param onError defines the callback to trigger in case of error
  61846. */
  61847. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61848. /**
  61849. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61850. * @param data contains the texture data
  61851. * @param texture defines the BabylonJS internal texture
  61852. * @param callback defines the method to call once ready to upload
  61853. */
  61854. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Info about the .basis files
  61860. */
  61861. class BasisFileInfo {
  61862. /**
  61863. * If the file has alpha
  61864. */
  61865. hasAlpha: boolean;
  61866. /**
  61867. * Info about each image of the basis file
  61868. */
  61869. images: Array<{
  61870. levels: Array<{
  61871. width: number;
  61872. height: number;
  61873. transcodedPixels: ArrayBufferView;
  61874. }>;
  61875. }>;
  61876. }
  61877. /**
  61878. * Result of transcoding a basis file
  61879. */
  61880. class TranscodeResult {
  61881. /**
  61882. * Info about the .basis file
  61883. */
  61884. fileInfo: BasisFileInfo;
  61885. /**
  61886. * Format to use when loading the file
  61887. */
  61888. format: number;
  61889. }
  61890. /**
  61891. * Configuration options for the Basis transcoder
  61892. */
  61893. export class BasisTranscodeConfiguration {
  61894. /**
  61895. * Supported compression formats used to determine the supported output format of the transcoder
  61896. */
  61897. supportedCompressionFormats?: {
  61898. /**
  61899. * etc1 compression format
  61900. */
  61901. etc1?: boolean;
  61902. /**
  61903. * s3tc compression format
  61904. */
  61905. s3tc?: boolean;
  61906. /**
  61907. * pvrtc compression format
  61908. */
  61909. pvrtc?: boolean;
  61910. /**
  61911. * etc2 compression format
  61912. */
  61913. etc2?: boolean;
  61914. };
  61915. /**
  61916. * If mipmap levels should be loaded for transcoded images (Default: true)
  61917. */
  61918. loadMipmapLevels?: boolean;
  61919. /**
  61920. * Index of a single image to load (Default: all images)
  61921. */
  61922. loadSingleImage?: number;
  61923. }
  61924. /**
  61925. * Used to load .Basis files
  61926. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61927. */
  61928. export class BasisTools {
  61929. private static _IgnoreSupportedFormats;
  61930. /**
  61931. * URL to use when loading the basis transcoder
  61932. */
  61933. static JSModuleURL: string;
  61934. /**
  61935. * URL to use when loading the wasm module for the transcoder
  61936. */
  61937. static WasmModuleURL: string;
  61938. /**
  61939. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61940. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61941. * @returns internal format corresponding to the Basis format
  61942. */
  61943. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61944. private static _WorkerPromise;
  61945. private static _Worker;
  61946. private static _actionId;
  61947. private static _CreateWorkerAsync;
  61948. /**
  61949. * Transcodes a loaded image file to compressed pixel data
  61950. * @param data image data to transcode
  61951. * @param config configuration options for the transcoding
  61952. * @returns a promise resulting in the transcoded image
  61953. */
  61954. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61955. /**
  61956. * Loads a texture from the transcode result
  61957. * @param texture texture load to
  61958. * @param transcodeResult the result of transcoding the basis file to load from
  61959. */
  61960. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61961. }
  61962. }
  61963. declare module BABYLON {
  61964. /**
  61965. * Loader for .basis file format
  61966. */
  61967. export class _BasisTextureLoader implements IInternalTextureLoader {
  61968. /**
  61969. * Defines whether the loader supports cascade loading the different faces.
  61970. */
  61971. readonly supportCascades: boolean;
  61972. /**
  61973. * This returns if the loader support the current file information.
  61974. * @param extension defines the file extension of the file being loaded
  61975. * @returns true if the loader can load the specified file
  61976. */
  61977. canLoad(extension: string): boolean;
  61978. /**
  61979. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61980. * @param data contains the texture data
  61981. * @param texture defines the BabylonJS internal texture
  61982. * @param createPolynomials will be true if polynomials have been requested
  61983. * @param onLoad defines the callback to trigger once the texture is ready
  61984. * @param onError defines the callback to trigger in case of error
  61985. */
  61986. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61987. /**
  61988. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61989. * @param data contains the texture data
  61990. * @param texture defines the BabylonJS internal texture
  61991. * @param callback defines the method to call once ready to upload
  61992. */
  61993. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61994. }
  61995. }
  61996. declare module BABYLON {
  61997. /**
  61998. * Defines the basic options interface of a TexturePacker Frame
  61999. */
  62000. export interface ITexturePackerFrame {
  62001. /**
  62002. * The frame ID
  62003. */
  62004. id: number;
  62005. /**
  62006. * The frames Scale
  62007. */
  62008. scale: Vector2;
  62009. /**
  62010. * The Frames offset
  62011. */
  62012. offset: Vector2;
  62013. }
  62014. /**
  62015. * This is a support class for frame Data on texture packer sets.
  62016. */
  62017. export class TexturePackerFrame implements ITexturePackerFrame {
  62018. /**
  62019. * The frame ID
  62020. */
  62021. id: number;
  62022. /**
  62023. * The frames Scale
  62024. */
  62025. scale: Vector2;
  62026. /**
  62027. * The Frames offset
  62028. */
  62029. offset: Vector2;
  62030. /**
  62031. * Initializes a texture package frame.
  62032. * @param id The numerical frame identifier
  62033. * @param scale Scalar Vector2 for UV frame
  62034. * @param offset Vector2 for the frame position in UV units.
  62035. * @returns TexturePackerFrame
  62036. */
  62037. constructor(id: number, scale: Vector2, offset: Vector2);
  62038. }
  62039. }
  62040. declare module BABYLON {
  62041. /**
  62042. * Defines the basic options interface of a TexturePacker
  62043. */
  62044. export interface ITexturePackerOptions {
  62045. /**
  62046. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62047. */
  62048. map?: string[];
  62049. /**
  62050. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62051. */
  62052. uvsIn?: string;
  62053. /**
  62054. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62055. */
  62056. uvsOut?: string;
  62057. /**
  62058. * number representing the layout style. Defaults to LAYOUT_STRIP
  62059. */
  62060. layout?: number;
  62061. /**
  62062. * number of columns if using custom column count layout(2). This defaults to 4.
  62063. */
  62064. colnum?: number;
  62065. /**
  62066. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62067. */
  62068. updateInputMeshes?: boolean;
  62069. /**
  62070. * boolean flag to dispose all the source textures. Defaults to true.
  62071. */
  62072. disposeSources?: boolean;
  62073. /**
  62074. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62075. */
  62076. fillBlanks?: boolean;
  62077. /**
  62078. * string value representing the context fill style color. Defaults to 'black'.
  62079. */
  62080. customFillColor?: string;
  62081. /**
  62082. * Width and Height Value of each Frame in the TexturePacker Sets
  62083. */
  62084. frameSize?: number;
  62085. /**
  62086. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62087. */
  62088. paddingRatio?: number;
  62089. /**
  62090. * Number that declares the fill method for the padding gutter.
  62091. */
  62092. paddingMode?: number;
  62093. /**
  62094. * If in SUBUV_COLOR padding mode what color to use.
  62095. */
  62096. paddingColor?: Color3 | Color4;
  62097. }
  62098. /**
  62099. * Defines the basic interface of a TexturePacker JSON File
  62100. */
  62101. export interface ITexturePackerJSON {
  62102. /**
  62103. * The frame ID
  62104. */
  62105. name: string;
  62106. /**
  62107. * The base64 channel data
  62108. */
  62109. sets: any;
  62110. /**
  62111. * The options of the Packer
  62112. */
  62113. options: ITexturePackerOptions;
  62114. /**
  62115. * The frame data of the Packer
  62116. */
  62117. frames: Array<number>;
  62118. }
  62119. /**
  62120. * This is a support class that generates a series of packed texture sets.
  62121. * @see https://doc.babylonjs.com/babylon101/materials
  62122. */
  62123. export class TexturePacker {
  62124. /** Packer Layout Constant 0 */
  62125. static readonly LAYOUT_STRIP: number;
  62126. /** Packer Layout Constant 1 */
  62127. static readonly LAYOUT_POWER2: number;
  62128. /** Packer Layout Constant 2 */
  62129. static readonly LAYOUT_COLNUM: number;
  62130. /** Packer Layout Constant 0 */
  62131. static readonly SUBUV_WRAP: number;
  62132. /** Packer Layout Constant 1 */
  62133. static readonly SUBUV_EXTEND: number;
  62134. /** Packer Layout Constant 2 */
  62135. static readonly SUBUV_COLOR: number;
  62136. /** The Name of the Texture Package */
  62137. name: string;
  62138. /** The scene scope of the TexturePacker */
  62139. scene: Scene;
  62140. /** The Meshes to target */
  62141. meshes: AbstractMesh[];
  62142. /** Arguments passed with the Constructor */
  62143. options: ITexturePackerOptions;
  62144. /** The promise that is started upon initialization */
  62145. promise: Nullable<Promise<TexturePacker | string>>;
  62146. /** The Container object for the channel sets that are generated */
  62147. sets: object;
  62148. /** The Container array for the frames that are generated */
  62149. frames: TexturePackerFrame[];
  62150. /** The expected number of textures the system is parsing. */
  62151. private _expecting;
  62152. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62153. private _paddingValue;
  62154. /**
  62155. * Initializes a texture package series from an array of meshes or a single mesh.
  62156. * @param name The name of the package
  62157. * @param meshes The target meshes to compose the package from
  62158. * @param options The arguments that texture packer should follow while building.
  62159. * @param scene The scene which the textures are scoped to.
  62160. * @returns TexturePacker
  62161. */
  62162. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62163. /**
  62164. * Starts the package process
  62165. * @param resolve The promises resolution function
  62166. * @returns TexturePacker
  62167. */
  62168. private _createFrames;
  62169. /**
  62170. * Calculates the Size of the Channel Sets
  62171. * @returns Vector2
  62172. */
  62173. private _calculateSize;
  62174. /**
  62175. * Calculates the UV data for the frames.
  62176. * @param baseSize the base frameSize
  62177. * @param padding the base frame padding
  62178. * @param dtSize size of the Dynamic Texture for that channel
  62179. * @param dtUnits is 1/dtSize
  62180. * @param update flag to update the input meshes
  62181. */
  62182. private _calculateMeshUVFrames;
  62183. /**
  62184. * Calculates the frames Offset.
  62185. * @param index of the frame
  62186. * @returns Vector2
  62187. */
  62188. private _getFrameOffset;
  62189. /**
  62190. * Updates a Mesh to the frame data
  62191. * @param mesh that is the target
  62192. * @param frameID or the frame index
  62193. */
  62194. private _updateMeshUV;
  62195. /**
  62196. * Updates a Meshes materials to use the texture packer channels
  62197. * @param m is the mesh to target
  62198. * @param force all channels on the packer to be set.
  62199. */
  62200. private _updateTextureReferences;
  62201. /**
  62202. * Public method to set a Mesh to a frame
  62203. * @param m that is the target
  62204. * @param frameID or the frame index
  62205. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62206. */
  62207. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62208. /**
  62209. * Starts the async promise to compile the texture packer.
  62210. * @returns Promise<void>
  62211. */
  62212. processAsync(): Promise<void>;
  62213. /**
  62214. * Disposes all textures associated with this packer
  62215. */
  62216. dispose(): void;
  62217. /**
  62218. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62219. * @param imageType is the image type to use.
  62220. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62221. */
  62222. download(imageType?: string, quality?: number): void;
  62223. /**
  62224. * Public method to load a texturePacker JSON file.
  62225. * @param data of the JSON file in string format.
  62226. */
  62227. updateFromJSON(data: string): void;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * 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.
  62233. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62234. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62235. */
  62236. export class CustomProceduralTexture extends ProceduralTexture {
  62237. private _animate;
  62238. private _time;
  62239. private _config;
  62240. private _texturePath;
  62241. /**
  62242. * Instantiates a new Custom Procedural Texture.
  62243. * 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.
  62244. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62245. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62246. * @param name Define the name of the texture
  62247. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62248. * @param size Define the size of the texture to create
  62249. * @param scene Define the scene the texture belongs to
  62250. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62251. * @param generateMipMaps Define if the texture should creates mip maps or not
  62252. */
  62253. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62254. private _loadJson;
  62255. /**
  62256. * Is the texture ready to be used ? (rendered at least once)
  62257. * @returns true if ready, otherwise, false.
  62258. */
  62259. isReady(): boolean;
  62260. /**
  62261. * Render the texture to its associated render target.
  62262. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62263. */
  62264. render(useCameraPostProcess?: boolean): void;
  62265. /**
  62266. * Update the list of dependant textures samplers in the shader.
  62267. */
  62268. updateTextures(): void;
  62269. /**
  62270. * Update the uniform values of the procedural texture in the shader.
  62271. */
  62272. updateShaderUniforms(): void;
  62273. /**
  62274. * Define if the texture animates or not.
  62275. */
  62276. get animate(): boolean;
  62277. set animate(value: boolean);
  62278. }
  62279. }
  62280. declare module BABYLON {
  62281. /** @hidden */
  62282. export var noisePixelShader: {
  62283. name: string;
  62284. shader: string;
  62285. };
  62286. }
  62287. declare module BABYLON {
  62288. /**
  62289. * Class used to generate noise procedural textures
  62290. */
  62291. export class NoiseProceduralTexture extends ProceduralTexture {
  62292. /** Gets or sets the start time (default is 0) */
  62293. time: number;
  62294. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62295. brightness: number;
  62296. /** Defines the number of octaves to process */
  62297. octaves: number;
  62298. /** Defines the level of persistence (0.8 by default) */
  62299. persistence: number;
  62300. /** Gets or sets animation speed factor (default is 1) */
  62301. animationSpeedFactor: number;
  62302. /**
  62303. * Creates a new NoiseProceduralTexture
  62304. * @param name defines the name fo the texture
  62305. * @param size defines the size of the texture (default is 256)
  62306. * @param scene defines the hosting scene
  62307. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62308. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62309. */
  62310. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62311. private _updateShaderUniforms;
  62312. protected _getDefines(): string;
  62313. /** Generate the current state of the procedural texture */
  62314. render(useCameraPostProcess?: boolean): void;
  62315. /**
  62316. * Serializes this noise procedural texture
  62317. * @returns a serialized noise procedural texture object
  62318. */
  62319. serialize(): any;
  62320. /**
  62321. * Clone the texture.
  62322. * @returns the cloned texture
  62323. */
  62324. clone(): NoiseProceduralTexture;
  62325. /**
  62326. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62327. * @param parsedTexture defines parsed texture data
  62328. * @param scene defines the current scene
  62329. * @param rootUrl defines the root URL containing noise procedural texture information
  62330. * @returns a parsed NoiseProceduralTexture
  62331. */
  62332. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Raw cube texture where the raw buffers are passed in
  62338. */
  62339. export class RawCubeTexture extends CubeTexture {
  62340. /**
  62341. * Creates a cube texture where the raw buffers are passed in.
  62342. * @param scene defines the scene the texture is attached to
  62343. * @param data defines the array of data to use to create each face
  62344. * @param size defines the size of the textures
  62345. * @param format defines the format of the data
  62346. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62347. * @param generateMipMaps defines if the engine should generate the mip levels
  62348. * @param invertY defines if data must be stored with Y axis inverted
  62349. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62350. * @param compression defines the compression used (null by default)
  62351. */
  62352. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62353. /**
  62354. * Updates the raw cube texture.
  62355. * @param data defines the data to store
  62356. * @param format defines the data format
  62357. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62358. * @param invertY defines if data must be stored with Y axis inverted
  62359. * @param compression defines the compression used (null by default)
  62360. * @param level defines which level of the texture to update
  62361. */
  62362. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62363. /**
  62364. * Updates a raw cube texture with RGBD encoded data.
  62365. * @param data defines the array of data [mipmap][face] to use to create each face
  62366. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62367. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62368. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62369. * @returns a promsie that resolves when the operation is complete
  62370. */
  62371. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62372. /**
  62373. * Clones the raw cube texture.
  62374. * @return a new cube texture
  62375. */
  62376. clone(): CubeTexture;
  62377. /** @hidden */
  62378. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62379. }
  62380. }
  62381. declare module BABYLON {
  62382. /**
  62383. * Class used to store 2D array textures containing user data
  62384. */
  62385. export class RawTexture2DArray extends Texture {
  62386. /** Gets or sets the texture format to use */
  62387. format: number;
  62388. /**
  62389. * Create a new RawTexture2DArray
  62390. * @param data defines the data of the texture
  62391. * @param width defines the width of the texture
  62392. * @param height defines the height of the texture
  62393. * @param depth defines the number of layers of the texture
  62394. * @param format defines the texture format to use
  62395. * @param scene defines the hosting scene
  62396. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62397. * @param invertY defines if texture must be stored with Y axis inverted
  62398. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62399. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62400. */
  62401. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62402. /** Gets or sets the texture format to use */
  62403. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62404. /**
  62405. * Update the texture with new data
  62406. * @param data defines the data to store in the texture
  62407. */
  62408. update(data: ArrayBufferView): void;
  62409. }
  62410. }
  62411. declare module BABYLON {
  62412. /**
  62413. * Class used to store 3D textures containing user data
  62414. */
  62415. export class RawTexture3D extends Texture {
  62416. /** Gets or sets the texture format to use */
  62417. format: number;
  62418. /**
  62419. * Create a new RawTexture3D
  62420. * @param data defines the data of the texture
  62421. * @param width defines the width of the texture
  62422. * @param height defines the height of the texture
  62423. * @param depth defines the depth of the texture
  62424. * @param format defines the texture format to use
  62425. * @param scene defines the hosting scene
  62426. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62427. * @param invertY defines if texture must be stored with Y axis inverted
  62428. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62430. */
  62431. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62432. /** Gets or sets the texture format to use */
  62433. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62434. /**
  62435. * Update the texture with new data
  62436. * @param data defines the data to store in the texture
  62437. */
  62438. update(data: ArrayBufferView): void;
  62439. }
  62440. }
  62441. declare module BABYLON {
  62442. /**
  62443. * Creates a refraction texture used by refraction channel of the standard material.
  62444. * It is like a mirror but to see through a material.
  62445. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62446. */
  62447. export class RefractionTexture extends RenderTargetTexture {
  62448. /**
  62449. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62450. * 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.
  62451. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62452. */
  62453. refractionPlane: Plane;
  62454. /**
  62455. * Define how deep under the surface we should see.
  62456. */
  62457. depth: number;
  62458. /**
  62459. * Creates a refraction texture used by refraction channel of the standard material.
  62460. * It is like a mirror but to see through a material.
  62461. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62462. * @param name Define the texture name
  62463. * @param size Define the size of the underlying texture
  62464. * @param scene Define the scene the refraction belongs to
  62465. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62466. */
  62467. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62468. /**
  62469. * Clone the refraction texture.
  62470. * @returns the cloned texture
  62471. */
  62472. clone(): RefractionTexture;
  62473. /**
  62474. * Serialize the texture to a JSON representation you could use in Parse later on
  62475. * @returns the serialized JSON representation
  62476. */
  62477. serialize(): any;
  62478. }
  62479. }
  62480. declare module BABYLON {
  62481. /**
  62482. * Block used to add support for vertex skinning (bones)
  62483. */
  62484. export class BonesBlock extends NodeMaterialBlock {
  62485. /**
  62486. * Creates a new BonesBlock
  62487. * @param name defines the block name
  62488. */
  62489. constructor(name: string);
  62490. /**
  62491. * Initialize the block and prepare the context for build
  62492. * @param state defines the state that will be used for the build
  62493. */
  62494. initialize(state: NodeMaterialBuildState): void;
  62495. /**
  62496. * Gets the current class name
  62497. * @returns the class name
  62498. */
  62499. getClassName(): string;
  62500. /**
  62501. * Gets the matrix indices input component
  62502. */
  62503. get matricesIndices(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the matrix weights input component
  62506. */
  62507. get matricesWeights(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the extra matrix indices input component
  62510. */
  62511. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the extra matrix weights input component
  62514. */
  62515. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the world input component
  62518. */
  62519. get world(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the output component
  62522. */
  62523. get output(): NodeMaterialConnectionPoint;
  62524. autoConfigure(material: NodeMaterial): void;
  62525. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62528. protected _buildBlock(state: NodeMaterialBuildState): this;
  62529. }
  62530. }
  62531. declare module BABYLON {
  62532. /**
  62533. * Block used to add support for instances
  62534. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62535. */
  62536. export class InstancesBlock extends NodeMaterialBlock {
  62537. /**
  62538. * Creates a new InstancesBlock
  62539. * @param name defines the block name
  62540. */
  62541. constructor(name: string);
  62542. /**
  62543. * Gets the current class name
  62544. * @returns the class name
  62545. */
  62546. getClassName(): string;
  62547. /**
  62548. * Gets the first world row input component
  62549. */
  62550. get world0(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the second world row input component
  62553. */
  62554. get world1(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the third world row input component
  62557. */
  62558. get world2(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the forth world row input component
  62561. */
  62562. get world3(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the world input component
  62565. */
  62566. get world(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the output component
  62569. */
  62570. get output(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the isntanceID component
  62573. */
  62574. get instanceID(): NodeMaterialConnectionPoint;
  62575. autoConfigure(material: NodeMaterial): void;
  62576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62577. protected _buildBlock(state: NodeMaterialBuildState): this;
  62578. }
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * Block used to add morph targets support to vertex shader
  62583. */
  62584. export class MorphTargetsBlock extends NodeMaterialBlock {
  62585. private _repeatableContentAnchor;
  62586. /**
  62587. * Create a new MorphTargetsBlock
  62588. * @param name defines the block name
  62589. */
  62590. constructor(name: string);
  62591. /**
  62592. * Gets the current class name
  62593. * @returns the class name
  62594. */
  62595. getClassName(): string;
  62596. /**
  62597. * Gets the position input component
  62598. */
  62599. get position(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the normal input component
  62602. */
  62603. get normal(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the tangent input component
  62606. */
  62607. get tangent(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the tangent input component
  62610. */
  62611. get uv(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the position output component
  62614. */
  62615. get positionOutput(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the normal output component
  62618. */
  62619. get normalOutput(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the tangent output component
  62622. */
  62623. get tangentOutput(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the tangent output component
  62626. */
  62627. get uvOutput(): NodeMaterialConnectionPoint;
  62628. initialize(state: NodeMaterialBuildState): void;
  62629. autoConfigure(material: NodeMaterial): void;
  62630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62632. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62633. protected _buildBlock(state: NodeMaterialBuildState): this;
  62634. }
  62635. }
  62636. declare module BABYLON {
  62637. /**
  62638. * Block used to get data information from a light
  62639. */
  62640. export class LightInformationBlock extends NodeMaterialBlock {
  62641. private _lightDataUniformName;
  62642. private _lightColorUniformName;
  62643. private _lightTypeDefineName;
  62644. /**
  62645. * Gets or sets the light associated with this block
  62646. */
  62647. light: Nullable<Light>;
  62648. /**
  62649. * Creates a new LightInformationBlock
  62650. * @param name defines the block name
  62651. */
  62652. constructor(name: string);
  62653. /**
  62654. * Gets the current class name
  62655. * @returns the class name
  62656. */
  62657. getClassName(): string;
  62658. /**
  62659. * Gets the world position input component
  62660. */
  62661. get worldPosition(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the direction output component
  62664. */
  62665. get direction(): NodeMaterialConnectionPoint;
  62666. /**
  62667. * Gets the direction output component
  62668. */
  62669. get color(): NodeMaterialConnectionPoint;
  62670. /**
  62671. * Gets the direction output component
  62672. */
  62673. get intensity(): NodeMaterialConnectionPoint;
  62674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62676. protected _buildBlock(state: NodeMaterialBuildState): this;
  62677. serialize(): any;
  62678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62679. }
  62680. }
  62681. declare module BABYLON {
  62682. /**
  62683. * Block used to add image processing support to fragment shader
  62684. */
  62685. export class ImageProcessingBlock extends NodeMaterialBlock {
  62686. /**
  62687. * Create a new ImageProcessingBlock
  62688. * @param name defines the block name
  62689. */
  62690. constructor(name: string);
  62691. /**
  62692. * Gets the current class name
  62693. * @returns the class name
  62694. */
  62695. getClassName(): string;
  62696. /**
  62697. * Gets the color input component
  62698. */
  62699. get color(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the output component
  62702. */
  62703. get output(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Initialize the block and prepare the context for build
  62706. * @param state defines the state that will be used for the build
  62707. */
  62708. initialize(state: NodeMaterialBuildState): void;
  62709. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62712. protected _buildBlock(state: NodeMaterialBuildState): this;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Block used to pertub normals based on a normal map
  62718. */
  62719. export class PerturbNormalBlock extends NodeMaterialBlock {
  62720. private _tangentSpaceParameterName;
  62721. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62722. invertX: boolean;
  62723. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62724. invertY: boolean;
  62725. /**
  62726. * Create a new PerturbNormalBlock
  62727. * @param name defines the block name
  62728. */
  62729. constructor(name: string);
  62730. /**
  62731. * Gets the current class name
  62732. * @returns the class name
  62733. */
  62734. getClassName(): string;
  62735. /**
  62736. * Gets the world position input component
  62737. */
  62738. get worldPosition(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the world normal input component
  62741. */
  62742. get worldNormal(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the world tangent input component
  62745. */
  62746. get worldTangent(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the uv input component
  62749. */
  62750. get uv(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the normal map color input component
  62753. */
  62754. get normalMapColor(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the strength input component
  62757. */
  62758. get strength(): NodeMaterialConnectionPoint;
  62759. /**
  62760. * Gets the output component
  62761. */
  62762. get output(): NodeMaterialConnectionPoint;
  62763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62765. autoConfigure(material: NodeMaterial): void;
  62766. protected _buildBlock(state: NodeMaterialBuildState): this;
  62767. protected _dumpPropertiesCode(): string;
  62768. serialize(): any;
  62769. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62770. }
  62771. }
  62772. declare module BABYLON {
  62773. /**
  62774. * Block used to discard a pixel if a value is smaller than a cutoff
  62775. */
  62776. export class DiscardBlock extends NodeMaterialBlock {
  62777. /**
  62778. * Create a new DiscardBlock
  62779. * @param name defines the block name
  62780. */
  62781. constructor(name: string);
  62782. /**
  62783. * Gets the current class name
  62784. * @returns the class name
  62785. */
  62786. getClassName(): string;
  62787. /**
  62788. * Gets the color input component
  62789. */
  62790. get value(): NodeMaterialConnectionPoint;
  62791. /**
  62792. * Gets the cutoff input component
  62793. */
  62794. get cutoff(): NodeMaterialConnectionPoint;
  62795. protected _buildBlock(state: NodeMaterialBuildState): this;
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * Block used to test if the fragment shader is front facing
  62801. */
  62802. export class FrontFacingBlock extends NodeMaterialBlock {
  62803. /**
  62804. * Creates a new FrontFacingBlock
  62805. * @param name defines the block name
  62806. */
  62807. constructor(name: string);
  62808. /**
  62809. * Gets the current class name
  62810. * @returns the class name
  62811. */
  62812. getClassName(): string;
  62813. /**
  62814. * Gets the output component
  62815. */
  62816. get output(): NodeMaterialConnectionPoint;
  62817. protected _buildBlock(state: NodeMaterialBuildState): this;
  62818. }
  62819. }
  62820. declare module BABYLON {
  62821. /**
  62822. * Block used to get the derivative value on x and y of a given input
  62823. */
  62824. export class DerivativeBlock extends NodeMaterialBlock {
  62825. /**
  62826. * Create a new DerivativeBlock
  62827. * @param name defines the block name
  62828. */
  62829. constructor(name: string);
  62830. /**
  62831. * Gets the current class name
  62832. * @returns the class name
  62833. */
  62834. getClassName(): string;
  62835. /**
  62836. * Gets the input component
  62837. */
  62838. get input(): NodeMaterialConnectionPoint;
  62839. /**
  62840. * Gets the derivative output on x
  62841. */
  62842. get dx(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the derivative output on y
  62845. */
  62846. get dy(): NodeMaterialConnectionPoint;
  62847. protected _buildBlock(state: NodeMaterialBuildState): this;
  62848. }
  62849. }
  62850. declare module BABYLON {
  62851. /**
  62852. * Block used to make gl_FragCoord available
  62853. */
  62854. export class FragCoordBlock extends NodeMaterialBlock {
  62855. /**
  62856. * Creates a new FragCoordBlock
  62857. * @param name defines the block name
  62858. */
  62859. constructor(name: string);
  62860. /**
  62861. * Gets the current class name
  62862. * @returns the class name
  62863. */
  62864. getClassName(): string;
  62865. /**
  62866. * Gets the xy component
  62867. */
  62868. get xy(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the xyz component
  62871. */
  62872. get xyz(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the xyzw component
  62875. */
  62876. get xyzw(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the x component
  62879. */
  62880. get x(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the y component
  62883. */
  62884. get y(): NodeMaterialConnectionPoint;
  62885. /**
  62886. * Gets the z component
  62887. */
  62888. get z(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the w component
  62891. */
  62892. get output(): NodeMaterialConnectionPoint;
  62893. protected writeOutputs(state: NodeMaterialBuildState): string;
  62894. protected _buildBlock(state: NodeMaterialBuildState): this;
  62895. }
  62896. }
  62897. declare module BABYLON {
  62898. /**
  62899. * Block used to get the screen sizes
  62900. */
  62901. export class ScreenSizeBlock extends NodeMaterialBlock {
  62902. private _varName;
  62903. private _scene;
  62904. /**
  62905. * Creates a new ScreenSizeBlock
  62906. * @param name defines the block name
  62907. */
  62908. constructor(name: string);
  62909. /**
  62910. * Gets the current class name
  62911. * @returns the class name
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Gets the xy component
  62916. */
  62917. get xy(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the x component
  62920. */
  62921. get x(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the y component
  62924. */
  62925. get y(): NodeMaterialConnectionPoint;
  62926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62927. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62928. protected _buildBlock(state: NodeMaterialBuildState): this;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Block used to add support for scene fog
  62934. */
  62935. export class FogBlock extends NodeMaterialBlock {
  62936. private _fogDistanceName;
  62937. private _fogParameters;
  62938. /**
  62939. * Create a new FogBlock
  62940. * @param name defines the block name
  62941. */
  62942. constructor(name: string);
  62943. /**
  62944. * Gets the current class name
  62945. * @returns the class name
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the world position input component
  62950. */
  62951. get worldPosition(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the view input component
  62954. */
  62955. get view(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the color input component
  62958. */
  62959. get input(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the fog color input component
  62962. */
  62963. get fogColor(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the output component
  62966. */
  62967. get output(): NodeMaterialConnectionPoint;
  62968. autoConfigure(material: NodeMaterial): void;
  62969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62970. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62971. protected _buildBlock(state: NodeMaterialBuildState): this;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Block used to add light in the fragment shader
  62977. */
  62978. export class LightBlock extends NodeMaterialBlock {
  62979. private _lightId;
  62980. /**
  62981. * Gets or sets the light associated with this block
  62982. */
  62983. light: Nullable<Light>;
  62984. /**
  62985. * Create a new LightBlock
  62986. * @param name defines the block name
  62987. */
  62988. constructor(name: string);
  62989. /**
  62990. * Gets the current class name
  62991. * @returns the class name
  62992. */
  62993. getClassName(): string;
  62994. /**
  62995. * Gets the world position input component
  62996. */
  62997. get worldPosition(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the world normal input component
  63000. */
  63001. get worldNormal(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the camera (or eye) position component
  63004. */
  63005. get cameraPosition(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the glossiness component
  63008. */
  63009. get glossiness(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the glossinness power component
  63012. */
  63013. get glossPower(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the diffuse color component
  63016. */
  63017. get diffuseColor(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the specular color component
  63020. */
  63021. get specularColor(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the diffuse output component
  63024. */
  63025. get diffuseOutput(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the specular output component
  63028. */
  63029. get specularOutput(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the shadow output component
  63032. */
  63033. get shadow(): NodeMaterialConnectionPoint;
  63034. autoConfigure(material: NodeMaterial): void;
  63035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63036. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63038. private _injectVertexCode;
  63039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63040. serialize(): any;
  63041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63042. }
  63043. }
  63044. declare module BABYLON {
  63045. /**
  63046. * Block used to read a reflection texture from a sampler
  63047. */
  63048. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63049. /**
  63050. * Create a new ReflectionTextureBlock
  63051. * @param name defines the block name
  63052. */
  63053. constructor(name: string);
  63054. /**
  63055. * Gets the current class name
  63056. * @returns the class name
  63057. */
  63058. getClassName(): string;
  63059. /**
  63060. * Gets the world position input component
  63061. */
  63062. get position(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the world position input component
  63065. */
  63066. get worldPosition(): NodeMaterialConnectionPoint;
  63067. /**
  63068. * Gets the world normal input component
  63069. */
  63070. get worldNormal(): NodeMaterialConnectionPoint;
  63071. /**
  63072. * Gets the world input component
  63073. */
  63074. get world(): NodeMaterialConnectionPoint;
  63075. /**
  63076. * Gets the camera (or eye) position component
  63077. */
  63078. get cameraPosition(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the view input component
  63081. */
  63082. get view(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the rgb output component
  63085. */
  63086. get rgb(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the rgba output component
  63089. */
  63090. get rgba(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the r output component
  63093. */
  63094. get r(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the g output component
  63097. */
  63098. get g(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the b output component
  63101. */
  63102. get b(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the a output component
  63105. */
  63106. get a(): NodeMaterialConnectionPoint;
  63107. autoConfigure(material: NodeMaterial): void;
  63108. protected _buildBlock(state: NodeMaterialBuildState): this;
  63109. }
  63110. }
  63111. declare module BABYLON {
  63112. /**
  63113. * Block used to add 2 vectors
  63114. */
  63115. export class AddBlock extends NodeMaterialBlock {
  63116. /**
  63117. * Creates a new AddBlock
  63118. * @param name defines the block name
  63119. */
  63120. constructor(name: string);
  63121. /**
  63122. * Gets the current class name
  63123. * @returns the class name
  63124. */
  63125. getClassName(): string;
  63126. /**
  63127. * Gets the left operand input component
  63128. */
  63129. get left(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the right operand input component
  63132. */
  63133. get right(): NodeMaterialConnectionPoint;
  63134. /**
  63135. * Gets the output component
  63136. */
  63137. get output(): NodeMaterialConnectionPoint;
  63138. protected _buildBlock(state: NodeMaterialBuildState): this;
  63139. }
  63140. }
  63141. declare module BABYLON {
  63142. /**
  63143. * Block used to scale a vector by a float
  63144. */
  63145. export class ScaleBlock extends NodeMaterialBlock {
  63146. /**
  63147. * Creates a new ScaleBlock
  63148. * @param name defines the block name
  63149. */
  63150. constructor(name: string);
  63151. /**
  63152. * Gets the current class name
  63153. * @returns the class name
  63154. */
  63155. getClassName(): string;
  63156. /**
  63157. * Gets the input component
  63158. */
  63159. get input(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the factor input component
  63162. */
  63163. get factor(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the output component
  63166. */
  63167. get output(): NodeMaterialConnectionPoint;
  63168. protected _buildBlock(state: NodeMaterialBuildState): this;
  63169. }
  63170. }
  63171. declare module BABYLON {
  63172. /**
  63173. * Block used to clamp a float
  63174. */
  63175. export class ClampBlock extends NodeMaterialBlock {
  63176. /** Gets or sets the minimum range */
  63177. minimum: number;
  63178. /** Gets or sets the maximum range */
  63179. maximum: number;
  63180. /**
  63181. * Creates a new ClampBlock
  63182. * @param name defines the block name
  63183. */
  63184. constructor(name: string);
  63185. /**
  63186. * Gets the current class name
  63187. * @returns the class name
  63188. */
  63189. getClassName(): string;
  63190. /**
  63191. * Gets the value input component
  63192. */
  63193. get value(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the output component
  63196. */
  63197. get output(): NodeMaterialConnectionPoint;
  63198. protected _buildBlock(state: NodeMaterialBuildState): this;
  63199. protected _dumpPropertiesCode(): string;
  63200. serialize(): any;
  63201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to apply a cross product between 2 vectors
  63207. */
  63208. export class CrossBlock extends NodeMaterialBlock {
  63209. /**
  63210. * Creates a new CrossBlock
  63211. * @param name defines the block name
  63212. */
  63213. constructor(name: string);
  63214. /**
  63215. * Gets the current class name
  63216. * @returns the class name
  63217. */
  63218. getClassName(): string;
  63219. /**
  63220. * Gets the left operand input component
  63221. */
  63222. get left(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the right operand input component
  63225. */
  63226. get right(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the output component
  63229. */
  63230. get output(): NodeMaterialConnectionPoint;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Block used to apply a dot product between 2 vectors
  63237. */
  63238. export class DotBlock extends NodeMaterialBlock {
  63239. /**
  63240. * Creates a new DotBlock
  63241. * @param name defines the block name
  63242. */
  63243. constructor(name: string);
  63244. /**
  63245. * Gets the current class name
  63246. * @returns the class name
  63247. */
  63248. getClassName(): string;
  63249. /**
  63250. * Gets the left operand input component
  63251. */
  63252. get left(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the right operand input component
  63255. */
  63256. get right(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the output component
  63259. */
  63260. get output(): NodeMaterialConnectionPoint;
  63261. protected _buildBlock(state: NodeMaterialBuildState): this;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /**
  63266. * Block used to normalize a vector
  63267. */
  63268. export class NormalizeBlock extends NodeMaterialBlock {
  63269. /**
  63270. * Creates a new NormalizeBlock
  63271. * @param name defines the block name
  63272. */
  63273. constructor(name: string);
  63274. /**
  63275. * Gets the current class name
  63276. * @returns the class name
  63277. */
  63278. getClassName(): string;
  63279. /**
  63280. * Gets the input component
  63281. */
  63282. get input(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the output component
  63285. */
  63286. get output(): NodeMaterialConnectionPoint;
  63287. protected _buildBlock(state: NodeMaterialBuildState): this;
  63288. }
  63289. }
  63290. declare module BABYLON {
  63291. /**
  63292. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63293. */
  63294. export class ColorMergerBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Create a new ColorMergerBlock
  63297. * @param name defines the block name
  63298. */
  63299. constructor(name: string);
  63300. /**
  63301. * Gets the current class name
  63302. * @returns the class name
  63303. */
  63304. getClassName(): string;
  63305. /**
  63306. * Gets the rgb component (input)
  63307. */
  63308. get rgbIn(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the r component (input)
  63311. */
  63312. get r(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the g component (input)
  63315. */
  63316. get g(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the b component (input)
  63319. */
  63320. get b(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the a component (input)
  63323. */
  63324. get a(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the rgba component (output)
  63327. */
  63328. get rgba(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the rgb component (output)
  63331. */
  63332. get rgbOut(): NodeMaterialConnectionPoint;
  63333. /**
  63334. * Gets the rgb component (output)
  63335. * @deprecated Please use rgbOut instead.
  63336. */
  63337. get rgb(): NodeMaterialConnectionPoint;
  63338. protected _buildBlock(state: NodeMaterialBuildState): this;
  63339. }
  63340. }
  63341. declare module BABYLON {
  63342. /**
  63343. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63344. */
  63345. export class VectorSplitterBlock extends NodeMaterialBlock {
  63346. /**
  63347. * Create a new VectorSplitterBlock
  63348. * @param name defines the block name
  63349. */
  63350. constructor(name: string);
  63351. /**
  63352. * Gets the current class name
  63353. * @returns the class name
  63354. */
  63355. getClassName(): string;
  63356. /**
  63357. * Gets the xyzw component (input)
  63358. */
  63359. get xyzw(): NodeMaterialConnectionPoint;
  63360. /**
  63361. * Gets the xyz component (input)
  63362. */
  63363. get xyzIn(): NodeMaterialConnectionPoint;
  63364. /**
  63365. * Gets the xy component (input)
  63366. */
  63367. get xyIn(): NodeMaterialConnectionPoint;
  63368. /**
  63369. * Gets the xyz component (output)
  63370. */
  63371. get xyzOut(): NodeMaterialConnectionPoint;
  63372. /**
  63373. * Gets the xy component (output)
  63374. */
  63375. get xyOut(): NodeMaterialConnectionPoint;
  63376. /**
  63377. * Gets the x component (output)
  63378. */
  63379. get x(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the y component (output)
  63382. */
  63383. get y(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the z component (output)
  63386. */
  63387. get z(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the w component (output)
  63390. */
  63391. get w(): NodeMaterialConnectionPoint;
  63392. protected _inputRename(name: string): string;
  63393. protected _outputRename(name: string): string;
  63394. protected _buildBlock(state: NodeMaterialBuildState): this;
  63395. }
  63396. }
  63397. declare module BABYLON {
  63398. /**
  63399. * Block used to lerp between 2 values
  63400. */
  63401. export class LerpBlock extends NodeMaterialBlock {
  63402. /**
  63403. * Creates a new LerpBlock
  63404. * @param name defines the block name
  63405. */
  63406. constructor(name: string);
  63407. /**
  63408. * Gets the current class name
  63409. * @returns the class name
  63410. */
  63411. getClassName(): string;
  63412. /**
  63413. * Gets the left operand input component
  63414. */
  63415. get left(): NodeMaterialConnectionPoint;
  63416. /**
  63417. * Gets the right operand input component
  63418. */
  63419. get right(): NodeMaterialConnectionPoint;
  63420. /**
  63421. * Gets the gradient operand input component
  63422. */
  63423. get gradient(): NodeMaterialConnectionPoint;
  63424. /**
  63425. * Gets the output component
  63426. */
  63427. get output(): NodeMaterialConnectionPoint;
  63428. protected _buildBlock(state: NodeMaterialBuildState): this;
  63429. }
  63430. }
  63431. declare module BABYLON {
  63432. /**
  63433. * Block used to divide 2 vectors
  63434. */
  63435. export class DivideBlock extends NodeMaterialBlock {
  63436. /**
  63437. * Creates a new DivideBlock
  63438. * @param name defines the block name
  63439. */
  63440. constructor(name: string);
  63441. /**
  63442. * Gets the current class name
  63443. * @returns the class name
  63444. */
  63445. getClassName(): string;
  63446. /**
  63447. * Gets the left operand input component
  63448. */
  63449. get left(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the right operand input component
  63452. */
  63453. get right(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the output component
  63456. */
  63457. get output(): NodeMaterialConnectionPoint;
  63458. protected _buildBlock(state: NodeMaterialBuildState): this;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * Block used to subtract 2 vectors
  63464. */
  63465. export class SubtractBlock extends NodeMaterialBlock {
  63466. /**
  63467. * Creates a new SubtractBlock
  63468. * @param name defines the block name
  63469. */
  63470. constructor(name: string);
  63471. /**
  63472. * Gets the current class name
  63473. * @returns the class name
  63474. */
  63475. getClassName(): string;
  63476. /**
  63477. * Gets the left operand input component
  63478. */
  63479. get left(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the right operand input component
  63482. */
  63483. get right(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the output component
  63486. */
  63487. get output(): NodeMaterialConnectionPoint;
  63488. protected _buildBlock(state: NodeMaterialBuildState): this;
  63489. }
  63490. }
  63491. declare module BABYLON {
  63492. /**
  63493. * Block used to step a value
  63494. */
  63495. export class StepBlock extends NodeMaterialBlock {
  63496. /**
  63497. * Creates a new StepBlock
  63498. * @param name defines the block name
  63499. */
  63500. constructor(name: string);
  63501. /**
  63502. * Gets the current class name
  63503. * @returns the class name
  63504. */
  63505. getClassName(): string;
  63506. /**
  63507. * Gets the value operand input component
  63508. */
  63509. get value(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the edge operand input component
  63512. */
  63513. get edge(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the output component
  63516. */
  63517. get output(): NodeMaterialConnectionPoint;
  63518. protected _buildBlock(state: NodeMaterialBuildState): this;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * Block used to get the opposite (1 - x) of a value
  63524. */
  63525. export class OneMinusBlock extends NodeMaterialBlock {
  63526. /**
  63527. * Creates a new OneMinusBlock
  63528. * @param name defines the block name
  63529. */
  63530. constructor(name: string);
  63531. /**
  63532. * Gets the current class name
  63533. * @returns the class name
  63534. */
  63535. getClassName(): string;
  63536. /**
  63537. * Gets the input component
  63538. */
  63539. get input(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the output component
  63542. */
  63543. get output(): NodeMaterialConnectionPoint;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this;
  63545. }
  63546. }
  63547. declare module BABYLON {
  63548. /**
  63549. * Block used to get the view direction
  63550. */
  63551. export class ViewDirectionBlock extends NodeMaterialBlock {
  63552. /**
  63553. * Creates a new ViewDirectionBlock
  63554. * @param name defines the block name
  63555. */
  63556. constructor(name: string);
  63557. /**
  63558. * Gets the current class name
  63559. * @returns the class name
  63560. */
  63561. getClassName(): string;
  63562. /**
  63563. * Gets the world position component
  63564. */
  63565. get worldPosition(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the camera position component
  63568. */
  63569. get cameraPosition(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the output component
  63572. */
  63573. get output(): NodeMaterialConnectionPoint;
  63574. autoConfigure(material: NodeMaterial): void;
  63575. protected _buildBlock(state: NodeMaterialBuildState): this;
  63576. }
  63577. }
  63578. declare module BABYLON {
  63579. /**
  63580. * Block used to compute fresnel value
  63581. */
  63582. export class FresnelBlock extends NodeMaterialBlock {
  63583. /**
  63584. * Create a new FresnelBlock
  63585. * @param name defines the block name
  63586. */
  63587. constructor(name: string);
  63588. /**
  63589. * Gets the current class name
  63590. * @returns the class name
  63591. */
  63592. getClassName(): string;
  63593. /**
  63594. * Gets the world normal input component
  63595. */
  63596. get worldNormal(): NodeMaterialConnectionPoint;
  63597. /**
  63598. * Gets the view direction input component
  63599. */
  63600. get viewDirection(): NodeMaterialConnectionPoint;
  63601. /**
  63602. * Gets the bias input component
  63603. */
  63604. get bias(): NodeMaterialConnectionPoint;
  63605. /**
  63606. * Gets the camera (or eye) position component
  63607. */
  63608. get power(): NodeMaterialConnectionPoint;
  63609. /**
  63610. * Gets the fresnel output component
  63611. */
  63612. get fresnel(): NodeMaterialConnectionPoint;
  63613. autoConfigure(material: NodeMaterial): void;
  63614. protected _buildBlock(state: NodeMaterialBuildState): this;
  63615. }
  63616. }
  63617. declare module BABYLON {
  63618. /**
  63619. * Block used to get the max of 2 values
  63620. */
  63621. export class MaxBlock extends NodeMaterialBlock {
  63622. /**
  63623. * Creates a new MaxBlock
  63624. * @param name defines the block name
  63625. */
  63626. constructor(name: string);
  63627. /**
  63628. * Gets the current class name
  63629. * @returns the class name
  63630. */
  63631. getClassName(): string;
  63632. /**
  63633. * Gets the left operand input component
  63634. */
  63635. get left(): NodeMaterialConnectionPoint;
  63636. /**
  63637. * Gets the right operand input component
  63638. */
  63639. get right(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the output component
  63642. */
  63643. get output(): NodeMaterialConnectionPoint;
  63644. protected _buildBlock(state: NodeMaterialBuildState): this;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. /**
  63649. * Block used to get the min of 2 values
  63650. */
  63651. export class MinBlock extends NodeMaterialBlock {
  63652. /**
  63653. * Creates a new MinBlock
  63654. * @param name defines the block name
  63655. */
  63656. constructor(name: string);
  63657. /**
  63658. * Gets the current class name
  63659. * @returns the class name
  63660. */
  63661. getClassName(): string;
  63662. /**
  63663. * Gets the left operand input component
  63664. */
  63665. get left(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the right operand input component
  63668. */
  63669. get right(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the output component
  63672. */
  63673. get output(): NodeMaterialConnectionPoint;
  63674. protected _buildBlock(state: NodeMaterialBuildState): this;
  63675. }
  63676. }
  63677. declare module BABYLON {
  63678. /**
  63679. * Block used to get the distance between 2 values
  63680. */
  63681. export class DistanceBlock extends NodeMaterialBlock {
  63682. /**
  63683. * Creates a new DistanceBlock
  63684. * @param name defines the block name
  63685. */
  63686. constructor(name: string);
  63687. /**
  63688. * Gets the current class name
  63689. * @returns the class name
  63690. */
  63691. getClassName(): string;
  63692. /**
  63693. * Gets the left operand input component
  63694. */
  63695. get left(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the right operand input component
  63698. */
  63699. get right(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the output component
  63702. */
  63703. get output(): NodeMaterialConnectionPoint;
  63704. protected _buildBlock(state: NodeMaterialBuildState): this;
  63705. }
  63706. }
  63707. declare module BABYLON {
  63708. /**
  63709. * Block used to get the length of a vector
  63710. */
  63711. export class LengthBlock extends NodeMaterialBlock {
  63712. /**
  63713. * Creates a new LengthBlock
  63714. * @param name defines the block name
  63715. */
  63716. constructor(name: string);
  63717. /**
  63718. * Gets the current class name
  63719. * @returns the class name
  63720. */
  63721. getClassName(): string;
  63722. /**
  63723. * Gets the value input component
  63724. */
  63725. get value(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the output component
  63728. */
  63729. get output(): NodeMaterialConnectionPoint;
  63730. protected _buildBlock(state: NodeMaterialBuildState): this;
  63731. }
  63732. }
  63733. declare module BABYLON {
  63734. /**
  63735. * Block used to get negative version of a value (i.e. x * -1)
  63736. */
  63737. export class NegateBlock extends NodeMaterialBlock {
  63738. /**
  63739. * Creates a new NegateBlock
  63740. * @param name defines the block name
  63741. */
  63742. constructor(name: string);
  63743. /**
  63744. * Gets the current class name
  63745. * @returns the class name
  63746. */
  63747. getClassName(): string;
  63748. /**
  63749. * Gets the value input component
  63750. */
  63751. get value(): NodeMaterialConnectionPoint;
  63752. /**
  63753. * Gets the output component
  63754. */
  63755. get output(): NodeMaterialConnectionPoint;
  63756. protected _buildBlock(state: NodeMaterialBuildState): this;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. /**
  63761. * Block used to get the value of the first parameter raised to the power of the second
  63762. */
  63763. export class PowBlock extends NodeMaterialBlock {
  63764. /**
  63765. * Creates a new PowBlock
  63766. * @param name defines the block name
  63767. */
  63768. constructor(name: string);
  63769. /**
  63770. * Gets the current class name
  63771. * @returns the class name
  63772. */
  63773. getClassName(): string;
  63774. /**
  63775. * Gets the value operand input component
  63776. */
  63777. get value(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the power operand input component
  63780. */
  63781. get power(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the output component
  63784. */
  63785. get output(): NodeMaterialConnectionPoint;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /**
  63791. * Block used to get a random number
  63792. */
  63793. export class RandomNumberBlock extends NodeMaterialBlock {
  63794. /**
  63795. * Creates a new RandomNumberBlock
  63796. * @param name defines the block name
  63797. */
  63798. constructor(name: string);
  63799. /**
  63800. * Gets the current class name
  63801. * @returns the class name
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Gets the seed input component
  63806. */
  63807. get seed(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the output component
  63810. */
  63811. get output(): NodeMaterialConnectionPoint;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Block used to compute arc tangent of 2 values
  63818. */
  63819. export class ArcTan2Block extends NodeMaterialBlock {
  63820. /**
  63821. * Creates a new ArcTan2Block
  63822. * @param name defines the block name
  63823. */
  63824. constructor(name: string);
  63825. /**
  63826. * Gets the current class name
  63827. * @returns the class name
  63828. */
  63829. getClassName(): string;
  63830. /**
  63831. * Gets the x operand input component
  63832. */
  63833. get x(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Gets the y operand input component
  63836. */
  63837. get y(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the output component
  63840. */
  63841. get output(): NodeMaterialConnectionPoint;
  63842. protected _buildBlock(state: NodeMaterialBuildState): this;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Block used to smooth step a value
  63848. */
  63849. export class SmoothStepBlock extends NodeMaterialBlock {
  63850. /**
  63851. * Creates a new SmoothStepBlock
  63852. * @param name defines the block name
  63853. */
  63854. constructor(name: string);
  63855. /**
  63856. * Gets the current class name
  63857. * @returns the class name
  63858. */
  63859. getClassName(): string;
  63860. /**
  63861. * Gets the value operand input component
  63862. */
  63863. get value(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the first edge operand input component
  63866. */
  63867. get edge0(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the second edge operand input component
  63870. */
  63871. get edge1(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the output component
  63874. */
  63875. get output(): NodeMaterialConnectionPoint;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to get the reciprocal (1 / x) of a value
  63882. */
  63883. export class ReciprocalBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Creates a new ReciprocalBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * Gets the current class name
  63891. * @returns the class name
  63892. */
  63893. getClassName(): string;
  63894. /**
  63895. * Gets the input component
  63896. */
  63897. get input(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the output component
  63900. */
  63901. get output(): NodeMaterialConnectionPoint;
  63902. protected _buildBlock(state: NodeMaterialBuildState): this;
  63903. }
  63904. }
  63905. declare module BABYLON {
  63906. /**
  63907. * Block used to replace a color by another one
  63908. */
  63909. export class ReplaceColorBlock extends NodeMaterialBlock {
  63910. /**
  63911. * Creates a new ReplaceColorBlock
  63912. * @param name defines the block name
  63913. */
  63914. constructor(name: string);
  63915. /**
  63916. * Gets the current class name
  63917. * @returns the class name
  63918. */
  63919. getClassName(): string;
  63920. /**
  63921. * Gets the value input component
  63922. */
  63923. get value(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the reference input component
  63926. */
  63927. get reference(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the distance input component
  63930. */
  63931. get distance(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the replacement input component
  63934. */
  63935. get replacement(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the output component
  63938. */
  63939. get output(): NodeMaterialConnectionPoint;
  63940. protected _buildBlock(state: NodeMaterialBuildState): this;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * Block used to posterize a value
  63946. * @see https://en.wikipedia.org/wiki/Posterization
  63947. */
  63948. export class PosterizeBlock extends NodeMaterialBlock {
  63949. /**
  63950. * Creates a new PosterizeBlock
  63951. * @param name defines the block name
  63952. */
  63953. constructor(name: string);
  63954. /**
  63955. * Gets the current class name
  63956. * @returns the class name
  63957. */
  63958. getClassName(): string;
  63959. /**
  63960. * Gets the value input component
  63961. */
  63962. get value(): NodeMaterialConnectionPoint;
  63963. /**
  63964. * Gets the steps input component
  63965. */
  63966. get steps(): NodeMaterialConnectionPoint;
  63967. /**
  63968. * Gets the output component
  63969. */
  63970. get output(): NodeMaterialConnectionPoint;
  63971. protected _buildBlock(state: NodeMaterialBuildState): this;
  63972. }
  63973. }
  63974. declare module BABYLON {
  63975. /**
  63976. * Operations supported by the Wave block
  63977. */
  63978. export enum WaveBlockKind {
  63979. /** SawTooth */
  63980. SawTooth = 0,
  63981. /** Square */
  63982. Square = 1,
  63983. /** Triangle */
  63984. Triangle = 2
  63985. }
  63986. /**
  63987. * Block used to apply wave operation to floats
  63988. */
  63989. export class WaveBlock extends NodeMaterialBlock {
  63990. /**
  63991. * Gets or sets the kibnd of wave to be applied by the block
  63992. */
  63993. kind: WaveBlockKind;
  63994. /**
  63995. * Creates a new WaveBlock
  63996. * @param name defines the block name
  63997. */
  63998. constructor(name: string);
  63999. /**
  64000. * Gets the current class name
  64001. * @returns the class name
  64002. */
  64003. getClassName(): string;
  64004. /**
  64005. * Gets the input component
  64006. */
  64007. get input(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the output component
  64010. */
  64011. get output(): NodeMaterialConnectionPoint;
  64012. protected _buildBlock(state: NodeMaterialBuildState): this;
  64013. serialize(): any;
  64014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /**
  64019. * Class used to store a color step for the GradientBlock
  64020. */
  64021. export class GradientBlockColorStep {
  64022. private _step;
  64023. /**
  64024. * Gets value indicating which step this color is associated with (between 0 and 1)
  64025. */
  64026. get step(): number;
  64027. /**
  64028. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64029. */
  64030. set step(val: number);
  64031. private _color;
  64032. /**
  64033. * Gets the color associated with this step
  64034. */
  64035. get color(): Color3;
  64036. /**
  64037. * Sets the color associated with this step
  64038. */
  64039. set color(val: Color3);
  64040. /**
  64041. * Creates a new GradientBlockColorStep
  64042. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64043. * @param color defines the color associated with this step
  64044. */
  64045. constructor(step: number, color: Color3);
  64046. }
  64047. /**
  64048. * Block used to return a color from a gradient based on an input value between 0 and 1
  64049. */
  64050. export class GradientBlock extends NodeMaterialBlock {
  64051. /**
  64052. * Gets or sets the list of color steps
  64053. */
  64054. colorSteps: GradientBlockColorStep[];
  64055. /** Gets an observable raised when the value is changed */
  64056. onValueChangedObservable: Observable<GradientBlock>;
  64057. /** calls observable when the value is changed*/
  64058. colorStepsUpdated(): void;
  64059. /**
  64060. * Creates a new GradientBlock
  64061. * @param name defines the block name
  64062. */
  64063. constructor(name: string);
  64064. /**
  64065. * Gets the current class name
  64066. * @returns the class name
  64067. */
  64068. getClassName(): string;
  64069. /**
  64070. * Gets the gradient input component
  64071. */
  64072. get gradient(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the output component
  64075. */
  64076. get output(): NodeMaterialConnectionPoint;
  64077. private _writeColorConstant;
  64078. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64079. serialize(): any;
  64080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64081. protected _dumpPropertiesCode(): string;
  64082. }
  64083. }
  64084. declare module BABYLON {
  64085. /**
  64086. * Block used to normalize lerp between 2 values
  64087. */
  64088. export class NLerpBlock extends NodeMaterialBlock {
  64089. /**
  64090. * Creates a new NLerpBlock
  64091. * @param name defines the block name
  64092. */
  64093. constructor(name: string);
  64094. /**
  64095. * Gets the current class name
  64096. * @returns the class name
  64097. */
  64098. getClassName(): string;
  64099. /**
  64100. * Gets the left operand input component
  64101. */
  64102. get left(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the right operand input component
  64105. */
  64106. get right(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the gradient operand input component
  64109. */
  64110. get gradient(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the output component
  64113. */
  64114. get output(): NodeMaterialConnectionPoint;
  64115. protected _buildBlock(state: NodeMaterialBuildState): this;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * block used to Generate a Worley Noise 3D Noise Pattern
  64121. */
  64122. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64123. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64124. manhattanDistance: boolean;
  64125. /**
  64126. * Creates a new WorleyNoise3DBlock
  64127. * @param name defines the block name
  64128. */
  64129. constructor(name: string);
  64130. /**
  64131. * Gets the current class name
  64132. * @returns the class name
  64133. */
  64134. getClassName(): string;
  64135. /**
  64136. * Gets the seed input component
  64137. */
  64138. get seed(): NodeMaterialConnectionPoint;
  64139. /**
  64140. * Gets the jitter input component
  64141. */
  64142. get jitter(): NodeMaterialConnectionPoint;
  64143. /**
  64144. * Gets the output component
  64145. */
  64146. get output(): NodeMaterialConnectionPoint;
  64147. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64148. /**
  64149. * Exposes the properties to the UI?
  64150. */
  64151. protected _dumpPropertiesCode(): string;
  64152. /**
  64153. * Exposes the properties to the Seralize?
  64154. */
  64155. serialize(): any;
  64156. /**
  64157. * Exposes the properties to the deseralize?
  64158. */
  64159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64165. */
  64166. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64167. /**
  64168. * Creates a new SimplexPerlin3DBlock
  64169. * @param name defines the block name
  64170. */
  64171. constructor(name: string);
  64172. /**
  64173. * Gets the current class name
  64174. * @returns the class name
  64175. */
  64176. getClassName(): string;
  64177. /**
  64178. * Gets the seed operand input component
  64179. */
  64180. get seed(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the output component
  64183. */
  64184. get output(): NodeMaterialConnectionPoint;
  64185. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64186. }
  64187. }
  64188. declare module BABYLON {
  64189. /**
  64190. * Block used to blend normals
  64191. */
  64192. export class NormalBlendBlock extends NodeMaterialBlock {
  64193. /**
  64194. * Creates a new NormalBlendBlock
  64195. * @param name defines the block name
  64196. */
  64197. constructor(name: string);
  64198. /**
  64199. * Gets the current class name
  64200. * @returns the class name
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Gets the first input component
  64205. */
  64206. get normalMap0(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the second input component
  64209. */
  64210. get normalMap1(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /**
  64220. * Block used to rotate a 2d vector by a given angle
  64221. */
  64222. export class Rotate2dBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Creates a new Rotate2dBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the input vector
  64235. */
  64236. get input(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the input angle
  64239. */
  64240. get angle(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the output component
  64243. */
  64244. get output(): NodeMaterialConnectionPoint;
  64245. autoConfigure(material: NodeMaterial): void;
  64246. protected _buildBlock(state: NodeMaterialBuildState): this;
  64247. }
  64248. }
  64249. declare module BABYLON {
  64250. /**
  64251. * Block used to get the reflected vector from a direction and a normal
  64252. */
  64253. export class ReflectBlock extends NodeMaterialBlock {
  64254. /**
  64255. * Creates a new ReflectBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the incident component
  64266. */
  64267. get incident(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the normal component
  64270. */
  64271. get normal(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the output component
  64274. */
  64275. get output(): NodeMaterialConnectionPoint;
  64276. protected _buildBlock(state: NodeMaterialBuildState): this;
  64277. }
  64278. }
  64279. declare module BABYLON {
  64280. /**
  64281. * Block used to get the refracted vector from a direction and a normal
  64282. */
  64283. export class RefractBlock extends NodeMaterialBlock {
  64284. /**
  64285. * Creates a new RefractBlock
  64286. * @param name defines the block name
  64287. */
  64288. constructor(name: string);
  64289. /**
  64290. * Gets the current class name
  64291. * @returns the class name
  64292. */
  64293. getClassName(): string;
  64294. /**
  64295. * Gets the incident component
  64296. */
  64297. get incident(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the normal component
  64300. */
  64301. get normal(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the index of refraction component
  64304. */
  64305. get ior(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the output component
  64308. */
  64309. get output(): NodeMaterialConnectionPoint;
  64310. protected _buildBlock(state: NodeMaterialBuildState): this;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Block used to desaturate a color
  64316. */
  64317. export class DesaturateBlock extends NodeMaterialBlock {
  64318. /**
  64319. * Creates a new DesaturateBlock
  64320. * @param name defines the block name
  64321. */
  64322. constructor(name: string);
  64323. /**
  64324. * Gets the current class name
  64325. * @returns the class name
  64326. */
  64327. getClassName(): string;
  64328. /**
  64329. * Gets the color operand input component
  64330. */
  64331. get color(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the level operand input component
  64334. */
  64335. get level(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the output component
  64338. */
  64339. get output(): NodeMaterialConnectionPoint;
  64340. protected _buildBlock(state: NodeMaterialBuildState): this;
  64341. }
  64342. }
  64343. declare module BABYLON {
  64344. /**
  64345. * Block used to implement the ambient occlusion module of the PBR material
  64346. */
  64347. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64348. /**
  64349. * Create a new AmbientOcclusionBlock
  64350. * @param name defines the block name
  64351. */
  64352. constructor(name: string);
  64353. /**
  64354. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64355. */
  64356. useAmbientInGrayScale: boolean;
  64357. /**
  64358. * Initialize the block and prepare the context for build
  64359. * @param state defines the state that will be used for the build
  64360. */
  64361. initialize(state: NodeMaterialBuildState): void;
  64362. /**
  64363. * Gets the current class name
  64364. * @returns the class name
  64365. */
  64366. getClassName(): string;
  64367. /**
  64368. * Gets the texture input component
  64369. */
  64370. get texture(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the texture intensity component
  64373. */
  64374. get intensity(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the direct light intensity input component
  64377. */
  64378. get directLightIntensity(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the ambient occlusion object output component
  64381. */
  64382. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64383. /**
  64384. * Gets the main code of the block (fragment side)
  64385. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64386. * @returns the shader code
  64387. */
  64388. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64390. protected _buildBlock(state: NodeMaterialBuildState): this;
  64391. protected _dumpPropertiesCode(): string;
  64392. serialize(): any;
  64393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64394. }
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * Block used to implement the reflection module of the PBR material
  64399. */
  64400. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64401. /** @hidden */
  64402. _defineLODReflectionAlpha: string;
  64403. /** @hidden */
  64404. _defineLinearSpecularReflection: string;
  64405. private _vEnvironmentIrradianceName;
  64406. /** @hidden */
  64407. _vReflectionMicrosurfaceInfosName: string;
  64408. /** @hidden */
  64409. _vReflectionInfosName: string;
  64410. /** @hidden */
  64411. _vReflectionFilteringInfoName: string;
  64412. private _scene;
  64413. /**
  64414. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64415. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64416. * It's less burden on the user side in the editor part.
  64417. */
  64418. /** @hidden */
  64419. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64420. /** @hidden */
  64421. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64422. /** @hidden */
  64423. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64424. /**
  64425. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64426. * diffuse part of the IBL.
  64427. */
  64428. useSphericalHarmonics: boolean;
  64429. /**
  64430. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64431. */
  64432. forceIrradianceInFragment: boolean;
  64433. /**
  64434. * Create a new ReflectionBlock
  64435. * @param name defines the block name
  64436. */
  64437. constructor(name: string);
  64438. /**
  64439. * Gets the current class name
  64440. * @returns the class name
  64441. */
  64442. getClassName(): string;
  64443. /**
  64444. * Gets the position input component
  64445. */
  64446. get position(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the world position input component
  64449. */
  64450. get worldPosition(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the world normal input component
  64453. */
  64454. get worldNormal(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the world input component
  64457. */
  64458. get world(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the camera (or eye) position component
  64461. */
  64462. get cameraPosition(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the view input component
  64465. */
  64466. get view(): NodeMaterialConnectionPoint;
  64467. /**
  64468. * Gets the color input component
  64469. */
  64470. get color(): NodeMaterialConnectionPoint;
  64471. /**
  64472. * Gets the reflection object output component
  64473. */
  64474. get reflection(): NodeMaterialConnectionPoint;
  64475. /**
  64476. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64477. */
  64478. get hasTexture(): boolean;
  64479. /**
  64480. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64481. */
  64482. get reflectionColor(): string;
  64483. protected _getTexture(): Nullable<BaseTexture>;
  64484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64486. /**
  64487. * Gets the code to inject in the vertex shader
  64488. * @param state current state of the node material building
  64489. * @returns the shader code
  64490. */
  64491. handleVertexSide(state: NodeMaterialBuildState): string;
  64492. /**
  64493. * Gets the main code of the block (fragment side)
  64494. * @param state current state of the node material building
  64495. * @param normalVarName name of the existing variable corresponding to the normal
  64496. * @returns the shader code
  64497. */
  64498. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64499. protected _buildBlock(state: NodeMaterialBuildState): this;
  64500. protected _dumpPropertiesCode(): string;
  64501. serialize(): any;
  64502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /**
  64507. * Block used to implement the sheen module of the PBR material
  64508. */
  64509. export class SheenBlock extends NodeMaterialBlock {
  64510. /**
  64511. * Create a new SheenBlock
  64512. * @param name defines the block name
  64513. */
  64514. constructor(name: string);
  64515. /**
  64516. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64517. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64518. * making it easier to setup and tweak the effect
  64519. */
  64520. albedoScaling: boolean;
  64521. /**
  64522. * Defines if the sheen is linked to the sheen color.
  64523. */
  64524. linkSheenWithAlbedo: boolean;
  64525. /**
  64526. * Initialize the block and prepare the context for build
  64527. * @param state defines the state that will be used for the build
  64528. */
  64529. initialize(state: NodeMaterialBuildState): void;
  64530. /**
  64531. * Gets the current class name
  64532. * @returns the class name
  64533. */
  64534. getClassName(): string;
  64535. /**
  64536. * Gets the intensity input component
  64537. */
  64538. get intensity(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the color input component
  64541. */
  64542. get color(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the roughness input component
  64545. */
  64546. get roughness(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the sheen object output component
  64549. */
  64550. get sheen(): NodeMaterialConnectionPoint;
  64551. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64552. /**
  64553. * Gets the main code of the block (fragment side)
  64554. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64555. * @returns the shader code
  64556. */
  64557. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64558. protected _buildBlock(state: NodeMaterialBuildState): this;
  64559. protected _dumpPropertiesCode(): string;
  64560. serialize(): any;
  64561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64562. }
  64563. }
  64564. declare module BABYLON {
  64565. /**
  64566. * Block used to implement the reflectivity module of the PBR material
  64567. */
  64568. export class ReflectivityBlock extends NodeMaterialBlock {
  64569. private _metallicReflectanceColor;
  64570. private _metallicF0Factor;
  64571. /** @hidden */
  64572. _vMetallicReflectanceFactorsName: string;
  64573. /**
  64574. * The property below is set by the main PBR block prior to calling methods of this class.
  64575. */
  64576. /** @hidden */
  64577. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64578. /**
  64579. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64580. */
  64581. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64582. /**
  64583. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64584. */
  64585. useMetallnessFromMetallicTextureBlue: boolean;
  64586. /**
  64587. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64588. */
  64589. useRoughnessFromMetallicTextureAlpha: boolean;
  64590. /**
  64591. * Specifies if the metallic texture contains the roughness information in its green channel.
  64592. */
  64593. useRoughnessFromMetallicTextureGreen: boolean;
  64594. /**
  64595. * Create a new ReflectivityBlock
  64596. * @param name defines the block name
  64597. */
  64598. constructor(name: string);
  64599. /**
  64600. * Initialize the block and prepare the context for build
  64601. * @param state defines the state that will be used for the build
  64602. */
  64603. initialize(state: NodeMaterialBuildState): void;
  64604. /**
  64605. * Gets the current class name
  64606. * @returns the class name
  64607. */
  64608. getClassName(): string;
  64609. /**
  64610. * Gets the metallic input component
  64611. */
  64612. get metallic(): NodeMaterialConnectionPoint;
  64613. /**
  64614. * Gets the roughness input component
  64615. */
  64616. get roughness(): NodeMaterialConnectionPoint;
  64617. /**
  64618. * Gets the texture input component
  64619. */
  64620. get texture(): NodeMaterialConnectionPoint;
  64621. /**
  64622. * Gets the reflectivity object output component
  64623. */
  64624. get reflectivity(): NodeMaterialConnectionPoint;
  64625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64626. /**
  64627. * Gets the main code of the block (fragment side)
  64628. * @param state current state of the node material building
  64629. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64630. * @returns the shader code
  64631. */
  64632. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64634. protected _buildBlock(state: NodeMaterialBuildState): this;
  64635. protected _dumpPropertiesCode(): string;
  64636. serialize(): any;
  64637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64638. }
  64639. }
  64640. declare module BABYLON {
  64641. /**
  64642. * Block used to implement the anisotropy module of the PBR material
  64643. */
  64644. export class AnisotropyBlock extends NodeMaterialBlock {
  64645. /**
  64646. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64647. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64648. * It's less burden on the user side in the editor part.
  64649. */
  64650. /** @hidden */
  64651. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64652. /** @hidden */
  64653. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64654. /**
  64655. * Create a new AnisotropyBlock
  64656. * @param name defines the block name
  64657. */
  64658. constructor(name: string);
  64659. /**
  64660. * Initialize the block and prepare the context for build
  64661. * @param state defines the state that will be used for the build
  64662. */
  64663. initialize(state: NodeMaterialBuildState): void;
  64664. /**
  64665. * Gets the current class name
  64666. * @returns the class name
  64667. */
  64668. getClassName(): string;
  64669. /**
  64670. * Gets the intensity input component
  64671. */
  64672. get intensity(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the direction input component
  64675. */
  64676. get direction(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the texture input component
  64679. */
  64680. get texture(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the uv input component
  64683. */
  64684. get uv(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the worldTangent input component
  64687. */
  64688. get worldTangent(): NodeMaterialConnectionPoint;
  64689. /**
  64690. * Gets the anisotropy object output component
  64691. */
  64692. get anisotropy(): NodeMaterialConnectionPoint;
  64693. private _generateTBNSpace;
  64694. /**
  64695. * Gets the main code of the block (fragment side)
  64696. * @param state current state of the node material building
  64697. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64698. * @returns the shader code
  64699. */
  64700. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64702. protected _buildBlock(state: NodeMaterialBuildState): this;
  64703. }
  64704. }
  64705. declare module BABYLON {
  64706. /**
  64707. * Block used to implement the clear coat module of the PBR material
  64708. */
  64709. export class ClearCoatBlock extends NodeMaterialBlock {
  64710. private _scene;
  64711. /**
  64712. * Create a new ClearCoatBlock
  64713. * @param name defines the block name
  64714. */
  64715. constructor(name: string);
  64716. /**
  64717. * Initialize the block and prepare the context for build
  64718. * @param state defines the state that will be used for the build
  64719. */
  64720. initialize(state: NodeMaterialBuildState): void;
  64721. /**
  64722. * Gets the current class name
  64723. * @returns the class name
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Gets the intensity input component
  64728. */
  64729. get intensity(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the roughness input component
  64732. */
  64733. get roughness(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the ior input component
  64736. */
  64737. get ior(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the texture input component
  64740. */
  64741. get texture(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the bump texture input component
  64744. */
  64745. get bumpTexture(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the uv input component
  64748. */
  64749. get uv(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the tint color input component
  64752. */
  64753. get tintColor(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the tint "at distance" input component
  64756. */
  64757. get tintAtDistance(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the tint thickness input component
  64760. */
  64761. get tintThickness(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the world tangent input component
  64764. */
  64765. get worldTangent(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the clear coat object output component
  64768. */
  64769. get clearcoat(): NodeMaterialConnectionPoint;
  64770. autoConfigure(material: NodeMaterial): void;
  64771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64773. private _generateTBNSpace;
  64774. /**
  64775. * Gets the main code of the block (fragment side)
  64776. * @param state current state of the node material building
  64777. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64778. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64779. * @param worldPosVarName name of the variable holding the world position
  64780. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64781. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64782. * @param worldNormalVarName name of the variable holding the world normal
  64783. * @returns the shader code
  64784. */
  64785. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64786. protected _buildBlock(state: NodeMaterialBuildState): this;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * Block used to implement the sub surface module of the PBR material
  64792. */
  64793. export class SubSurfaceBlock extends NodeMaterialBlock {
  64794. /**
  64795. * Create a new SubSurfaceBlock
  64796. * @param name defines the block name
  64797. */
  64798. constructor(name: string);
  64799. /**
  64800. * Stores the intensity of the different subsurface effects in the thickness texture.
  64801. * * the green channel is the translucency intensity.
  64802. * * the blue channel is the scattering intensity.
  64803. * * the alpha channel is the refraction intensity.
  64804. */
  64805. useMaskFromThicknessTexture: boolean;
  64806. /**
  64807. * Initialize the block and prepare the context for build
  64808. * @param state defines the state that will be used for the build
  64809. */
  64810. initialize(state: NodeMaterialBuildState): void;
  64811. /**
  64812. * Gets the current class name
  64813. * @returns the class name
  64814. */
  64815. getClassName(): string;
  64816. /**
  64817. * Gets the min thickness input component
  64818. */
  64819. get minThickness(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the max thickness input component
  64822. */
  64823. get maxThickness(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the thickness texture component
  64826. */
  64827. get thicknessTexture(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the tint color input component
  64830. */
  64831. get tintColor(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the translucency intensity input component
  64834. */
  64835. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the translucency diffusion distance input component
  64838. */
  64839. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the refraction object parameters
  64842. */
  64843. get refraction(): NodeMaterialConnectionPoint;
  64844. /**
  64845. * Gets the sub surface object output component
  64846. */
  64847. get subsurface(): NodeMaterialConnectionPoint;
  64848. autoConfigure(material: NodeMaterial): void;
  64849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64850. /**
  64851. * Gets the main code of the block (fragment side)
  64852. * @param state current state of the node material building
  64853. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64854. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64855. * @param worldPosVarName name of the variable holding the world position
  64856. * @returns the shader code
  64857. */
  64858. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64859. protected _buildBlock(state: NodeMaterialBuildState): this;
  64860. }
  64861. }
  64862. declare module BABYLON {
  64863. /**
  64864. * Block used to implement the PBR metallic/roughness model
  64865. */
  64866. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64867. /**
  64868. * Gets or sets the light associated with this block
  64869. */
  64870. light: Nullable<Light>;
  64871. private _lightId;
  64872. private _scene;
  64873. private _environmentBRDFTexture;
  64874. private _environmentBrdfSamplerName;
  64875. private _vNormalWName;
  64876. private _invertNormalName;
  64877. /**
  64878. * Create a new ReflectionBlock
  64879. * @param name defines the block name
  64880. */
  64881. constructor(name: string);
  64882. /**
  64883. * Intensity of the direct lights e.g. the four lights available in your scene.
  64884. * This impacts both the direct diffuse and specular highlights.
  64885. */
  64886. directIntensity: number;
  64887. /**
  64888. * Intensity of the environment e.g. how much the environment will light the object
  64889. * either through harmonics for rough material or through the refelction for shiny ones.
  64890. */
  64891. environmentIntensity: number;
  64892. /**
  64893. * This is a special control allowing the reduction of the specular highlights coming from the
  64894. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64895. */
  64896. specularIntensity: number;
  64897. /**
  64898. * Defines the falloff type used in this material.
  64899. * It by default is Physical.
  64900. */
  64901. lightFalloff: number;
  64902. /**
  64903. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64904. */
  64905. useAlphaFromAlbedoTexture: boolean;
  64906. /**
  64907. * Specifies that alpha test should be used
  64908. */
  64909. useAlphaTest: boolean;
  64910. /**
  64911. * Defines the alpha limits in alpha test mode.
  64912. */
  64913. alphaTestCutoff: number;
  64914. /**
  64915. * Specifies that alpha blending should be used
  64916. */
  64917. useAlphaBlending: boolean;
  64918. /**
  64919. * Defines if the alpha value should be determined via the rgb values.
  64920. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64921. */
  64922. opacityRGB: boolean;
  64923. /**
  64924. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64925. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64926. */
  64927. useRadianceOverAlpha: boolean;
  64928. /**
  64929. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64931. */
  64932. useSpecularOverAlpha: boolean;
  64933. /**
  64934. * Enables specular anti aliasing in the PBR shader.
  64935. * It will both interacts on the Geometry for analytical and IBL lighting.
  64936. * It also prefilter the roughness map based on the bump values.
  64937. */
  64938. enableSpecularAntiAliasing: boolean;
  64939. /**
  64940. * Enables realtime filtering on the texture.
  64941. */
  64942. realTimeFiltering: boolean;
  64943. /**
  64944. * Quality switch for realtime filtering
  64945. */
  64946. realTimeFilteringQuality: number;
  64947. /**
  64948. * Defines if the material uses energy conservation.
  64949. */
  64950. useEnergyConservation: boolean;
  64951. /**
  64952. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64953. * too much the area relying on ambient texture to define their ambient occlusion.
  64954. */
  64955. useRadianceOcclusion: boolean;
  64956. /**
  64957. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64958. * makes the reflect vector face the model (under horizon).
  64959. */
  64960. useHorizonOcclusion: boolean;
  64961. /**
  64962. * If set to true, no lighting calculations will be applied.
  64963. */
  64964. unlit: boolean;
  64965. /**
  64966. * Force normal to face away from face.
  64967. */
  64968. forceNormalForward: boolean;
  64969. /**
  64970. * Defines the material debug mode.
  64971. * It helps seeing only some components of the material while troubleshooting.
  64972. */
  64973. debugMode: number;
  64974. /**
  64975. * Specify from where on screen the debug mode should start.
  64976. * The value goes from -1 (full screen) to 1 (not visible)
  64977. * It helps with side by side comparison against the final render
  64978. * This defaults to 0
  64979. */
  64980. debugLimit: number;
  64981. /**
  64982. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64983. * You can use the factor to better multiply the final value.
  64984. */
  64985. debugFactor: number;
  64986. /**
  64987. * Initialize the block and prepare the context for build
  64988. * @param state defines the state that will be used for the build
  64989. */
  64990. initialize(state: NodeMaterialBuildState): void;
  64991. /**
  64992. * Gets the current class name
  64993. * @returns the class name
  64994. */
  64995. getClassName(): string;
  64996. /**
  64997. * Gets the world position input component
  64998. */
  64999. get worldPosition(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the world normal input component
  65002. */
  65003. get worldNormal(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the perturbed normal input component
  65006. */
  65007. get perturbedNormal(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the camera position input component
  65010. */
  65011. get cameraPosition(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the base color input component
  65014. */
  65015. get baseColor(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the opacity texture input component
  65018. */
  65019. get opacityTexture(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the ambient color input component
  65022. */
  65023. get ambientColor(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the reflectivity object parameters
  65026. */
  65027. get reflectivity(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the ambient occlusion object parameters
  65030. */
  65031. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65032. /**
  65033. * Gets the reflection object parameters
  65034. */
  65035. get reflection(): NodeMaterialConnectionPoint;
  65036. /**
  65037. * Gets the sheen object parameters
  65038. */
  65039. get sheen(): NodeMaterialConnectionPoint;
  65040. /**
  65041. * Gets the clear coat object parameters
  65042. */
  65043. get clearcoat(): NodeMaterialConnectionPoint;
  65044. /**
  65045. * Gets the sub surface object parameters
  65046. */
  65047. get subsurface(): NodeMaterialConnectionPoint;
  65048. /**
  65049. * Gets the anisotropy object parameters
  65050. */
  65051. get anisotropy(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the ambient output component
  65054. */
  65055. get ambient(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the diffuse output component
  65058. */
  65059. get diffuse(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the specular output component
  65062. */
  65063. get specular(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the sheen output component
  65066. */
  65067. get sheenDir(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the clear coat output component
  65070. */
  65071. get clearcoatDir(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the indirect diffuse output component
  65074. */
  65075. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the indirect specular output component
  65078. */
  65079. get specularIndirect(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the indirect sheen output component
  65082. */
  65083. get sheenIndirect(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Gets the indirect clear coat output component
  65086. */
  65087. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65088. /**
  65089. * Gets the refraction output component
  65090. */
  65091. get refraction(): NodeMaterialConnectionPoint;
  65092. /**
  65093. * Gets the global lighting output component
  65094. */
  65095. get lighting(): NodeMaterialConnectionPoint;
  65096. /**
  65097. * Gets the shadow output component
  65098. */
  65099. get shadow(): NodeMaterialConnectionPoint;
  65100. /**
  65101. * Gets the alpha output component
  65102. */
  65103. get alpha(): NodeMaterialConnectionPoint;
  65104. autoConfigure(material: NodeMaterial): void;
  65105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65106. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65108. private _injectVertexCode;
  65109. /**
  65110. * Gets the code corresponding to the albedo/opacity module
  65111. * @returns the shader code
  65112. */
  65113. getAlbedoOpacityCode(): string;
  65114. protected _buildBlock(state: NodeMaterialBuildState): this;
  65115. protected _dumpPropertiesCode(): string;
  65116. serialize(): any;
  65117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. * Block used to compute value of one parameter modulo another
  65123. */
  65124. export class ModBlock extends NodeMaterialBlock {
  65125. /**
  65126. * Creates a new ModBlock
  65127. * @param name defines the block name
  65128. */
  65129. constructor(name: string);
  65130. /**
  65131. * Gets the current class name
  65132. * @returns the class name
  65133. */
  65134. getClassName(): string;
  65135. /**
  65136. * Gets the left operand input component
  65137. */
  65138. get left(): NodeMaterialConnectionPoint;
  65139. /**
  65140. * Gets the right operand input component
  65141. */
  65142. get right(): NodeMaterialConnectionPoint;
  65143. /**
  65144. * Gets the output component
  65145. */
  65146. get output(): NodeMaterialConnectionPoint;
  65147. protected _buildBlock(state: NodeMaterialBuildState): this;
  65148. }
  65149. }
  65150. declare module BABYLON {
  65151. /**
  65152. * Configuration for Draco compression
  65153. */
  65154. export interface IDracoCompressionConfiguration {
  65155. /**
  65156. * Configuration for the decoder.
  65157. */
  65158. decoder: {
  65159. /**
  65160. * The url to the WebAssembly module.
  65161. */
  65162. wasmUrl?: string;
  65163. /**
  65164. * The url to the WebAssembly binary.
  65165. */
  65166. wasmBinaryUrl?: string;
  65167. /**
  65168. * The url to the fallback JavaScript module.
  65169. */
  65170. fallbackUrl?: string;
  65171. };
  65172. }
  65173. /**
  65174. * Draco compression (https://google.github.io/draco/)
  65175. *
  65176. * This class wraps the Draco module.
  65177. *
  65178. * **Encoder**
  65179. *
  65180. * The encoder is not currently implemented.
  65181. *
  65182. * **Decoder**
  65183. *
  65184. * 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.
  65185. *
  65186. * To update the configuration, use the following code:
  65187. * ```javascript
  65188. * DracoCompression.Configuration = {
  65189. * decoder: {
  65190. * wasmUrl: "<url to the WebAssembly library>",
  65191. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65192. * fallbackUrl: "<url to the fallback JavaScript library>",
  65193. * }
  65194. * };
  65195. * ```
  65196. *
  65197. * 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.
  65198. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65199. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65200. *
  65201. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65202. * ```javascript
  65203. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65204. * ```
  65205. *
  65206. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65207. */
  65208. export class DracoCompression implements IDisposable {
  65209. private _workerPoolPromise?;
  65210. private _decoderModulePromise?;
  65211. /**
  65212. * The configuration. Defaults to the following urls:
  65213. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65214. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65215. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65216. */
  65217. static Configuration: IDracoCompressionConfiguration;
  65218. /**
  65219. * Returns true if the decoder configuration is available.
  65220. */
  65221. static get DecoderAvailable(): boolean;
  65222. /**
  65223. * Default number of workers to create when creating the draco compression object.
  65224. */
  65225. static DefaultNumWorkers: number;
  65226. private static GetDefaultNumWorkers;
  65227. private static _Default;
  65228. /**
  65229. * Default instance for the draco compression object.
  65230. */
  65231. static get Default(): DracoCompression;
  65232. /**
  65233. * Constructor
  65234. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65235. */
  65236. constructor(numWorkers?: number);
  65237. /**
  65238. * Stop all async operations and release resources.
  65239. */
  65240. dispose(): void;
  65241. /**
  65242. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65243. * @returns a promise that resolves when ready
  65244. */
  65245. whenReadyAsync(): Promise<void>;
  65246. /**
  65247. * Decode Draco compressed mesh data to vertex data.
  65248. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65249. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65250. * @returns A promise that resolves with the decoded vertex data
  65251. */
  65252. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65253. [kind: string]: number;
  65254. }): Promise<VertexData>;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Class for building Constructive Solid Geometry
  65260. */
  65261. export class CSG {
  65262. private polygons;
  65263. /**
  65264. * The world matrix
  65265. */
  65266. matrix: Matrix;
  65267. /**
  65268. * Stores the position
  65269. */
  65270. position: Vector3;
  65271. /**
  65272. * Stores the rotation
  65273. */
  65274. rotation: Vector3;
  65275. /**
  65276. * Stores the rotation quaternion
  65277. */
  65278. rotationQuaternion: Nullable<Quaternion>;
  65279. /**
  65280. * Stores the scaling vector
  65281. */
  65282. scaling: Vector3;
  65283. /**
  65284. * Convert the Mesh to CSG
  65285. * @param mesh The Mesh to convert to CSG
  65286. * @returns A new CSG from the Mesh
  65287. */
  65288. static FromMesh(mesh: Mesh): CSG;
  65289. /**
  65290. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65291. * @param polygons Polygons used to construct a CSG solid
  65292. */
  65293. private static FromPolygons;
  65294. /**
  65295. * Clones, or makes a deep copy, of the CSG
  65296. * @returns A new CSG
  65297. */
  65298. clone(): CSG;
  65299. /**
  65300. * Unions this CSG with another CSG
  65301. * @param csg The CSG to union against this CSG
  65302. * @returns The unioned CSG
  65303. */
  65304. union(csg: CSG): CSG;
  65305. /**
  65306. * Unions this CSG with another CSG in place
  65307. * @param csg The CSG to union against this CSG
  65308. */
  65309. unionInPlace(csg: CSG): void;
  65310. /**
  65311. * Subtracts this CSG with another CSG
  65312. * @param csg The CSG to subtract against this CSG
  65313. * @returns A new CSG
  65314. */
  65315. subtract(csg: CSG): CSG;
  65316. /**
  65317. * Subtracts this CSG with another CSG in place
  65318. * @param csg The CSG to subtact against this CSG
  65319. */
  65320. subtractInPlace(csg: CSG): void;
  65321. /**
  65322. * Intersect this CSG with another CSG
  65323. * @param csg The CSG to intersect against this CSG
  65324. * @returns A new CSG
  65325. */
  65326. intersect(csg: CSG): CSG;
  65327. /**
  65328. * Intersects this CSG with another CSG in place
  65329. * @param csg The CSG to intersect against this CSG
  65330. */
  65331. intersectInPlace(csg: CSG): void;
  65332. /**
  65333. * Return a new CSG solid with solid and empty space switched. This solid is
  65334. * not modified.
  65335. * @returns A new CSG solid with solid and empty space switched
  65336. */
  65337. inverse(): CSG;
  65338. /**
  65339. * Inverses the CSG in place
  65340. */
  65341. inverseInPlace(): void;
  65342. /**
  65343. * This is used to keep meshes transformations so they can be restored
  65344. * when we build back a Babylon Mesh
  65345. * NB : All CSG operations are performed in world coordinates
  65346. * @param csg The CSG to copy the transform attributes from
  65347. * @returns This CSG
  65348. */
  65349. copyTransformAttributes(csg: CSG): CSG;
  65350. /**
  65351. * Build Raw mesh from CSG
  65352. * Coordinates here are in world space
  65353. * @param name The name of the mesh geometry
  65354. * @param scene The Scene
  65355. * @param keepSubMeshes Specifies if the submeshes should be kept
  65356. * @returns A new Mesh
  65357. */
  65358. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65359. /**
  65360. * Build Mesh from CSG taking material and transforms into account
  65361. * @param name The name of the Mesh
  65362. * @param material The material of the Mesh
  65363. * @param scene The Scene
  65364. * @param keepSubMeshes Specifies if submeshes should be kept
  65365. * @returns The new Mesh
  65366. */
  65367. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65368. }
  65369. }
  65370. declare module BABYLON {
  65371. /**
  65372. * Class used to create a trail following a mesh
  65373. */
  65374. export class TrailMesh extends Mesh {
  65375. private _generator;
  65376. private _autoStart;
  65377. private _running;
  65378. private _diameter;
  65379. private _length;
  65380. private _sectionPolygonPointsCount;
  65381. private _sectionVectors;
  65382. private _sectionNormalVectors;
  65383. private _beforeRenderObserver;
  65384. /**
  65385. * @constructor
  65386. * @param name The value used by scene.getMeshByName() to do a lookup.
  65387. * @param generator The mesh or transform node to generate a trail.
  65388. * @param scene The scene to add this mesh to.
  65389. * @param diameter Diameter of trailing mesh. Default is 1.
  65390. * @param length Length of trailing mesh. Default is 60.
  65391. * @param autoStart Automatically start trailing mesh. Default true.
  65392. */
  65393. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65394. /**
  65395. * "TrailMesh"
  65396. * @returns "TrailMesh"
  65397. */
  65398. getClassName(): string;
  65399. private _createMesh;
  65400. /**
  65401. * Start trailing mesh.
  65402. */
  65403. start(): void;
  65404. /**
  65405. * Stop trailing mesh.
  65406. */
  65407. stop(): void;
  65408. /**
  65409. * Update trailing mesh geometry.
  65410. */
  65411. update(): void;
  65412. /**
  65413. * Returns a new TrailMesh object.
  65414. * @param name is a string, the name given to the new mesh
  65415. * @param newGenerator use new generator object for cloned trail mesh
  65416. * @returns a new mesh
  65417. */
  65418. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65419. /**
  65420. * Serializes this trail mesh
  65421. * @param serializationObject object to write serialization to
  65422. */
  65423. serialize(serializationObject: any): void;
  65424. /**
  65425. * Parses a serialized trail mesh
  65426. * @param parsedMesh the serialized mesh
  65427. * @param scene the scene to create the trail mesh in
  65428. * @returns the created trail mesh
  65429. */
  65430. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65431. }
  65432. }
  65433. declare module BABYLON {
  65434. /**
  65435. * Class containing static functions to help procedurally build meshes
  65436. */
  65437. export class TiledBoxBuilder {
  65438. /**
  65439. * Creates a box mesh
  65440. * 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)
  65441. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65443. * * 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
  65444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65445. * @param name defines the name of the mesh
  65446. * @param options defines the options used to create the mesh
  65447. * @param scene defines the hosting scene
  65448. * @returns the box mesh
  65449. */
  65450. static CreateTiledBox(name: string, options: {
  65451. pattern?: number;
  65452. width?: number;
  65453. height?: number;
  65454. depth?: number;
  65455. tileSize?: number;
  65456. tileWidth?: number;
  65457. tileHeight?: number;
  65458. alignHorizontal?: number;
  65459. alignVertical?: number;
  65460. faceUV?: Vector4[];
  65461. faceColors?: Color4[];
  65462. sideOrientation?: number;
  65463. updatable?: boolean;
  65464. }, scene?: Nullable<Scene>): Mesh;
  65465. }
  65466. }
  65467. declare module BABYLON {
  65468. /**
  65469. * Class containing static functions to help procedurally build meshes
  65470. */
  65471. export class TorusKnotBuilder {
  65472. /**
  65473. * Creates a torus knot mesh
  65474. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65475. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65476. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65477. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65479. * * 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
  65480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65481. * @param name defines the name of the mesh
  65482. * @param options defines the options used to create the mesh
  65483. * @param scene defines the hosting scene
  65484. * @returns the torus knot mesh
  65485. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65486. */
  65487. static CreateTorusKnot(name: string, options: {
  65488. radius?: number;
  65489. tube?: number;
  65490. radialSegments?: number;
  65491. tubularSegments?: number;
  65492. p?: number;
  65493. q?: number;
  65494. updatable?: boolean;
  65495. sideOrientation?: number;
  65496. frontUVs?: Vector4;
  65497. backUVs?: Vector4;
  65498. }, scene: any): Mesh;
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /**
  65503. * Polygon
  65504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65505. */
  65506. export class Polygon {
  65507. /**
  65508. * Creates a rectangle
  65509. * @param xmin bottom X coord
  65510. * @param ymin bottom Y coord
  65511. * @param xmax top X coord
  65512. * @param ymax top Y coord
  65513. * @returns points that make the resulting rectation
  65514. */
  65515. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65516. /**
  65517. * Creates a circle
  65518. * @param radius radius of circle
  65519. * @param cx scale in x
  65520. * @param cy scale in y
  65521. * @param numberOfSides number of sides that make up the circle
  65522. * @returns points that make the resulting circle
  65523. */
  65524. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65525. /**
  65526. * Creates a polygon from input string
  65527. * @param input Input polygon data
  65528. * @returns the parsed points
  65529. */
  65530. static Parse(input: string): Vector2[];
  65531. /**
  65532. * Starts building a polygon from x and y coordinates
  65533. * @param x x coordinate
  65534. * @param y y coordinate
  65535. * @returns the started path2
  65536. */
  65537. static StartingAt(x: number, y: number): Path2;
  65538. }
  65539. /**
  65540. * Builds a polygon
  65541. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65542. */
  65543. export class PolygonMeshBuilder {
  65544. private _points;
  65545. private _outlinepoints;
  65546. private _holes;
  65547. private _name;
  65548. private _scene;
  65549. private _epoints;
  65550. private _eholes;
  65551. private _addToepoint;
  65552. /**
  65553. * Babylon reference to the earcut plugin.
  65554. */
  65555. bjsEarcut: any;
  65556. /**
  65557. * Creates a PolygonMeshBuilder
  65558. * @param name name of the builder
  65559. * @param contours Path of the polygon
  65560. * @param scene scene to add to when creating the mesh
  65561. * @param earcutInjection can be used to inject your own earcut reference
  65562. */
  65563. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65564. /**
  65565. * Adds a whole within the polygon
  65566. * @param hole Array of points defining the hole
  65567. * @returns this
  65568. */
  65569. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65570. /**
  65571. * Creates the polygon
  65572. * @param updatable If the mesh should be updatable
  65573. * @param depth The depth of the mesh created
  65574. * @returns the created mesh
  65575. */
  65576. build(updatable?: boolean, depth?: number): Mesh;
  65577. /**
  65578. * Creates the polygon
  65579. * @param depth The depth of the mesh created
  65580. * @returns the created VertexData
  65581. */
  65582. buildVertexData(depth?: number): VertexData;
  65583. /**
  65584. * Adds a side to the polygon
  65585. * @param positions points that make the polygon
  65586. * @param normals normals of the polygon
  65587. * @param uvs uvs of the polygon
  65588. * @param indices indices of the polygon
  65589. * @param bounds bounds of the polygon
  65590. * @param points points of the polygon
  65591. * @param depth depth of the polygon
  65592. * @param flip flip of the polygon
  65593. */
  65594. private addSide;
  65595. }
  65596. }
  65597. declare module BABYLON {
  65598. /**
  65599. * Class containing static functions to help procedurally build meshes
  65600. */
  65601. export class PolygonBuilder {
  65602. /**
  65603. * Creates a polygon mesh
  65604. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65605. * * 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
  65606. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65608. * * 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)
  65609. * * Remember you can only change the shape positions, not their number when updating a polygon
  65610. * @param name defines the name of the mesh
  65611. * @param options defines the options used to create the mesh
  65612. * @param scene defines the hosting scene
  65613. * @param earcutInjection can be used to inject your own earcut reference
  65614. * @returns the polygon mesh
  65615. */
  65616. static CreatePolygon(name: string, options: {
  65617. shape: Vector3[];
  65618. holes?: Vector3[][];
  65619. depth?: number;
  65620. faceUV?: Vector4[];
  65621. faceColors?: Color4[];
  65622. updatable?: boolean;
  65623. sideOrientation?: number;
  65624. frontUVs?: Vector4;
  65625. backUVs?: Vector4;
  65626. wrap?: boolean;
  65627. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65628. /**
  65629. * Creates an extruded polygon mesh, with depth in the Y direction.
  65630. * * 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)
  65631. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65632. * @param name defines the name of the mesh
  65633. * @param options defines the options used to create the mesh
  65634. * @param scene defines the hosting scene
  65635. * @param earcutInjection can be used to inject your own earcut reference
  65636. * @returns the polygon mesh
  65637. */
  65638. static ExtrudePolygon(name: string, options: {
  65639. shape: Vector3[];
  65640. holes?: Vector3[][];
  65641. depth?: number;
  65642. faceUV?: Vector4[];
  65643. faceColors?: Color4[];
  65644. updatable?: boolean;
  65645. sideOrientation?: number;
  65646. frontUVs?: Vector4;
  65647. backUVs?: Vector4;
  65648. wrap?: boolean;
  65649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65650. }
  65651. }
  65652. declare module BABYLON {
  65653. /**
  65654. * Class containing static functions to help procedurally build meshes
  65655. */
  65656. export class LatheBuilder {
  65657. /**
  65658. * Creates lathe mesh.
  65659. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65660. * * 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
  65661. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65662. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65663. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65664. * * 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
  65665. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65666. * * 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
  65667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65668. * * 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
  65669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65671. * @param name defines the name of the mesh
  65672. * @param options defines the options used to create the mesh
  65673. * @param scene defines the hosting scene
  65674. * @returns the lathe mesh
  65675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65676. */
  65677. static CreateLathe(name: string, options: {
  65678. shape: Vector3[];
  65679. radius?: number;
  65680. tessellation?: number;
  65681. clip?: number;
  65682. arc?: number;
  65683. closed?: boolean;
  65684. updatable?: boolean;
  65685. sideOrientation?: number;
  65686. frontUVs?: Vector4;
  65687. backUVs?: Vector4;
  65688. cap?: number;
  65689. invertUV?: boolean;
  65690. }, scene?: Nullable<Scene>): Mesh;
  65691. }
  65692. }
  65693. declare module BABYLON {
  65694. /**
  65695. * Class containing static functions to help procedurally build meshes
  65696. */
  65697. export class TiledPlaneBuilder {
  65698. /**
  65699. * Creates a tiled plane mesh
  65700. * * The parameter `pattern` will, depending on value, do nothing or
  65701. * * * flip (reflect about central vertical) alternate tiles across and up
  65702. * * * flip every tile on alternate rows
  65703. * * * rotate (180 degs) alternate tiles across and up
  65704. * * * rotate every tile on alternate rows
  65705. * * * flip and rotate alternate tiles across and up
  65706. * * * flip and rotate every tile on alternate rows
  65707. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65708. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65709. * * 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
  65710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65711. * * 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)
  65712. * * 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)
  65713. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65714. * @param name defines the name of the mesh
  65715. * @param options defines the options used to create the mesh
  65716. * @param scene defines the hosting scene
  65717. * @returns the box mesh
  65718. */
  65719. static CreateTiledPlane(name: string, options: {
  65720. pattern?: number;
  65721. tileSize?: number;
  65722. tileWidth?: number;
  65723. tileHeight?: number;
  65724. size?: number;
  65725. width?: number;
  65726. height?: number;
  65727. alignHorizontal?: number;
  65728. alignVertical?: number;
  65729. sideOrientation?: number;
  65730. frontUVs?: Vector4;
  65731. backUVs?: Vector4;
  65732. updatable?: boolean;
  65733. }, scene?: Nullable<Scene>): Mesh;
  65734. }
  65735. }
  65736. declare module BABYLON {
  65737. /**
  65738. * Class containing static functions to help procedurally build meshes
  65739. */
  65740. export class TubeBuilder {
  65741. /**
  65742. * Creates a tube mesh.
  65743. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65744. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65745. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65746. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65747. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65748. * * 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)
  65749. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65750. * * 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
  65751. * * 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
  65752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65753. * * 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
  65754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65756. * @param name defines the name of the mesh
  65757. * @param options defines the options used to create the mesh
  65758. * @param scene defines the hosting scene
  65759. * @returns the tube mesh
  65760. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65761. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65762. */
  65763. static CreateTube(name: string, options: {
  65764. path: Vector3[];
  65765. radius?: number;
  65766. tessellation?: number;
  65767. radiusFunction?: {
  65768. (i: number, distance: number): number;
  65769. };
  65770. cap?: number;
  65771. arc?: number;
  65772. updatable?: boolean;
  65773. sideOrientation?: number;
  65774. frontUVs?: Vector4;
  65775. backUVs?: Vector4;
  65776. instance?: Mesh;
  65777. invertUV?: boolean;
  65778. }, scene?: Nullable<Scene>): Mesh;
  65779. }
  65780. }
  65781. declare module BABYLON {
  65782. /**
  65783. * Class containing static functions to help procedurally build meshes
  65784. */
  65785. export class IcoSphereBuilder {
  65786. /**
  65787. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65788. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65789. * * 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`)
  65790. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65791. * * 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
  65792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65793. * * 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
  65794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65795. * @param name defines the name of the mesh
  65796. * @param options defines the options used to create the mesh
  65797. * @param scene defines the hosting scene
  65798. * @returns the icosahedron mesh
  65799. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65800. */
  65801. static CreateIcoSphere(name: string, options: {
  65802. radius?: number;
  65803. radiusX?: number;
  65804. radiusY?: number;
  65805. radiusZ?: number;
  65806. flat?: boolean;
  65807. subdivisions?: number;
  65808. sideOrientation?: number;
  65809. frontUVs?: Vector4;
  65810. backUVs?: Vector4;
  65811. updatable?: boolean;
  65812. }, scene?: Nullable<Scene>): Mesh;
  65813. }
  65814. }
  65815. declare module BABYLON {
  65816. /**
  65817. * Class containing static functions to help procedurally build meshes
  65818. */
  65819. export class DecalBuilder {
  65820. /**
  65821. * Creates a decal mesh.
  65822. * 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
  65823. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65824. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65825. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65826. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65827. * @param name defines the name of the mesh
  65828. * @param sourceMesh defines the mesh where the decal must be applied
  65829. * @param options defines the options used to create the mesh
  65830. * @param scene defines the hosting scene
  65831. * @returns the decal mesh
  65832. * @see https://doc.babylonjs.com/how_to/decals
  65833. */
  65834. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65835. position?: Vector3;
  65836. normal?: Vector3;
  65837. size?: Vector3;
  65838. angle?: number;
  65839. }): Mesh;
  65840. }
  65841. }
  65842. declare module BABYLON {
  65843. /**
  65844. * Class containing static functions to help procedurally build meshes
  65845. */
  65846. export class MeshBuilder {
  65847. /**
  65848. * Creates a box mesh
  65849. * * The parameter `size` sets the size (float) of each box side (default 1)
  65850. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65851. * * 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)
  65852. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65854. * * 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
  65855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65856. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65857. * @param name defines the name of the mesh
  65858. * @param options defines the options used to create the mesh
  65859. * @param scene defines the hosting scene
  65860. * @returns the box mesh
  65861. */
  65862. static CreateBox(name: string, options: {
  65863. size?: number;
  65864. width?: number;
  65865. height?: number;
  65866. depth?: number;
  65867. faceUV?: Vector4[];
  65868. faceColors?: Color4[];
  65869. sideOrientation?: number;
  65870. frontUVs?: Vector4;
  65871. backUVs?: Vector4;
  65872. wrap?: boolean;
  65873. topBaseAt?: number;
  65874. bottomBaseAt?: number;
  65875. updatable?: boolean;
  65876. }, scene?: Nullable<Scene>): Mesh;
  65877. /**
  65878. * Creates a tiled box mesh
  65879. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65881. * @param name defines the name of the mesh
  65882. * @param options defines the options used to create the mesh
  65883. * @param scene defines the hosting scene
  65884. * @returns the tiled box mesh
  65885. */
  65886. static CreateTiledBox(name: string, options: {
  65887. pattern?: number;
  65888. size?: number;
  65889. width?: number;
  65890. height?: number;
  65891. depth: number;
  65892. tileSize?: number;
  65893. tileWidth?: number;
  65894. tileHeight?: number;
  65895. faceUV?: Vector4[];
  65896. faceColors?: Color4[];
  65897. alignHorizontal?: number;
  65898. alignVertical?: number;
  65899. sideOrientation?: number;
  65900. updatable?: boolean;
  65901. }, scene?: Nullable<Scene>): Mesh;
  65902. /**
  65903. * Creates a sphere mesh
  65904. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65905. * * 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`)
  65906. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65907. * * 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
  65908. * * 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)
  65909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65910. * * 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
  65911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65912. * @param name defines the name of the mesh
  65913. * @param options defines the options used to create the mesh
  65914. * @param scene defines the hosting scene
  65915. * @returns the sphere mesh
  65916. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65917. */
  65918. static CreateSphere(name: string, options: {
  65919. segments?: number;
  65920. diameter?: number;
  65921. diameterX?: number;
  65922. diameterY?: number;
  65923. diameterZ?: number;
  65924. arc?: number;
  65925. slice?: number;
  65926. sideOrientation?: number;
  65927. frontUVs?: Vector4;
  65928. backUVs?: Vector4;
  65929. updatable?: boolean;
  65930. }, scene?: Nullable<Scene>): Mesh;
  65931. /**
  65932. * Creates a plane polygonal mesh. By default, this is a disc
  65933. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65934. * * 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
  65935. * * 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
  65936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65937. * * 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
  65938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65939. * @param name defines the name of the mesh
  65940. * @param options defines the options used to create the mesh
  65941. * @param scene defines the hosting scene
  65942. * @returns the plane polygonal mesh
  65943. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65944. */
  65945. static CreateDisc(name: string, options: {
  65946. radius?: number;
  65947. tessellation?: number;
  65948. arc?: number;
  65949. updatable?: boolean;
  65950. sideOrientation?: number;
  65951. frontUVs?: Vector4;
  65952. backUVs?: Vector4;
  65953. }, scene?: Nullable<Scene>): Mesh;
  65954. /**
  65955. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65956. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65957. * * 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`)
  65958. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65959. * * 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
  65960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65961. * * 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
  65962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65963. * @param name defines the name of the mesh
  65964. * @param options defines the options used to create the mesh
  65965. * @param scene defines the hosting scene
  65966. * @returns the icosahedron mesh
  65967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65968. */
  65969. static CreateIcoSphere(name: string, options: {
  65970. radius?: number;
  65971. radiusX?: number;
  65972. radiusY?: number;
  65973. radiusZ?: number;
  65974. flat?: boolean;
  65975. subdivisions?: number;
  65976. sideOrientation?: number;
  65977. frontUVs?: Vector4;
  65978. backUVs?: Vector4;
  65979. updatable?: boolean;
  65980. }, scene?: Nullable<Scene>): Mesh;
  65981. /**
  65982. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65983. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65984. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65985. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65986. * * 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
  65987. * * 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
  65988. * * 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
  65989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65990. * * 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
  65991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65992. * * 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
  65993. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65994. * * 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
  65995. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65997. * @param name defines the name of the mesh
  65998. * @param options defines the options used to create the mesh
  65999. * @param scene defines the hosting scene
  66000. * @returns the ribbon mesh
  66001. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66003. */
  66004. static CreateRibbon(name: string, options: {
  66005. pathArray: Vector3[][];
  66006. closeArray?: boolean;
  66007. closePath?: boolean;
  66008. offset?: number;
  66009. updatable?: boolean;
  66010. sideOrientation?: number;
  66011. frontUVs?: Vector4;
  66012. backUVs?: Vector4;
  66013. instance?: Mesh;
  66014. invertUV?: boolean;
  66015. uvs?: Vector2[];
  66016. colors?: Color4[];
  66017. }, scene?: Nullable<Scene>): Mesh;
  66018. /**
  66019. * Creates a cylinder or a cone mesh
  66020. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66021. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66022. * * 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.
  66023. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66024. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66025. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66026. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66027. * * 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).
  66028. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66029. * * 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).
  66030. * * 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
  66031. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66032. * * 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
  66033. * * 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.
  66034. * * If `enclose` is false, a ring surface is one element.
  66035. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66036. * * 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
  66037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66038. * * 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
  66039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66040. * @param name defines the name of the mesh
  66041. * @param options defines the options used to create the mesh
  66042. * @param scene defines the hosting scene
  66043. * @returns the cylinder mesh
  66044. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66045. */
  66046. static CreateCylinder(name: string, options: {
  66047. height?: number;
  66048. diameterTop?: number;
  66049. diameterBottom?: number;
  66050. diameter?: number;
  66051. tessellation?: number;
  66052. subdivisions?: number;
  66053. arc?: number;
  66054. faceColors?: Color4[];
  66055. faceUV?: Vector4[];
  66056. updatable?: boolean;
  66057. hasRings?: boolean;
  66058. enclose?: boolean;
  66059. cap?: number;
  66060. sideOrientation?: number;
  66061. frontUVs?: Vector4;
  66062. backUVs?: Vector4;
  66063. }, scene?: Nullable<Scene>): Mesh;
  66064. /**
  66065. * Creates a torus mesh
  66066. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66067. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66068. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66070. * * 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
  66071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66072. * @param name defines the name of the mesh
  66073. * @param options defines the options used to create the mesh
  66074. * @param scene defines the hosting scene
  66075. * @returns the torus mesh
  66076. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66077. */
  66078. static CreateTorus(name: string, options: {
  66079. diameter?: number;
  66080. thickness?: number;
  66081. tessellation?: number;
  66082. updatable?: boolean;
  66083. sideOrientation?: number;
  66084. frontUVs?: Vector4;
  66085. backUVs?: Vector4;
  66086. }, scene?: Nullable<Scene>): Mesh;
  66087. /**
  66088. * Creates a torus knot mesh
  66089. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66090. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66091. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66092. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66094. * * 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
  66095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66096. * @param name defines the name of the mesh
  66097. * @param options defines the options used to create the mesh
  66098. * @param scene defines the hosting scene
  66099. * @returns the torus knot mesh
  66100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66101. */
  66102. static CreateTorusKnot(name: string, options: {
  66103. radius?: number;
  66104. tube?: number;
  66105. radialSegments?: number;
  66106. tubularSegments?: number;
  66107. p?: number;
  66108. q?: number;
  66109. updatable?: boolean;
  66110. sideOrientation?: number;
  66111. frontUVs?: Vector4;
  66112. backUVs?: Vector4;
  66113. }, scene?: Nullable<Scene>): Mesh;
  66114. /**
  66115. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66116. * * 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
  66117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66118. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66119. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66120. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66122. * * 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
  66123. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66126. * @param name defines the name of the new line system
  66127. * @param options defines the options used to create the line system
  66128. * @param scene defines the hosting scene
  66129. * @returns a new line system mesh
  66130. */
  66131. static CreateLineSystem(name: string, options: {
  66132. lines: Vector3[][];
  66133. updatable?: boolean;
  66134. instance?: Nullable<LinesMesh>;
  66135. colors?: Nullable<Color4[][]>;
  66136. useVertexAlpha?: boolean;
  66137. }, scene: Nullable<Scene>): LinesMesh;
  66138. /**
  66139. * Creates a line mesh
  66140. * 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
  66141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66142. * * The parameter `points` is an array successive Vector3
  66143. * * 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
  66144. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66146. * * When updating an instance, remember that only point positions can change, not the number of points
  66147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66149. * @param name defines the name of the new line system
  66150. * @param options defines the options used to create the line system
  66151. * @param scene defines the hosting scene
  66152. * @returns a new line mesh
  66153. */
  66154. static CreateLines(name: string, options: {
  66155. points: Vector3[];
  66156. updatable?: boolean;
  66157. instance?: Nullable<LinesMesh>;
  66158. colors?: Color4[];
  66159. useVertexAlpha?: boolean;
  66160. }, scene?: Nullable<Scene>): LinesMesh;
  66161. /**
  66162. * Creates a dashed line mesh
  66163. * * 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
  66164. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66165. * * The parameter `points` is an array successive Vector3
  66166. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66167. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66168. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66169. * * 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
  66170. * * When updating an instance, remember that only point positions can change, not the number of points
  66171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66172. * @param name defines the name of the mesh
  66173. * @param options defines the options used to create the mesh
  66174. * @param scene defines the hosting scene
  66175. * @returns the dashed line mesh
  66176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66177. */
  66178. static CreateDashedLines(name: string, options: {
  66179. points: Vector3[];
  66180. dashSize?: number;
  66181. gapSize?: number;
  66182. dashNb?: number;
  66183. updatable?: boolean;
  66184. instance?: LinesMesh;
  66185. }, scene?: Nullable<Scene>): LinesMesh;
  66186. /**
  66187. * 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.
  66188. * * 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.
  66189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66190. * * 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.
  66191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66192. * * 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
  66193. * * 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
  66194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66196. * * 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
  66197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66199. * @param name defines the name of the mesh
  66200. * @param options defines the options used to create the mesh
  66201. * @param scene defines the hosting scene
  66202. * @returns the extruded shape mesh
  66203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66205. */
  66206. static ExtrudeShape(name: string, options: {
  66207. shape: Vector3[];
  66208. path: Vector3[];
  66209. scale?: number;
  66210. rotation?: number;
  66211. cap?: number;
  66212. updatable?: boolean;
  66213. sideOrientation?: number;
  66214. frontUVs?: Vector4;
  66215. backUVs?: Vector4;
  66216. instance?: Mesh;
  66217. invertUV?: boolean;
  66218. }, scene?: Nullable<Scene>): Mesh;
  66219. /**
  66220. * Creates an custom extruded shape mesh.
  66221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66222. * * 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.
  66223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66224. * * 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
  66225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66226. * * 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
  66227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66230. * * 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
  66231. * * 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
  66232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66234. * * 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
  66235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66237. * @param name defines the name of the mesh
  66238. * @param options defines the options used to create the mesh
  66239. * @param scene defines the hosting scene
  66240. * @returns the custom extruded shape mesh
  66241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66244. */
  66245. static ExtrudeShapeCustom(name: string, options: {
  66246. shape: Vector3[];
  66247. path: Vector3[];
  66248. scaleFunction?: any;
  66249. rotationFunction?: any;
  66250. ribbonCloseArray?: boolean;
  66251. ribbonClosePath?: boolean;
  66252. cap?: number;
  66253. updatable?: boolean;
  66254. sideOrientation?: number;
  66255. frontUVs?: Vector4;
  66256. backUVs?: Vector4;
  66257. instance?: Mesh;
  66258. invertUV?: boolean;
  66259. }, scene?: Nullable<Scene>): Mesh;
  66260. /**
  66261. * Creates lathe mesh.
  66262. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66263. * * 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
  66264. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66265. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66266. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66267. * * 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
  66268. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66269. * * 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
  66270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66271. * * 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
  66272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66274. * @param name defines the name of the mesh
  66275. * @param options defines the options used to create the mesh
  66276. * @param scene defines the hosting scene
  66277. * @returns the lathe mesh
  66278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66279. */
  66280. static CreateLathe(name: string, options: {
  66281. shape: Vector3[];
  66282. radius?: number;
  66283. tessellation?: number;
  66284. clip?: number;
  66285. arc?: number;
  66286. closed?: boolean;
  66287. updatable?: boolean;
  66288. sideOrientation?: number;
  66289. frontUVs?: Vector4;
  66290. backUVs?: Vector4;
  66291. cap?: number;
  66292. invertUV?: boolean;
  66293. }, scene?: Nullable<Scene>): Mesh;
  66294. /**
  66295. * Creates a tiled plane mesh
  66296. * * You can set a limited pattern arrangement with the tiles
  66297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66298. * * 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
  66299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66300. * @param name defines the name of the mesh
  66301. * @param options defines the options used to create the mesh
  66302. * @param scene defines the hosting scene
  66303. * @returns the plane mesh
  66304. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66305. */
  66306. static CreateTiledPlane(name: string, options: {
  66307. pattern?: number;
  66308. tileSize?: number;
  66309. tileWidth?: number;
  66310. tileHeight?: number;
  66311. size?: number;
  66312. width?: number;
  66313. height?: number;
  66314. alignHorizontal?: number;
  66315. alignVertical?: number;
  66316. sideOrientation?: number;
  66317. frontUVs?: Vector4;
  66318. backUVs?: Vector4;
  66319. updatable?: boolean;
  66320. }, scene?: Nullable<Scene>): Mesh;
  66321. /**
  66322. * Creates a plane mesh
  66323. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66324. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66325. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66327. * * 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
  66328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66329. * @param name defines the name of the mesh
  66330. * @param options defines the options used to create the mesh
  66331. * @param scene defines the hosting scene
  66332. * @returns the plane mesh
  66333. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66334. */
  66335. static CreatePlane(name: string, options: {
  66336. size?: number;
  66337. width?: number;
  66338. height?: number;
  66339. sideOrientation?: number;
  66340. frontUVs?: Vector4;
  66341. backUVs?: Vector4;
  66342. updatable?: boolean;
  66343. sourcePlane?: Plane;
  66344. }, scene?: Nullable<Scene>): Mesh;
  66345. /**
  66346. * Creates a ground mesh
  66347. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66348. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66350. * @param name defines the name of the mesh
  66351. * @param options defines the options used to create the mesh
  66352. * @param scene defines the hosting scene
  66353. * @returns the ground mesh
  66354. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66355. */
  66356. static CreateGround(name: string, options: {
  66357. width?: number;
  66358. height?: number;
  66359. subdivisions?: number;
  66360. subdivisionsX?: number;
  66361. subdivisionsY?: number;
  66362. updatable?: boolean;
  66363. }, scene?: Nullable<Scene>): Mesh;
  66364. /**
  66365. * Creates a tiled ground mesh
  66366. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66367. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66368. * * 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
  66369. * * 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
  66370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66371. * @param name defines the name of the mesh
  66372. * @param options defines the options used to create the mesh
  66373. * @param scene defines the hosting scene
  66374. * @returns the tiled ground mesh
  66375. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66376. */
  66377. static CreateTiledGround(name: string, options: {
  66378. xmin: number;
  66379. zmin: number;
  66380. xmax: number;
  66381. zmax: number;
  66382. subdivisions?: {
  66383. w: number;
  66384. h: number;
  66385. };
  66386. precision?: {
  66387. w: number;
  66388. h: number;
  66389. };
  66390. updatable?: boolean;
  66391. }, scene?: Nullable<Scene>): Mesh;
  66392. /**
  66393. * Creates a ground mesh from a height map
  66394. * * The parameter `url` sets the URL of the height map image resource.
  66395. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66396. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66397. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66398. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66399. * * 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.
  66400. * * 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).
  66401. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66403. * @param name defines the name of the mesh
  66404. * @param url defines the url to the height map
  66405. * @param options defines the options used to create the mesh
  66406. * @param scene defines the hosting scene
  66407. * @returns the ground mesh
  66408. * @see https://doc.babylonjs.com/babylon101/height_map
  66409. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66410. */
  66411. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66412. width?: number;
  66413. height?: number;
  66414. subdivisions?: number;
  66415. minHeight?: number;
  66416. maxHeight?: number;
  66417. colorFilter?: Color3;
  66418. alphaFilter?: number;
  66419. updatable?: boolean;
  66420. onReady?: (mesh: GroundMesh) => void;
  66421. }, scene?: Nullable<Scene>): GroundMesh;
  66422. /**
  66423. * Creates a polygon mesh
  66424. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66425. * * 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
  66426. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66428. * * 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)
  66429. * * Remember you can only change the shape positions, not their number when updating a polygon
  66430. * @param name defines the name of the mesh
  66431. * @param options defines the options used to create the mesh
  66432. * @param scene defines the hosting scene
  66433. * @param earcutInjection can be used to inject your own earcut reference
  66434. * @returns the polygon mesh
  66435. */
  66436. static CreatePolygon(name: string, options: {
  66437. shape: Vector3[];
  66438. holes?: Vector3[][];
  66439. depth?: number;
  66440. faceUV?: Vector4[];
  66441. faceColors?: Color4[];
  66442. updatable?: boolean;
  66443. sideOrientation?: number;
  66444. frontUVs?: Vector4;
  66445. backUVs?: Vector4;
  66446. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66447. /**
  66448. * Creates an extruded polygon mesh, with depth in the Y direction.
  66449. * * 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)
  66450. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66451. * @param name defines the name of the mesh
  66452. * @param options defines the options used to create the mesh
  66453. * @param scene defines the hosting scene
  66454. * @param earcutInjection can be used to inject your own earcut reference
  66455. * @returns the polygon mesh
  66456. */
  66457. static ExtrudePolygon(name: string, options: {
  66458. shape: Vector3[];
  66459. holes?: Vector3[][];
  66460. depth?: number;
  66461. faceUV?: Vector4[];
  66462. faceColors?: Color4[];
  66463. updatable?: boolean;
  66464. sideOrientation?: number;
  66465. frontUVs?: Vector4;
  66466. backUVs?: Vector4;
  66467. wrap?: boolean;
  66468. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66469. /**
  66470. * Creates a tube mesh.
  66471. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66472. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66473. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66474. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66475. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66476. * * 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)
  66477. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66478. * * 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
  66479. * * 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
  66480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66481. * * 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
  66482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66484. * @param name defines the name of the mesh
  66485. * @param options defines the options used to create the mesh
  66486. * @param scene defines the hosting scene
  66487. * @returns the tube mesh
  66488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66489. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66490. */
  66491. static CreateTube(name: string, options: {
  66492. path: Vector3[];
  66493. radius?: number;
  66494. tessellation?: number;
  66495. radiusFunction?: {
  66496. (i: number, distance: number): number;
  66497. };
  66498. cap?: number;
  66499. arc?: number;
  66500. updatable?: boolean;
  66501. sideOrientation?: number;
  66502. frontUVs?: Vector4;
  66503. backUVs?: Vector4;
  66504. instance?: Mesh;
  66505. invertUV?: boolean;
  66506. }, scene?: Nullable<Scene>): Mesh;
  66507. /**
  66508. * Creates a polyhedron mesh
  66509. * * 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
  66510. * * The parameter `size` (positive float, default 1) sets the polygon size
  66511. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66512. * * 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`
  66513. * * 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
  66514. * * 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)`)
  66515. * * 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
  66516. * * 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
  66517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66518. * * 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
  66519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66520. * @param name defines the name of the mesh
  66521. * @param options defines the options used to create the mesh
  66522. * @param scene defines the hosting scene
  66523. * @returns the polyhedron mesh
  66524. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66525. */
  66526. static CreatePolyhedron(name: string, options: {
  66527. type?: number;
  66528. size?: number;
  66529. sizeX?: number;
  66530. sizeY?: number;
  66531. sizeZ?: number;
  66532. custom?: any;
  66533. faceUV?: Vector4[];
  66534. faceColors?: Color4[];
  66535. flat?: boolean;
  66536. updatable?: boolean;
  66537. sideOrientation?: number;
  66538. frontUVs?: Vector4;
  66539. backUVs?: Vector4;
  66540. }, scene?: Nullable<Scene>): Mesh;
  66541. /**
  66542. * Creates a decal mesh.
  66543. * 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
  66544. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66545. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66546. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66547. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66548. * @param name defines the name of the mesh
  66549. * @param sourceMesh defines the mesh where the decal must be applied
  66550. * @param options defines the options used to create the mesh
  66551. * @param scene defines the hosting scene
  66552. * @returns the decal mesh
  66553. * @see https://doc.babylonjs.com/how_to/decals
  66554. */
  66555. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66556. position?: Vector3;
  66557. normal?: Vector3;
  66558. size?: Vector3;
  66559. angle?: number;
  66560. }): Mesh;
  66561. /**
  66562. * Creates a Capsule Mesh
  66563. * @param name defines the name of the mesh.
  66564. * @param options the constructors options used to shape the mesh.
  66565. * @param scene defines the scene the mesh is scoped to.
  66566. * @returns the capsule mesh
  66567. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66568. */
  66569. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66570. }
  66571. }
  66572. declare module BABYLON {
  66573. /**
  66574. * A simplifier interface for future simplification implementations
  66575. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66576. */
  66577. export interface ISimplifier {
  66578. /**
  66579. * Simplification of a given mesh according to the given settings.
  66580. * Since this requires computation, it is assumed that the function runs async.
  66581. * @param settings The settings of the simplification, including quality and distance
  66582. * @param successCallback A callback that will be called after the mesh was simplified.
  66583. * @param errorCallback in case of an error, this callback will be called. optional.
  66584. */
  66585. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66586. }
  66587. /**
  66588. * Expected simplification settings.
  66589. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66590. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66591. */
  66592. export interface ISimplificationSettings {
  66593. /**
  66594. * Gets or sets the expected quality
  66595. */
  66596. quality: number;
  66597. /**
  66598. * Gets or sets the distance when this optimized version should be used
  66599. */
  66600. distance: number;
  66601. /**
  66602. * Gets an already optimized mesh
  66603. */
  66604. optimizeMesh?: boolean;
  66605. }
  66606. /**
  66607. * Class used to specify simplification options
  66608. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66609. */
  66610. export class SimplificationSettings implements ISimplificationSettings {
  66611. /** expected quality */
  66612. quality: number;
  66613. /** distance when this optimized version should be used */
  66614. distance: number;
  66615. /** already optimized mesh */
  66616. optimizeMesh?: boolean | undefined;
  66617. /**
  66618. * Creates a SimplificationSettings
  66619. * @param quality expected quality
  66620. * @param distance distance when this optimized version should be used
  66621. * @param optimizeMesh already optimized mesh
  66622. */
  66623. constructor(
  66624. /** expected quality */
  66625. quality: number,
  66626. /** distance when this optimized version should be used */
  66627. distance: number,
  66628. /** already optimized mesh */
  66629. optimizeMesh?: boolean | undefined);
  66630. }
  66631. /**
  66632. * Interface used to define a simplification task
  66633. */
  66634. export interface ISimplificationTask {
  66635. /**
  66636. * Array of settings
  66637. */
  66638. settings: Array<ISimplificationSettings>;
  66639. /**
  66640. * Simplification type
  66641. */
  66642. simplificationType: SimplificationType;
  66643. /**
  66644. * Mesh to simplify
  66645. */
  66646. mesh: Mesh;
  66647. /**
  66648. * Callback called on success
  66649. */
  66650. successCallback?: () => void;
  66651. /**
  66652. * Defines if parallel processing can be used
  66653. */
  66654. parallelProcessing: boolean;
  66655. }
  66656. /**
  66657. * Queue used to order the simplification tasks
  66658. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66659. */
  66660. export class SimplificationQueue {
  66661. private _simplificationArray;
  66662. /**
  66663. * Gets a boolean indicating that the process is still running
  66664. */
  66665. running: boolean;
  66666. /**
  66667. * Creates a new queue
  66668. */
  66669. constructor();
  66670. /**
  66671. * Adds a new simplification task
  66672. * @param task defines a task to add
  66673. */
  66674. addTask(task: ISimplificationTask): void;
  66675. /**
  66676. * Execute next task
  66677. */
  66678. executeNext(): void;
  66679. /**
  66680. * Execute a simplification task
  66681. * @param task defines the task to run
  66682. */
  66683. runSimplification(task: ISimplificationTask): void;
  66684. private getSimplifier;
  66685. }
  66686. /**
  66687. * The implemented types of simplification
  66688. * At the moment only Quadratic Error Decimation is implemented
  66689. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66690. */
  66691. export enum SimplificationType {
  66692. /** Quadratic error decimation */
  66693. QUADRATIC = 0
  66694. }
  66695. /**
  66696. * An implementation of the Quadratic Error simplification algorithm.
  66697. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66698. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66699. * @author RaananW
  66700. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66701. */
  66702. export class QuadraticErrorSimplification implements ISimplifier {
  66703. private _mesh;
  66704. private triangles;
  66705. private vertices;
  66706. private references;
  66707. private _reconstructedMesh;
  66708. /** Gets or sets the number pf sync interations */
  66709. syncIterations: number;
  66710. /** Gets or sets the aggressiveness of the simplifier */
  66711. aggressiveness: number;
  66712. /** Gets or sets the number of allowed iterations for decimation */
  66713. decimationIterations: number;
  66714. /** Gets or sets the espilon to use for bounding box computation */
  66715. boundingBoxEpsilon: number;
  66716. /**
  66717. * Creates a new QuadraticErrorSimplification
  66718. * @param _mesh defines the target mesh
  66719. */
  66720. constructor(_mesh: Mesh);
  66721. /**
  66722. * Simplification of a given mesh according to the given settings.
  66723. * Since this requires computation, it is assumed that the function runs async.
  66724. * @param settings The settings of the simplification, including quality and distance
  66725. * @param successCallback A callback that will be called after the mesh was simplified.
  66726. */
  66727. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66728. private runDecimation;
  66729. private initWithMesh;
  66730. private init;
  66731. private reconstructMesh;
  66732. private initDecimatedMesh;
  66733. private isFlipped;
  66734. private updateTriangles;
  66735. private identifyBorder;
  66736. private updateMesh;
  66737. private vertexError;
  66738. private calculateError;
  66739. }
  66740. }
  66741. declare module BABYLON {
  66742. interface Scene {
  66743. /** @hidden (Backing field) */
  66744. _simplificationQueue: SimplificationQueue;
  66745. /**
  66746. * Gets or sets the simplification queue attached to the scene
  66747. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66748. */
  66749. simplificationQueue: SimplificationQueue;
  66750. }
  66751. interface Mesh {
  66752. /**
  66753. * Simplify the mesh according to the given array of settings.
  66754. * Function will return immediately and will simplify async
  66755. * @param settings a collection of simplification settings
  66756. * @param parallelProcessing should all levels calculate parallel or one after the other
  66757. * @param simplificationType the type of simplification to run
  66758. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66759. * @returns the current mesh
  66760. */
  66761. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66762. }
  66763. /**
  66764. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66765. * created in a scene
  66766. */
  66767. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66768. /**
  66769. * The component name helpfull to identify the component in the list of scene components.
  66770. */
  66771. readonly name: string;
  66772. /**
  66773. * The scene the component belongs to.
  66774. */
  66775. scene: Scene;
  66776. /**
  66777. * Creates a new instance of the component for the given scene
  66778. * @param scene Defines the scene to register the component in
  66779. */
  66780. constructor(scene: Scene);
  66781. /**
  66782. * Registers the component in a given scene
  66783. */
  66784. register(): void;
  66785. /**
  66786. * Rebuilds the elements related to this component in case of
  66787. * context lost for instance.
  66788. */
  66789. rebuild(): void;
  66790. /**
  66791. * Disposes the component and the associated ressources
  66792. */
  66793. dispose(): void;
  66794. private _beforeCameraUpdate;
  66795. }
  66796. }
  66797. declare module BABYLON {
  66798. interface Mesh {
  66799. /**
  66800. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66801. */
  66802. thinInstanceEnablePicking: boolean;
  66803. /**
  66804. * Creates a new thin instance
  66805. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66806. * @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
  66807. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66808. */
  66809. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66810. /**
  66811. * Adds the transformation (matrix) of the current mesh as a thin instance
  66812. * @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
  66813. * @returns the thin instance index number
  66814. */
  66815. thinInstanceAddSelf(refresh: boolean): number;
  66816. /**
  66817. * Registers a custom attribute to be used with thin instances
  66818. * @param kind name of the attribute
  66819. * @param stride size in floats of the attribute
  66820. */
  66821. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66822. /**
  66823. * Sets the matrix of a thin instance
  66824. * @param index index of the thin instance
  66825. * @param matrix matrix to set
  66826. * @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
  66827. */
  66828. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66829. /**
  66830. * Sets the value of a custom attribute for a thin instance
  66831. * @param kind name of the attribute
  66832. * @param index index of the thin instance
  66833. * @param value value to set
  66834. * @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
  66835. */
  66836. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66837. /**
  66838. * 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.
  66839. */
  66840. thinInstanceCount: number;
  66841. /**
  66842. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66843. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66844. * @param buffer buffer to set
  66845. * @param stride size in floats of each value of the buffer
  66846. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66847. */
  66848. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66849. /**
  66850. * Gets the list of world matrices
  66851. * @return an array containing all the world matrices from the thin instances
  66852. */
  66853. thinInstanceGetWorldMatrices(): Matrix[];
  66854. /**
  66855. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66856. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66857. */
  66858. thinInstanceBufferUpdated(kind: string): void;
  66859. /**
  66860. * Applies a partial update to a buffer directly on the GPU
  66861. * 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
  66862. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66863. * @param data the data to set in the GPU buffer
  66864. * @param offset the offset in the GPU buffer where to update the data
  66865. */
  66866. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66867. /**
  66868. * Refreshes the bounding info, taking into account all the thin instances defined
  66869. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66870. */
  66871. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66872. /** @hidden */
  66873. _thinInstanceInitializeUserStorage(): void;
  66874. /** @hidden */
  66875. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66876. /** @hidden */
  66877. _userThinInstanceBuffersStorage: {
  66878. data: {
  66879. [key: string]: Float32Array;
  66880. };
  66881. sizes: {
  66882. [key: string]: number;
  66883. };
  66884. vertexBuffers: {
  66885. [key: string]: Nullable<VertexBuffer>;
  66886. };
  66887. strides: {
  66888. [key: string]: number;
  66889. };
  66890. };
  66891. }
  66892. }
  66893. declare module BABYLON {
  66894. /**
  66895. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66896. */
  66897. export interface INavigationEnginePlugin {
  66898. /**
  66899. * plugin name
  66900. */
  66901. name: string;
  66902. /**
  66903. * Creates a navigation mesh
  66904. * @param meshes array of all the geometry used to compute the navigatio mesh
  66905. * @param parameters bunch of parameters used to filter geometry
  66906. */
  66907. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66908. /**
  66909. * Create a navigation mesh debug mesh
  66910. * @param scene is where the mesh will be added
  66911. * @returns debug display mesh
  66912. */
  66913. createDebugNavMesh(scene: Scene): Mesh;
  66914. /**
  66915. * Get a navigation mesh constrained position, closest to the parameter position
  66916. * @param position world position
  66917. * @returns the closest point to position constrained by the navigation mesh
  66918. */
  66919. getClosestPoint(position: Vector3): Vector3;
  66920. /**
  66921. * Get a navigation mesh constrained position, closest to the parameter position
  66922. * @param position world position
  66923. * @param result output the closest point to position constrained by the navigation mesh
  66924. */
  66925. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66926. /**
  66927. * Get a navigation mesh constrained position, within a particular radius
  66928. * @param position world position
  66929. * @param maxRadius the maximum distance to the constrained world position
  66930. * @returns the closest point to position constrained by the navigation mesh
  66931. */
  66932. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66933. /**
  66934. * Get a navigation mesh constrained position, within a particular radius
  66935. * @param position world position
  66936. * @param maxRadius the maximum distance to the constrained world position
  66937. * @param result output the closest point to position constrained by the navigation mesh
  66938. */
  66939. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66940. /**
  66941. * Compute the final position from a segment made of destination-position
  66942. * @param position world position
  66943. * @param destination world position
  66944. * @returns the resulting point along the navmesh
  66945. */
  66946. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66947. /**
  66948. * Compute the final position from a segment made of destination-position
  66949. * @param position world position
  66950. * @param destination world position
  66951. * @param result output the resulting point along the navmesh
  66952. */
  66953. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66954. /**
  66955. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66956. * @param start world position
  66957. * @param end world position
  66958. * @returns array containing world position composing the path
  66959. */
  66960. computePath(start: Vector3, end: Vector3): Vector3[];
  66961. /**
  66962. * If this plugin is supported
  66963. * @returns true if plugin is supported
  66964. */
  66965. isSupported(): boolean;
  66966. /**
  66967. * Create a new Crowd so you can add agents
  66968. * @param maxAgents the maximum agent count in the crowd
  66969. * @param maxAgentRadius the maximum radius an agent can have
  66970. * @param scene to attach the crowd to
  66971. * @returns the crowd you can add agents to
  66972. */
  66973. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66974. /**
  66975. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66976. * The queries will try to find a solution within those bounds
  66977. * default is (1,1,1)
  66978. * @param extent x,y,z value that define the extent around the queries point of reference
  66979. */
  66980. setDefaultQueryExtent(extent: Vector3): void;
  66981. /**
  66982. * Get the Bounding box extent specified by setDefaultQueryExtent
  66983. * @returns the box extent values
  66984. */
  66985. getDefaultQueryExtent(): Vector3;
  66986. /**
  66987. * build the navmesh from a previously saved state using getNavmeshData
  66988. * @param data the Uint8Array returned by getNavmeshData
  66989. */
  66990. buildFromNavmeshData(data: Uint8Array): void;
  66991. /**
  66992. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66993. * @returns data the Uint8Array that can be saved and reused
  66994. */
  66995. getNavmeshData(): Uint8Array;
  66996. /**
  66997. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66998. * @param result output the box extent values
  66999. */
  67000. getDefaultQueryExtentToRef(result: Vector3): void;
  67001. /**
  67002. * Release all resources
  67003. */
  67004. dispose(): void;
  67005. }
  67006. /**
  67007. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67008. */
  67009. export interface ICrowd {
  67010. /**
  67011. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67012. * You can attach anything to that node. The node position is updated in the scene update tick.
  67013. * @param pos world position that will be constrained by the navigation mesh
  67014. * @param parameters agent parameters
  67015. * @param transform hooked to the agent that will be update by the scene
  67016. * @returns agent index
  67017. */
  67018. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67019. /**
  67020. * Returns the agent position in world space
  67021. * @param index agent index returned by addAgent
  67022. * @returns world space position
  67023. */
  67024. getAgentPosition(index: number): Vector3;
  67025. /**
  67026. * Gets the agent position result in world space
  67027. * @param index agent index returned by addAgent
  67028. * @param result output world space position
  67029. */
  67030. getAgentPositionToRef(index: number, result: Vector3): void;
  67031. /**
  67032. * Gets the agent velocity in world space
  67033. * @param index agent index returned by addAgent
  67034. * @returns world space velocity
  67035. */
  67036. getAgentVelocity(index: number): Vector3;
  67037. /**
  67038. * Gets the agent velocity result in world space
  67039. * @param index agent index returned by addAgent
  67040. * @param result output world space velocity
  67041. */
  67042. getAgentVelocityToRef(index: number, result: Vector3): void;
  67043. /**
  67044. * remove a particular agent previously created
  67045. * @param index agent index returned by addAgent
  67046. */
  67047. removeAgent(index: number): void;
  67048. /**
  67049. * get the list of all agents attached to this crowd
  67050. * @returns list of agent indices
  67051. */
  67052. getAgents(): number[];
  67053. /**
  67054. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67055. * @param deltaTime in seconds
  67056. */
  67057. update(deltaTime: number): void;
  67058. /**
  67059. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67060. * @param index agent index returned by addAgent
  67061. * @param destination targeted world position
  67062. */
  67063. agentGoto(index: number, destination: Vector3): void;
  67064. /**
  67065. * Teleport the agent to a new position
  67066. * @param index agent index returned by addAgent
  67067. * @param destination targeted world position
  67068. */
  67069. agentTeleport(index: number, destination: Vector3): void;
  67070. /**
  67071. * Update agent parameters
  67072. * @param index agent index returned by addAgent
  67073. * @param parameters agent parameters
  67074. */
  67075. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67076. /**
  67077. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67078. * The queries will try to find a solution within those bounds
  67079. * default is (1,1,1)
  67080. * @param extent x,y,z value that define the extent around the queries point of reference
  67081. */
  67082. setDefaultQueryExtent(extent: Vector3): void;
  67083. /**
  67084. * Get the Bounding box extent specified by setDefaultQueryExtent
  67085. * @returns the box extent values
  67086. */
  67087. getDefaultQueryExtent(): Vector3;
  67088. /**
  67089. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67090. * @param result output the box extent values
  67091. */
  67092. getDefaultQueryExtentToRef(result: Vector3): void;
  67093. /**
  67094. * Release all resources
  67095. */
  67096. dispose(): void;
  67097. }
  67098. /**
  67099. * Configures an agent
  67100. */
  67101. export interface IAgentParameters {
  67102. /**
  67103. * Agent radius. [Limit: >= 0]
  67104. */
  67105. radius: number;
  67106. /**
  67107. * Agent height. [Limit: > 0]
  67108. */
  67109. height: number;
  67110. /**
  67111. * Maximum allowed acceleration. [Limit: >= 0]
  67112. */
  67113. maxAcceleration: number;
  67114. /**
  67115. * Maximum allowed speed. [Limit: >= 0]
  67116. */
  67117. maxSpeed: number;
  67118. /**
  67119. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67120. */
  67121. collisionQueryRange: number;
  67122. /**
  67123. * The path visibility optimization range. [Limit: > 0]
  67124. */
  67125. pathOptimizationRange: number;
  67126. /**
  67127. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67128. */
  67129. separationWeight: number;
  67130. }
  67131. /**
  67132. * Configures the navigation mesh creation
  67133. */
  67134. export interface INavMeshParameters {
  67135. /**
  67136. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67137. */
  67138. cs: number;
  67139. /**
  67140. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67141. */
  67142. ch: number;
  67143. /**
  67144. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67145. */
  67146. walkableSlopeAngle: number;
  67147. /**
  67148. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67149. * be considered walkable. [Limit: >= 3] [Units: vx]
  67150. */
  67151. walkableHeight: number;
  67152. /**
  67153. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67154. */
  67155. walkableClimb: number;
  67156. /**
  67157. * The distance to erode/shrink the walkable area of the heightfield away from
  67158. * obstructions. [Limit: >=0] [Units: vx]
  67159. */
  67160. walkableRadius: number;
  67161. /**
  67162. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67163. */
  67164. maxEdgeLen: number;
  67165. /**
  67166. * The maximum distance a simplfied contour's border edges should deviate
  67167. * the original raw contour. [Limit: >=0] [Units: vx]
  67168. */
  67169. maxSimplificationError: number;
  67170. /**
  67171. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67172. */
  67173. minRegionArea: number;
  67174. /**
  67175. * Any regions with a span count smaller than this value will, if possible,
  67176. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67177. */
  67178. mergeRegionArea: number;
  67179. /**
  67180. * The maximum number of vertices allowed for polygons generated during the
  67181. * contour to polygon conversion process. [Limit: >= 3]
  67182. */
  67183. maxVertsPerPoly: number;
  67184. /**
  67185. * Sets the sampling distance to use when generating the detail mesh.
  67186. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67187. */
  67188. detailSampleDist: number;
  67189. /**
  67190. * The maximum distance the detail mesh surface should deviate from heightfield
  67191. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67192. */
  67193. detailSampleMaxError: number;
  67194. }
  67195. }
  67196. declare module BABYLON {
  67197. /**
  67198. * RecastJS navigation plugin
  67199. */
  67200. export class RecastJSPlugin implements INavigationEnginePlugin {
  67201. /**
  67202. * Reference to the Recast library
  67203. */
  67204. bjsRECAST: any;
  67205. /**
  67206. * plugin name
  67207. */
  67208. name: string;
  67209. /**
  67210. * the first navmesh created. We might extend this to support multiple navmeshes
  67211. */
  67212. navMesh: any;
  67213. /**
  67214. * Initializes the recastJS plugin
  67215. * @param recastInjection can be used to inject your own recast reference
  67216. */
  67217. constructor(recastInjection?: any);
  67218. /**
  67219. * Creates a navigation mesh
  67220. * @param meshes array of all the geometry used to compute the navigatio mesh
  67221. * @param parameters bunch of parameters used to filter geometry
  67222. */
  67223. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67224. /**
  67225. * Create a navigation mesh debug mesh
  67226. * @param scene is where the mesh will be added
  67227. * @returns debug display mesh
  67228. */
  67229. createDebugNavMesh(scene: Scene): Mesh;
  67230. /**
  67231. * Get a navigation mesh constrained position, closest to the parameter position
  67232. * @param position world position
  67233. * @returns the closest point to position constrained by the navigation mesh
  67234. */
  67235. getClosestPoint(position: Vector3): Vector3;
  67236. /**
  67237. * Get a navigation mesh constrained position, closest to the parameter position
  67238. * @param position world position
  67239. * @param result output the closest point to position constrained by the navigation mesh
  67240. */
  67241. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67242. /**
  67243. * Get a navigation mesh constrained position, within a particular radius
  67244. * @param position world position
  67245. * @param maxRadius the maximum distance to the constrained world position
  67246. * @returns the closest point to position constrained by the navigation mesh
  67247. */
  67248. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67249. /**
  67250. * Get a navigation mesh constrained position, within a particular radius
  67251. * @param position world position
  67252. * @param maxRadius the maximum distance to the constrained world position
  67253. * @param result output the closest point to position constrained by the navigation mesh
  67254. */
  67255. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67256. /**
  67257. * Compute the final position from a segment made of destination-position
  67258. * @param position world position
  67259. * @param destination world position
  67260. * @returns the resulting point along the navmesh
  67261. */
  67262. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67263. /**
  67264. * Compute the final position from a segment made of destination-position
  67265. * @param position world position
  67266. * @param destination world position
  67267. * @param result output the resulting point along the navmesh
  67268. */
  67269. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67270. /**
  67271. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67272. * @param start world position
  67273. * @param end world position
  67274. * @returns array containing world position composing the path
  67275. */
  67276. computePath(start: Vector3, end: Vector3): Vector3[];
  67277. /**
  67278. * Create a new Crowd so you can add agents
  67279. * @param maxAgents the maximum agent count in the crowd
  67280. * @param maxAgentRadius the maximum radius an agent can have
  67281. * @param scene to attach the crowd to
  67282. * @returns the crowd you can add agents to
  67283. */
  67284. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67285. /**
  67286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67287. * The queries will try to find a solution within those bounds
  67288. * default is (1,1,1)
  67289. * @param extent x,y,z value that define the extent around the queries point of reference
  67290. */
  67291. setDefaultQueryExtent(extent: Vector3): void;
  67292. /**
  67293. * Get the Bounding box extent specified by setDefaultQueryExtent
  67294. * @returns the box extent values
  67295. */
  67296. getDefaultQueryExtent(): Vector3;
  67297. /**
  67298. * build the navmesh from a previously saved state using getNavmeshData
  67299. * @param data the Uint8Array returned by getNavmeshData
  67300. */
  67301. buildFromNavmeshData(data: Uint8Array): void;
  67302. /**
  67303. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67304. * @returns data the Uint8Array that can be saved and reused
  67305. */
  67306. getNavmeshData(): Uint8Array;
  67307. /**
  67308. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67309. * @param result output the box extent values
  67310. */
  67311. getDefaultQueryExtentToRef(result: Vector3): void;
  67312. /**
  67313. * Disposes
  67314. */
  67315. dispose(): void;
  67316. /**
  67317. * If this plugin is supported
  67318. * @returns true if plugin is supported
  67319. */
  67320. isSupported(): boolean;
  67321. }
  67322. /**
  67323. * Recast detour crowd implementation
  67324. */
  67325. export class RecastJSCrowd implements ICrowd {
  67326. /**
  67327. * Recast/detour plugin
  67328. */
  67329. bjsRECASTPlugin: RecastJSPlugin;
  67330. /**
  67331. * Link to the detour crowd
  67332. */
  67333. recastCrowd: any;
  67334. /**
  67335. * One transform per agent
  67336. */
  67337. transforms: TransformNode[];
  67338. /**
  67339. * All agents created
  67340. */
  67341. agents: number[];
  67342. /**
  67343. * Link to the scene is kept to unregister the crowd from the scene
  67344. */
  67345. private _scene;
  67346. /**
  67347. * Observer for crowd updates
  67348. */
  67349. private _onBeforeAnimationsObserver;
  67350. /**
  67351. * Constructor
  67352. * @param plugin recastJS plugin
  67353. * @param maxAgents the maximum agent count in the crowd
  67354. * @param maxAgentRadius the maximum radius an agent can have
  67355. * @param scene to attach the crowd to
  67356. * @returns the crowd you can add agents to
  67357. */
  67358. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67359. /**
  67360. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67361. * You can attach anything to that node. The node position is updated in the scene update tick.
  67362. * @param pos world position that will be constrained by the navigation mesh
  67363. * @param parameters agent parameters
  67364. * @param transform hooked to the agent that will be update by the scene
  67365. * @returns agent index
  67366. */
  67367. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67368. /**
  67369. * Returns the agent position in world space
  67370. * @param index agent index returned by addAgent
  67371. * @returns world space position
  67372. */
  67373. getAgentPosition(index: number): Vector3;
  67374. /**
  67375. * Returns the agent position result in world space
  67376. * @param index agent index returned by addAgent
  67377. * @param result output world space position
  67378. */
  67379. getAgentPositionToRef(index: number, result: Vector3): void;
  67380. /**
  67381. * Returns the agent velocity in world space
  67382. * @param index agent index returned by addAgent
  67383. * @returns world space velocity
  67384. */
  67385. getAgentVelocity(index: number): Vector3;
  67386. /**
  67387. * Returns the agent velocity result in world space
  67388. * @param index agent index returned by addAgent
  67389. * @param result output world space velocity
  67390. */
  67391. getAgentVelocityToRef(index: number, result: Vector3): void;
  67392. /**
  67393. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67394. * @param index agent index returned by addAgent
  67395. * @param destination targeted world position
  67396. */
  67397. agentGoto(index: number, destination: Vector3): void;
  67398. /**
  67399. * Teleport the agent to a new position
  67400. * @param index agent index returned by addAgent
  67401. * @param destination targeted world position
  67402. */
  67403. agentTeleport(index: number, destination: Vector3): void;
  67404. /**
  67405. * Update agent parameters
  67406. * @param index agent index returned by addAgent
  67407. * @param parameters agent parameters
  67408. */
  67409. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67410. /**
  67411. * remove a particular agent previously created
  67412. * @param index agent index returned by addAgent
  67413. */
  67414. removeAgent(index: number): void;
  67415. /**
  67416. * get the list of all agents attached to this crowd
  67417. * @returns list of agent indices
  67418. */
  67419. getAgents(): number[];
  67420. /**
  67421. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67422. * @param deltaTime in seconds
  67423. */
  67424. update(deltaTime: number): void;
  67425. /**
  67426. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67427. * The queries will try to find a solution within those bounds
  67428. * default is (1,1,1)
  67429. * @param extent x,y,z value that define the extent around the queries point of reference
  67430. */
  67431. setDefaultQueryExtent(extent: Vector3): void;
  67432. /**
  67433. * Get the Bounding box extent specified by setDefaultQueryExtent
  67434. * @returns the box extent values
  67435. */
  67436. getDefaultQueryExtent(): Vector3;
  67437. /**
  67438. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67439. * @param result output the box extent values
  67440. */
  67441. getDefaultQueryExtentToRef(result: Vector3): void;
  67442. /**
  67443. * Release all resources
  67444. */
  67445. dispose(): void;
  67446. }
  67447. }
  67448. declare module BABYLON {
  67449. /**
  67450. * Class used to enable access to IndexedDB
  67451. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67452. */
  67453. export class Database implements IOfflineProvider {
  67454. private _callbackManifestChecked;
  67455. private _currentSceneUrl;
  67456. private _db;
  67457. private _enableSceneOffline;
  67458. private _enableTexturesOffline;
  67459. private _manifestVersionFound;
  67460. private _mustUpdateRessources;
  67461. private _hasReachedQuota;
  67462. private _isSupported;
  67463. private _idbFactory;
  67464. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67465. private static IsUASupportingBlobStorage;
  67466. /**
  67467. * Gets a boolean indicating if Database storate is enabled (off by default)
  67468. */
  67469. static IDBStorageEnabled: boolean;
  67470. /**
  67471. * Gets a boolean indicating if scene must be saved in the database
  67472. */
  67473. get enableSceneOffline(): boolean;
  67474. /**
  67475. * Gets a boolean indicating if textures must be saved in the database
  67476. */
  67477. get enableTexturesOffline(): boolean;
  67478. /**
  67479. * Creates a new Database
  67480. * @param urlToScene defines the url to load the scene
  67481. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67482. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67483. */
  67484. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67485. private static _ParseURL;
  67486. private static _ReturnFullUrlLocation;
  67487. private _checkManifestFile;
  67488. /**
  67489. * Open the database and make it available
  67490. * @param successCallback defines the callback to call on success
  67491. * @param errorCallback defines the callback to call on error
  67492. */
  67493. open(successCallback: () => void, errorCallback: () => void): void;
  67494. /**
  67495. * Loads an image from the database
  67496. * @param url defines the url to load from
  67497. * @param image defines the target DOM image
  67498. */
  67499. loadImage(url: string, image: HTMLImageElement): void;
  67500. private _loadImageFromDBAsync;
  67501. private _saveImageIntoDBAsync;
  67502. private _checkVersionFromDB;
  67503. private _loadVersionFromDBAsync;
  67504. private _saveVersionIntoDBAsync;
  67505. /**
  67506. * Loads a file from database
  67507. * @param url defines the URL to load from
  67508. * @param sceneLoaded defines a callback to call on success
  67509. * @param progressCallBack defines a callback to call when progress changed
  67510. * @param errorCallback defines a callback to call on error
  67511. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67512. */
  67513. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67514. private _loadFileAsync;
  67515. private _saveFileAsync;
  67516. /**
  67517. * Validates if xhr data is correct
  67518. * @param xhr defines the request to validate
  67519. * @param dataType defines the expected data type
  67520. * @returns true if data is correct
  67521. */
  67522. private static _ValidateXHRData;
  67523. }
  67524. }
  67525. declare module BABYLON {
  67526. /** @hidden */
  67527. export var gpuUpdateParticlesPixelShader: {
  67528. name: string;
  67529. shader: string;
  67530. };
  67531. }
  67532. declare module BABYLON {
  67533. /** @hidden */
  67534. export var gpuUpdateParticlesVertexShader: {
  67535. name: string;
  67536. shader: string;
  67537. };
  67538. }
  67539. declare module BABYLON {
  67540. /** @hidden */
  67541. export var clipPlaneFragmentDeclaration2: {
  67542. name: string;
  67543. shader: string;
  67544. };
  67545. }
  67546. declare module BABYLON {
  67547. /** @hidden */
  67548. export var gpuRenderParticlesPixelShader: {
  67549. name: string;
  67550. shader: string;
  67551. };
  67552. }
  67553. declare module BABYLON {
  67554. /** @hidden */
  67555. export var clipPlaneVertexDeclaration2: {
  67556. name: string;
  67557. shader: string;
  67558. };
  67559. }
  67560. declare module BABYLON {
  67561. /** @hidden */
  67562. export var gpuRenderParticlesVertexShader: {
  67563. name: string;
  67564. shader: string;
  67565. };
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * This represents a GPU particle system in Babylon
  67570. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67571. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67572. */
  67573. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67574. /**
  67575. * The layer mask we are rendering the particles through.
  67576. */
  67577. layerMask: number;
  67578. private _capacity;
  67579. private _activeCount;
  67580. private _currentActiveCount;
  67581. private _accumulatedCount;
  67582. private _renderEffect;
  67583. private _updateEffect;
  67584. private _buffer0;
  67585. private _buffer1;
  67586. private _spriteBuffer;
  67587. private _updateVAO;
  67588. private _renderVAO;
  67589. private _targetIndex;
  67590. private _sourceBuffer;
  67591. private _targetBuffer;
  67592. private _currentRenderId;
  67593. private _started;
  67594. private _stopped;
  67595. private _timeDelta;
  67596. private _randomTexture;
  67597. private _randomTexture2;
  67598. private _attributesStrideSize;
  67599. private _updateEffectOptions;
  67600. private _randomTextureSize;
  67601. private _actualFrame;
  67602. private _customEffect;
  67603. private readonly _rawTextureWidth;
  67604. /**
  67605. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67606. */
  67607. static get IsSupported(): boolean;
  67608. /**
  67609. * An event triggered when the system is disposed.
  67610. */
  67611. onDisposeObservable: Observable<IParticleSystem>;
  67612. /**
  67613. * Gets the maximum number of particles active at the same time.
  67614. * @returns The max number of active particles.
  67615. */
  67616. getCapacity(): number;
  67617. /**
  67618. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67619. * to override the particles.
  67620. */
  67621. forceDepthWrite: boolean;
  67622. /**
  67623. * Gets or set the number of active particles
  67624. */
  67625. get activeParticleCount(): number;
  67626. set activeParticleCount(value: number);
  67627. private _preWarmDone;
  67628. /**
  67629. * Specifies if the particles are updated in emitter local space or world space.
  67630. */
  67631. isLocal: boolean;
  67632. /** Gets or sets a matrix to use to compute projection */
  67633. defaultProjectionMatrix: Matrix;
  67634. /**
  67635. * Is this system ready to be used/rendered
  67636. * @return true if the system is ready
  67637. */
  67638. isReady(): boolean;
  67639. /**
  67640. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67641. * @returns True if it has been started, otherwise false.
  67642. */
  67643. isStarted(): boolean;
  67644. /**
  67645. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67646. * @returns True if it has been stopped, otherwise false.
  67647. */
  67648. isStopped(): boolean;
  67649. /**
  67650. * Gets a boolean indicating that the system is stopping
  67651. * @returns true if the system is currently stopping
  67652. */
  67653. isStopping(): boolean;
  67654. /**
  67655. * Gets the number of particles active at the same time.
  67656. * @returns The number of active particles.
  67657. */
  67658. getActiveCount(): number;
  67659. /**
  67660. * Starts the particle system and begins to emit
  67661. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67662. */
  67663. start(delay?: number): void;
  67664. /**
  67665. * Stops the particle system.
  67666. */
  67667. stop(): void;
  67668. /**
  67669. * Remove all active particles
  67670. */
  67671. reset(): void;
  67672. /**
  67673. * Returns the string "GPUParticleSystem"
  67674. * @returns a string containing the class name
  67675. */
  67676. getClassName(): string;
  67677. /**
  67678. * Gets the custom effect used to render the particles
  67679. * @param blendMode Blend mode for which the effect should be retrieved
  67680. * @returns The effect
  67681. */
  67682. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67683. /**
  67684. * Sets the custom effect used to render the particles
  67685. * @param effect The effect to set
  67686. * @param blendMode Blend mode for which the effect should be set
  67687. */
  67688. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67689. /** @hidden */
  67690. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67691. /**
  67692. * Observable that will be called just before the particles are drawn
  67693. */
  67694. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67695. /**
  67696. * Gets the name of the particle vertex shader
  67697. */
  67698. get vertexShaderName(): string;
  67699. private _colorGradientsTexture;
  67700. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67701. /**
  67702. * Adds a new color gradient
  67703. * @param gradient defines the gradient to use (between 0 and 1)
  67704. * @param color1 defines the color to affect to the specified gradient
  67705. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67706. * @returns the current particle system
  67707. */
  67708. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67709. private _refreshColorGradient;
  67710. /** Force the system to rebuild all gradients that need to be resync */
  67711. forceRefreshGradients(): void;
  67712. /**
  67713. * Remove a specific color gradient
  67714. * @param gradient defines the gradient to remove
  67715. * @returns the current particle system
  67716. */
  67717. removeColorGradient(gradient: number): GPUParticleSystem;
  67718. private _angularSpeedGradientsTexture;
  67719. private _sizeGradientsTexture;
  67720. private _velocityGradientsTexture;
  67721. private _limitVelocityGradientsTexture;
  67722. private _dragGradientsTexture;
  67723. private _addFactorGradient;
  67724. /**
  67725. * Adds a new size gradient
  67726. * @param gradient defines the gradient to use (between 0 and 1)
  67727. * @param factor defines the size factor to affect to the specified gradient
  67728. * @returns the current particle system
  67729. */
  67730. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67731. /**
  67732. * Remove a specific size gradient
  67733. * @param gradient defines the gradient to remove
  67734. * @returns the current particle system
  67735. */
  67736. removeSizeGradient(gradient: number): GPUParticleSystem;
  67737. private _refreshFactorGradient;
  67738. /**
  67739. * Adds a new angular speed gradient
  67740. * @param gradient defines the gradient to use (between 0 and 1)
  67741. * @param factor defines the angular speed to affect to the specified gradient
  67742. * @returns the current particle system
  67743. */
  67744. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67745. /**
  67746. * Remove a specific angular speed gradient
  67747. * @param gradient defines the gradient to remove
  67748. * @returns the current particle system
  67749. */
  67750. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67751. /**
  67752. * Adds a new velocity gradient
  67753. * @param gradient defines the gradient to use (between 0 and 1)
  67754. * @param factor defines the velocity to affect to the specified gradient
  67755. * @returns the current particle system
  67756. */
  67757. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67758. /**
  67759. * Remove a specific velocity gradient
  67760. * @param gradient defines the gradient to remove
  67761. * @returns the current particle system
  67762. */
  67763. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67764. /**
  67765. * Adds a new limit velocity gradient
  67766. * @param gradient defines the gradient to use (between 0 and 1)
  67767. * @param factor defines the limit velocity value to affect to the specified gradient
  67768. * @returns the current particle system
  67769. */
  67770. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67771. /**
  67772. * Remove a specific limit velocity gradient
  67773. * @param gradient defines the gradient to remove
  67774. * @returns the current particle system
  67775. */
  67776. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67777. /**
  67778. * Adds a new drag gradient
  67779. * @param gradient defines the gradient to use (between 0 and 1)
  67780. * @param factor defines the drag value to affect to the specified gradient
  67781. * @returns the current particle system
  67782. */
  67783. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67784. /**
  67785. * Remove a specific drag gradient
  67786. * @param gradient defines the gradient to remove
  67787. * @returns the current particle system
  67788. */
  67789. removeDragGradient(gradient: number): GPUParticleSystem;
  67790. /**
  67791. * Not supported by GPUParticleSystem
  67792. * @param gradient defines the gradient to use (between 0 and 1)
  67793. * @param factor defines the emit rate value to affect to the specified gradient
  67794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67795. * @returns the current particle system
  67796. */
  67797. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67798. /**
  67799. * Not supported by GPUParticleSystem
  67800. * @param gradient defines the gradient to remove
  67801. * @returns the current particle system
  67802. */
  67803. removeEmitRateGradient(gradient: number): IParticleSystem;
  67804. /**
  67805. * Not supported by GPUParticleSystem
  67806. * @param gradient defines the gradient to use (between 0 and 1)
  67807. * @param factor defines the start size value to affect to the specified gradient
  67808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67809. * @returns the current particle system
  67810. */
  67811. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67812. /**
  67813. * Not supported by GPUParticleSystem
  67814. * @param gradient defines the gradient to remove
  67815. * @returns the current particle system
  67816. */
  67817. removeStartSizeGradient(gradient: number): IParticleSystem;
  67818. /**
  67819. * Not supported by GPUParticleSystem
  67820. * @param gradient defines the gradient to use (between 0 and 1)
  67821. * @param min defines the color remap minimal range
  67822. * @param max defines the color remap maximal range
  67823. * @returns the current particle system
  67824. */
  67825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67826. /**
  67827. * Not supported by GPUParticleSystem
  67828. * @param gradient defines the gradient to remove
  67829. * @returns the current particle system
  67830. */
  67831. removeColorRemapGradient(): IParticleSystem;
  67832. /**
  67833. * Not supported by GPUParticleSystem
  67834. * @param gradient defines the gradient to use (between 0 and 1)
  67835. * @param min defines the alpha remap minimal range
  67836. * @param max defines the alpha remap maximal range
  67837. * @returns the current particle system
  67838. */
  67839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67840. /**
  67841. * Not supported by GPUParticleSystem
  67842. * @param gradient defines the gradient to remove
  67843. * @returns the current particle system
  67844. */
  67845. removeAlphaRemapGradient(): IParticleSystem;
  67846. /**
  67847. * Not supported by GPUParticleSystem
  67848. * @param gradient defines the gradient to use (between 0 and 1)
  67849. * @param color defines the color to affect to the specified gradient
  67850. * @returns the current particle system
  67851. */
  67852. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67853. /**
  67854. * Not supported by GPUParticleSystem
  67855. * @param gradient defines the gradient to remove
  67856. * @returns the current particle system
  67857. */
  67858. removeRampGradient(): IParticleSystem;
  67859. /**
  67860. * Not supported by GPUParticleSystem
  67861. * @returns the list of ramp gradients
  67862. */
  67863. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67864. /**
  67865. * Not supported by GPUParticleSystem
  67866. * Gets or sets a boolean indicating that ramp gradients must be used
  67867. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67868. */
  67869. get useRampGradients(): boolean;
  67870. set useRampGradients(value: boolean);
  67871. /**
  67872. * Not supported by GPUParticleSystem
  67873. * @param gradient defines the gradient to use (between 0 and 1)
  67874. * @param factor defines the life time factor to affect to the specified gradient
  67875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67876. * @returns the current particle system
  67877. */
  67878. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67879. /**
  67880. * Not supported by GPUParticleSystem
  67881. * @param gradient defines the gradient to remove
  67882. * @returns the current particle system
  67883. */
  67884. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67885. /**
  67886. * Instantiates a GPU particle system.
  67887. * 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.
  67888. * @param name The name of the particle system
  67889. * @param options The options used to create the system
  67890. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67891. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67892. * @param customEffect a custom effect used to change the way particles are rendered by default
  67893. */
  67894. constructor(name: string, options: Partial<{
  67895. capacity: number;
  67896. randomTextureSize: number;
  67897. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67898. protected _reset(): void;
  67899. private _createUpdateVAO;
  67900. private _createRenderVAO;
  67901. private _initialize;
  67902. /** @hidden */
  67903. _recreateUpdateEffect(): void;
  67904. private _getEffect;
  67905. /**
  67906. * Fill the defines array according to the current settings of the particle system
  67907. * @param defines Array to be updated
  67908. * @param blendMode blend mode to take into account when updating the array
  67909. */
  67910. fillDefines(defines: Array<string>, blendMode?: number): void;
  67911. /**
  67912. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67913. * @param uniforms Uniforms array to fill
  67914. * @param attributes Attributes array to fill
  67915. * @param samplers Samplers array to fill
  67916. */
  67917. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67918. /** @hidden */
  67919. _recreateRenderEffect(): Effect;
  67920. /**
  67921. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67922. * @param preWarm defines if we are in the pre-warmimg phase
  67923. */
  67924. animate(preWarm?: boolean): void;
  67925. private _createFactorGradientTexture;
  67926. private _createSizeGradientTexture;
  67927. private _createAngularSpeedGradientTexture;
  67928. private _createVelocityGradientTexture;
  67929. private _createLimitVelocityGradientTexture;
  67930. private _createDragGradientTexture;
  67931. private _createColorGradientTexture;
  67932. /**
  67933. * Renders the particle system in its current state
  67934. * @param preWarm defines if the system should only update the particles but not render them
  67935. * @returns the current number of particles
  67936. */
  67937. render(preWarm?: boolean): number;
  67938. /**
  67939. * Rebuilds the particle system
  67940. */
  67941. rebuild(): void;
  67942. private _releaseBuffers;
  67943. private _releaseVAOs;
  67944. /**
  67945. * Disposes the particle system and free the associated resources
  67946. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67947. */
  67948. dispose(disposeTexture?: boolean): void;
  67949. /**
  67950. * Clones the particle system.
  67951. * @param name The name of the cloned object
  67952. * @param newEmitter The new emitter to use
  67953. * @returns the cloned particle system
  67954. */
  67955. clone(name: string, newEmitter: any): GPUParticleSystem;
  67956. /**
  67957. * Serializes the particle system to a JSON object
  67958. * @param serializeTexture defines if the texture must be serialized as well
  67959. * @returns the JSON object
  67960. */
  67961. serialize(serializeTexture?: boolean): any;
  67962. /**
  67963. * Parses a JSON object to create a GPU particle system.
  67964. * @param parsedParticleSystem The JSON object to parse
  67965. * @param sceneOrEngine The scene or the engine to create the particle system in
  67966. * @param rootUrl The root url to use to load external dependencies like texture
  67967. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67968. * @returns the parsed GPU particle system
  67969. */
  67970. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67971. }
  67972. }
  67973. declare module BABYLON {
  67974. /**
  67975. * Represents a set of particle systems working together to create a specific effect
  67976. */
  67977. export class ParticleSystemSet implements IDisposable {
  67978. /**
  67979. * Gets or sets base Assets URL
  67980. */
  67981. static BaseAssetsUrl: string;
  67982. private _emitterCreationOptions;
  67983. private _emitterNode;
  67984. /**
  67985. * Gets the particle system list
  67986. */
  67987. systems: IParticleSystem[];
  67988. /**
  67989. * Gets the emitter node used with this set
  67990. */
  67991. get emitterNode(): Nullable<TransformNode>;
  67992. /**
  67993. * Creates a new emitter mesh as a sphere
  67994. * @param options defines the options used to create the sphere
  67995. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67996. * @param scene defines the hosting scene
  67997. */
  67998. setEmitterAsSphere(options: {
  67999. diameter: number;
  68000. segments: number;
  68001. color: Color3;
  68002. }, renderingGroupId: number, scene: Scene): void;
  68003. /**
  68004. * Starts all particle systems of the set
  68005. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68006. */
  68007. start(emitter?: AbstractMesh): void;
  68008. /**
  68009. * Release all associated resources
  68010. */
  68011. dispose(): void;
  68012. /**
  68013. * Serialize the set into a JSON compatible object
  68014. * @param serializeTexture defines if the texture must be serialized as well
  68015. * @returns a JSON compatible representation of the set
  68016. */
  68017. serialize(serializeTexture?: boolean): any;
  68018. /**
  68019. * Parse a new ParticleSystemSet from a serialized source
  68020. * @param data defines a JSON compatible representation of the set
  68021. * @param scene defines the hosting scene
  68022. * @param gpu defines if we want GPU particles or CPU particles
  68023. * @returns a new ParticleSystemSet
  68024. */
  68025. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68026. }
  68027. }
  68028. declare module BABYLON {
  68029. /**
  68030. * This class is made for on one-liner static method to help creating particle system set.
  68031. */
  68032. export class ParticleHelper {
  68033. /**
  68034. * Gets or sets base Assets URL
  68035. */
  68036. static BaseAssetsUrl: string;
  68037. /** Define the Url to load snippets */
  68038. static SnippetUrl: string;
  68039. /**
  68040. * Create a default particle system that you can tweak
  68041. * @param emitter defines the emitter to use
  68042. * @param capacity defines the system capacity (default is 500 particles)
  68043. * @param scene defines the hosting scene
  68044. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68045. * @returns the new Particle system
  68046. */
  68047. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68048. /**
  68049. * This is the main static method (one-liner) of this helper to create different particle systems
  68050. * @param type This string represents the type to the particle system to create
  68051. * @param scene The scene where the particle system should live
  68052. * @param gpu If the system will use gpu
  68053. * @returns the ParticleSystemSet created
  68054. */
  68055. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68056. /**
  68057. * Static function used to export a particle system to a ParticleSystemSet variable.
  68058. * Please note that the emitter shape is not exported
  68059. * @param systems defines the particle systems to export
  68060. * @returns the created particle system set
  68061. */
  68062. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68063. /**
  68064. * Creates a particle system from a snippet saved in a remote file
  68065. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68066. * @param url defines the url to load from
  68067. * @param scene defines the hosting scene
  68068. * @param gpu If the system will use gpu
  68069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68070. * @returns a promise that will resolve to the new particle system
  68071. */
  68072. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68073. /**
  68074. * Creates a particle system from a snippet saved by the particle system editor
  68075. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68076. * @param scene defines the hosting scene
  68077. * @param gpu If the system will use gpu
  68078. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68079. * @returns a promise that will resolve to the new particle system
  68080. */
  68081. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68082. }
  68083. }
  68084. declare module BABYLON {
  68085. interface Engine {
  68086. /**
  68087. * Create an effect to use with particle systems.
  68088. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68089. * the particle system for which you want to create a custom effect in the last parameter
  68090. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68091. * @param uniformsNames defines a list of attribute names
  68092. * @param samplers defines an array of string used to represent textures
  68093. * @param defines defines the string containing the defines to use to compile the shaders
  68094. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68095. * @param onCompiled defines a function to call when the effect creation is successful
  68096. * @param onError defines a function to call when the effect creation has failed
  68097. * @param particleSystem the particle system you want to create the effect for
  68098. * @returns the new Effect
  68099. */
  68100. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68101. }
  68102. interface Mesh {
  68103. /**
  68104. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68105. * @returns an array of IParticleSystem
  68106. */
  68107. getEmittedParticleSystems(): IParticleSystem[];
  68108. /**
  68109. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68110. * @returns an array of IParticleSystem
  68111. */
  68112. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68113. }
  68114. }
  68115. declare module BABYLON {
  68116. /** Defines the 4 color options */
  68117. export enum PointColor {
  68118. /** color value */
  68119. Color = 2,
  68120. /** uv value */
  68121. UV = 1,
  68122. /** random value */
  68123. Random = 0,
  68124. /** stated value */
  68125. Stated = 3
  68126. }
  68127. /**
  68128. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68129. * 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.
  68130. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68131. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68132. *
  68133. * Full documentation here : TO BE ENTERED
  68134. */
  68135. export class PointsCloudSystem implements IDisposable {
  68136. /**
  68137. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68138. * Example : var p = SPS.particles[i];
  68139. */
  68140. particles: CloudPoint[];
  68141. /**
  68142. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68143. */
  68144. nbParticles: number;
  68145. /**
  68146. * This a counter for your own usage. It's not set by any SPS functions.
  68147. */
  68148. counter: number;
  68149. /**
  68150. * The PCS name. This name is also given to the underlying mesh.
  68151. */
  68152. name: string;
  68153. /**
  68154. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68155. */
  68156. mesh: Mesh;
  68157. /**
  68158. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68159. * Please read :
  68160. */
  68161. vars: any;
  68162. /**
  68163. * @hidden
  68164. */
  68165. _size: number;
  68166. private _scene;
  68167. private _promises;
  68168. private _positions;
  68169. private _indices;
  68170. private _normals;
  68171. private _colors;
  68172. private _uvs;
  68173. private _indices32;
  68174. private _positions32;
  68175. private _colors32;
  68176. private _uvs32;
  68177. private _updatable;
  68178. private _isVisibilityBoxLocked;
  68179. private _alwaysVisible;
  68180. private _groups;
  68181. private _groupCounter;
  68182. private _computeParticleColor;
  68183. private _computeParticleTexture;
  68184. private _computeParticleRotation;
  68185. private _computeBoundingBox;
  68186. private _isReady;
  68187. /**
  68188. * Creates a PCS (Points Cloud System) object
  68189. * @param name (String) is the PCS name, this will be the underlying mesh name
  68190. * @param pointSize (number) is the size for each point
  68191. * @param scene (Scene) is the scene in which the PCS is added
  68192. * @param options defines the options of the PCS e.g.
  68193. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68194. */
  68195. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68196. updatable?: boolean;
  68197. });
  68198. /**
  68199. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68200. * If no points were added to the PCS, the returned mesh is just a single point.
  68201. * @returns a promise for the created mesh
  68202. */
  68203. buildMeshAsync(): Promise<Mesh>;
  68204. /**
  68205. * @hidden
  68206. */
  68207. private _buildMesh;
  68208. private _addParticle;
  68209. private _randomUnitVector;
  68210. private _getColorIndicesForCoord;
  68211. private _setPointsColorOrUV;
  68212. private _colorFromTexture;
  68213. private _calculateDensity;
  68214. /**
  68215. * Adds points to the PCS in random positions within a unit sphere
  68216. * @param nb (positive integer) the number of particles to be created from this model
  68217. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68218. * @returns the number of groups in the system
  68219. */
  68220. addPoints(nb: number, pointFunction?: any): number;
  68221. /**
  68222. * Adds points to the PCS from the surface of the model shape
  68223. * @param mesh is any Mesh object that will be used as a surface model for the points
  68224. * @param nb (positive integer) the number of particles to be created from this model
  68225. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68226. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68227. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68228. * @returns the number of groups in the system
  68229. */
  68230. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68231. /**
  68232. * Adds points to the PCS inside the model shape
  68233. * @param mesh is any Mesh object that will be used as a surface model for the points
  68234. * @param nb (positive integer) the number of particles to be created from this model
  68235. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68236. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68237. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68238. * @returns the number of groups in the system
  68239. */
  68240. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68241. /**
  68242. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68243. * This method calls `updateParticle()` for each particle of the SPS.
  68244. * For an animated SPS, it is usually called within the render loop.
  68245. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68246. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68247. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68248. * @returns the PCS.
  68249. */
  68250. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68251. /**
  68252. * Disposes the PCS.
  68253. */
  68254. dispose(): void;
  68255. /**
  68256. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68257. * doc :
  68258. * @returns the PCS.
  68259. */
  68260. refreshVisibleSize(): PointsCloudSystem;
  68261. /**
  68262. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68263. * @param size the size (float) of the visibility box
  68264. * note : this doesn't lock the PCS mesh bounding box.
  68265. * doc :
  68266. */
  68267. setVisibilityBox(size: number): void;
  68268. /**
  68269. * Gets whether the PCS is always visible or not
  68270. * doc :
  68271. */
  68272. get isAlwaysVisible(): boolean;
  68273. /**
  68274. * Sets the PCS as always visible or not
  68275. * doc :
  68276. */
  68277. set isAlwaysVisible(val: boolean);
  68278. /**
  68279. * Tells to `setParticles()` to compute the particle rotations or not
  68280. * Default value : false. The PCS is faster when it's set to false
  68281. * Note : particle rotations are only applied to parent particles
  68282. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68283. */
  68284. set computeParticleRotation(val: boolean);
  68285. /**
  68286. * Tells to `setParticles()` to compute the particle colors or not.
  68287. * Default value : true. The PCS is faster when it's set to false.
  68288. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68289. */
  68290. set computeParticleColor(val: boolean);
  68291. set computeParticleTexture(val: boolean);
  68292. /**
  68293. * Gets if `setParticles()` computes the particle colors or not.
  68294. * Default value : false. The PCS is faster when it's set to false.
  68295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68296. */
  68297. get computeParticleColor(): boolean;
  68298. /**
  68299. * Gets if `setParticles()` computes the particle textures or not.
  68300. * Default value : false. The PCS is faster when it's set to false.
  68301. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68302. */
  68303. get computeParticleTexture(): boolean;
  68304. /**
  68305. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68306. */
  68307. set computeBoundingBox(val: boolean);
  68308. /**
  68309. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68310. */
  68311. get computeBoundingBox(): boolean;
  68312. /**
  68313. * This function does nothing. It may be overwritten to set all the particle first values.
  68314. * The PCS doesn't call this function, you may have to call it by your own.
  68315. * doc :
  68316. */
  68317. initParticles(): void;
  68318. /**
  68319. * This function does nothing. It may be overwritten to recycle a particle
  68320. * The PCS doesn't call this function, you can to call it
  68321. * doc :
  68322. * @param particle The particle to recycle
  68323. * @returns the recycled particle
  68324. */
  68325. recycleParticle(particle: CloudPoint): CloudPoint;
  68326. /**
  68327. * Updates a particle : this function should be overwritten by the user.
  68328. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68329. * doc :
  68330. * @example : just set a particle position or velocity and recycle conditions
  68331. * @param particle The particle to update
  68332. * @returns the updated particle
  68333. */
  68334. updateParticle(particle: CloudPoint): CloudPoint;
  68335. /**
  68336. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68337. * This does nothing and may be overwritten by the user.
  68338. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68339. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68340. * @param update the boolean update value actually passed to setParticles()
  68341. */
  68342. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68343. /**
  68344. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68345. * This will be passed three parameters.
  68346. * This does nothing and may be overwritten by the user.
  68347. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68348. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68349. * @param update the boolean update value actually passed to setParticles()
  68350. */
  68351. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /**
  68356. * Represents one particle of a points cloud system.
  68357. */
  68358. export class CloudPoint {
  68359. /**
  68360. * particle global index
  68361. */
  68362. idx: number;
  68363. /**
  68364. * The color of the particle
  68365. */
  68366. color: Nullable<Color4>;
  68367. /**
  68368. * The world space position of the particle.
  68369. */
  68370. position: Vector3;
  68371. /**
  68372. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68373. */
  68374. rotation: Vector3;
  68375. /**
  68376. * The world space rotation quaternion of the particle.
  68377. */
  68378. rotationQuaternion: Nullable<Quaternion>;
  68379. /**
  68380. * The uv of the particle.
  68381. */
  68382. uv: Nullable<Vector2>;
  68383. /**
  68384. * The current speed of the particle.
  68385. */
  68386. velocity: Vector3;
  68387. /**
  68388. * The pivot point in the particle local space.
  68389. */
  68390. pivot: Vector3;
  68391. /**
  68392. * Must the particle be translated from its pivot point in its local space ?
  68393. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68394. * Default : false
  68395. */
  68396. translateFromPivot: boolean;
  68397. /**
  68398. * Index of this particle in the global "positions" array (Internal use)
  68399. * @hidden
  68400. */
  68401. _pos: number;
  68402. /**
  68403. * @hidden Index of this particle in the global "indices" array (Internal use)
  68404. */
  68405. _ind: number;
  68406. /**
  68407. * Group this particle belongs to
  68408. */
  68409. _group: PointsGroup;
  68410. /**
  68411. * Group id of this particle
  68412. */
  68413. groupId: number;
  68414. /**
  68415. * Index of the particle in its group id (Internal use)
  68416. */
  68417. idxInGroup: number;
  68418. /**
  68419. * @hidden Particle BoundingInfo object (Internal use)
  68420. */
  68421. _boundingInfo: BoundingInfo;
  68422. /**
  68423. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68424. */
  68425. _pcs: PointsCloudSystem;
  68426. /**
  68427. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68428. */
  68429. _stillInvisible: boolean;
  68430. /**
  68431. * @hidden Last computed particle rotation matrix
  68432. */
  68433. _rotationMatrix: number[];
  68434. /**
  68435. * Parent particle Id, if any.
  68436. * Default null.
  68437. */
  68438. parentId: Nullable<number>;
  68439. /**
  68440. * @hidden Internal global position in the PCS.
  68441. */
  68442. _globalPosition: Vector3;
  68443. /**
  68444. * Creates a Point Cloud object.
  68445. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68446. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68447. * @param group (PointsGroup) is the group the particle belongs to
  68448. * @param groupId (integer) is the group identifier in the PCS.
  68449. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68450. * @param pcs defines the PCS it is associated to
  68451. */
  68452. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68453. /**
  68454. * get point size
  68455. */
  68456. get size(): Vector3;
  68457. /**
  68458. * Set point size
  68459. */
  68460. set size(scale: Vector3);
  68461. /**
  68462. * Legacy support, changed quaternion to rotationQuaternion
  68463. */
  68464. get quaternion(): Nullable<Quaternion>;
  68465. /**
  68466. * Legacy support, changed quaternion to rotationQuaternion
  68467. */
  68468. set quaternion(q: Nullable<Quaternion>);
  68469. /**
  68470. * Returns a boolean. True if the particle intersects a mesh, else false
  68471. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68472. * @param target is the object (point or mesh) what the intersection is computed against
  68473. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68474. * @returns true if it intersects
  68475. */
  68476. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68477. /**
  68478. * get the rotation matrix of the particle
  68479. * @hidden
  68480. */
  68481. getRotationMatrix(m: Matrix): void;
  68482. }
  68483. /**
  68484. * Represents a group of points in a points cloud system
  68485. * * PCS internal tool, don't use it manually.
  68486. */
  68487. export class PointsGroup {
  68488. /**
  68489. * The group id
  68490. * @hidden
  68491. */
  68492. groupID: number;
  68493. /**
  68494. * image data for group (internal use)
  68495. * @hidden
  68496. */
  68497. _groupImageData: Nullable<ArrayBufferView>;
  68498. /**
  68499. * Image Width (internal use)
  68500. * @hidden
  68501. */
  68502. _groupImgWidth: number;
  68503. /**
  68504. * Image Height (internal use)
  68505. * @hidden
  68506. */
  68507. _groupImgHeight: number;
  68508. /**
  68509. * Custom position function (internal use)
  68510. * @hidden
  68511. */
  68512. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68513. /**
  68514. * density per facet for surface points
  68515. * @hidden
  68516. */
  68517. _groupDensity: number[];
  68518. /**
  68519. * Only when points are colored by texture carries pointer to texture list array
  68520. * @hidden
  68521. */
  68522. _textureNb: number;
  68523. /**
  68524. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68525. * PCS internal tool, don't use it manually.
  68526. * @hidden
  68527. */
  68528. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68529. }
  68530. }
  68531. declare module BABYLON {
  68532. interface Scene {
  68533. /** @hidden (Backing field) */
  68534. _physicsEngine: Nullable<IPhysicsEngine>;
  68535. /** @hidden */
  68536. _physicsTimeAccumulator: number;
  68537. /**
  68538. * Gets the current physics engine
  68539. * @returns a IPhysicsEngine or null if none attached
  68540. */
  68541. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68542. /**
  68543. * Enables physics to the current scene
  68544. * @param gravity defines the scene's gravity for the physics engine
  68545. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68546. * @return a boolean indicating if the physics engine was initialized
  68547. */
  68548. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68549. /**
  68550. * Disables and disposes the physics engine associated with the scene
  68551. */
  68552. disablePhysicsEngine(): void;
  68553. /**
  68554. * Gets a boolean indicating if there is an active physics engine
  68555. * @returns a boolean indicating if there is an active physics engine
  68556. */
  68557. isPhysicsEnabled(): boolean;
  68558. /**
  68559. * Deletes a physics compound impostor
  68560. * @param compound defines the compound to delete
  68561. */
  68562. deleteCompoundImpostor(compound: any): void;
  68563. /**
  68564. * An event triggered when physic simulation is about to be run
  68565. */
  68566. onBeforePhysicsObservable: Observable<Scene>;
  68567. /**
  68568. * An event triggered when physic simulation has been done
  68569. */
  68570. onAfterPhysicsObservable: Observable<Scene>;
  68571. }
  68572. interface AbstractMesh {
  68573. /** @hidden */
  68574. _physicsImpostor: Nullable<PhysicsImpostor>;
  68575. /**
  68576. * Gets or sets impostor used for physic simulation
  68577. * @see https://doc.babylonjs.com/features/physics_engine
  68578. */
  68579. physicsImpostor: Nullable<PhysicsImpostor>;
  68580. /**
  68581. * Gets the current physics impostor
  68582. * @see https://doc.babylonjs.com/features/physics_engine
  68583. * @returns a physics impostor or null
  68584. */
  68585. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68586. /** Apply a physic impulse to the mesh
  68587. * @param force defines the force to apply
  68588. * @param contactPoint defines where to apply the force
  68589. * @returns the current mesh
  68590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68591. */
  68592. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68593. /**
  68594. * Creates a physic joint between two meshes
  68595. * @param otherMesh defines the other mesh to use
  68596. * @param pivot1 defines the pivot to use on this mesh
  68597. * @param pivot2 defines the pivot to use on the other mesh
  68598. * @param options defines additional options (can be plugin dependent)
  68599. * @returns the current mesh
  68600. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68601. */
  68602. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68603. /** @hidden */
  68604. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68605. }
  68606. /**
  68607. * Defines the physics engine scene component responsible to manage a physics engine
  68608. */
  68609. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68610. /**
  68611. * The component name helpful to identify the component in the list of scene components.
  68612. */
  68613. readonly name: string;
  68614. /**
  68615. * The scene the component belongs to.
  68616. */
  68617. scene: Scene;
  68618. /**
  68619. * Creates a new instance of the component for the given scene
  68620. * @param scene Defines the scene to register the component in
  68621. */
  68622. constructor(scene: Scene);
  68623. /**
  68624. * Registers the component in a given scene
  68625. */
  68626. register(): void;
  68627. /**
  68628. * Rebuilds the elements related to this component in case of
  68629. * context lost for instance.
  68630. */
  68631. rebuild(): void;
  68632. /**
  68633. * Disposes the component and the associated ressources
  68634. */
  68635. dispose(): void;
  68636. }
  68637. }
  68638. declare module BABYLON {
  68639. /**
  68640. * A helper for physics simulations
  68641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68642. */
  68643. export class PhysicsHelper {
  68644. private _scene;
  68645. private _physicsEngine;
  68646. /**
  68647. * Initializes the Physics helper
  68648. * @param scene Babylon.js scene
  68649. */
  68650. constructor(scene: Scene);
  68651. /**
  68652. * Applies a radial explosion impulse
  68653. * @param origin the origin of the explosion
  68654. * @param radiusOrEventOptions the radius or the options of radial explosion
  68655. * @param strength the explosion strength
  68656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68657. * @returns A physics radial explosion event, or null
  68658. */
  68659. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68660. /**
  68661. * Applies a radial explosion force
  68662. * @param origin the origin of the explosion
  68663. * @param radiusOrEventOptions the radius or the options of radial explosion
  68664. * @param strength the explosion strength
  68665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68666. * @returns A physics radial explosion event, or null
  68667. */
  68668. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68669. /**
  68670. * Creates a gravitational field
  68671. * @param origin the origin of the explosion
  68672. * @param radiusOrEventOptions the radius or the options of radial explosion
  68673. * @param strength the explosion strength
  68674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68675. * @returns A physics gravitational field event, or null
  68676. */
  68677. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68678. /**
  68679. * Creates a physics updraft event
  68680. * @param origin the origin of the updraft
  68681. * @param radiusOrEventOptions the radius or the options of the updraft
  68682. * @param strength the strength of the updraft
  68683. * @param height the height of the updraft
  68684. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68685. * @returns A physics updraft event, or null
  68686. */
  68687. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68688. /**
  68689. * Creates a physics vortex event
  68690. * @param origin the of the vortex
  68691. * @param radiusOrEventOptions the radius or the options of the vortex
  68692. * @param strength the strength of the vortex
  68693. * @param height the height of the vortex
  68694. * @returns a Physics vortex event, or null
  68695. * A physics vortex event or null
  68696. */
  68697. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68698. }
  68699. /**
  68700. * Represents a physics radial explosion event
  68701. */
  68702. class PhysicsRadialExplosionEvent {
  68703. private _scene;
  68704. private _options;
  68705. private _sphere;
  68706. private _dataFetched;
  68707. /**
  68708. * Initializes a radial explosioin event
  68709. * @param _scene BabylonJS scene
  68710. * @param _options The options for the vortex event
  68711. */
  68712. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68713. /**
  68714. * Returns the data related to the radial explosion event (sphere).
  68715. * @returns The radial explosion event data
  68716. */
  68717. getData(): PhysicsRadialExplosionEventData;
  68718. /**
  68719. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68720. * @param impostor A physics imposter
  68721. * @param origin the origin of the explosion
  68722. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68723. */
  68724. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68725. /**
  68726. * Triggers affecterd impostors callbacks
  68727. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68728. */
  68729. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68730. /**
  68731. * Disposes the sphere.
  68732. * @param force Specifies if the sphere should be disposed by force
  68733. */
  68734. dispose(force?: boolean): void;
  68735. /*** Helpers ***/
  68736. private _prepareSphere;
  68737. private _intersectsWithSphere;
  68738. }
  68739. /**
  68740. * Represents a gravitational field event
  68741. */
  68742. class PhysicsGravitationalFieldEvent {
  68743. private _physicsHelper;
  68744. private _scene;
  68745. private _origin;
  68746. private _options;
  68747. private _tickCallback;
  68748. private _sphere;
  68749. private _dataFetched;
  68750. /**
  68751. * Initializes the physics gravitational field event
  68752. * @param _physicsHelper A physics helper
  68753. * @param _scene BabylonJS scene
  68754. * @param _origin The origin position of the gravitational field event
  68755. * @param _options The options for the vortex event
  68756. */
  68757. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68758. /**
  68759. * Returns the data related to the gravitational field event (sphere).
  68760. * @returns A gravitational field event
  68761. */
  68762. getData(): PhysicsGravitationalFieldEventData;
  68763. /**
  68764. * Enables the gravitational field.
  68765. */
  68766. enable(): void;
  68767. /**
  68768. * Disables the gravitational field.
  68769. */
  68770. disable(): void;
  68771. /**
  68772. * Disposes the sphere.
  68773. * @param force The force to dispose from the gravitational field event
  68774. */
  68775. dispose(force?: boolean): void;
  68776. private _tick;
  68777. }
  68778. /**
  68779. * Represents a physics updraft event
  68780. */
  68781. class PhysicsUpdraftEvent {
  68782. private _scene;
  68783. private _origin;
  68784. private _options;
  68785. private _physicsEngine;
  68786. private _originTop;
  68787. private _originDirection;
  68788. private _tickCallback;
  68789. private _cylinder;
  68790. private _cylinderPosition;
  68791. private _dataFetched;
  68792. /**
  68793. * Initializes the physics updraft event
  68794. * @param _scene BabylonJS scene
  68795. * @param _origin The origin position of the updraft
  68796. * @param _options The options for the updraft event
  68797. */
  68798. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68799. /**
  68800. * Returns the data related to the updraft event (cylinder).
  68801. * @returns A physics updraft event
  68802. */
  68803. getData(): PhysicsUpdraftEventData;
  68804. /**
  68805. * Enables the updraft.
  68806. */
  68807. enable(): void;
  68808. /**
  68809. * Disables the updraft.
  68810. */
  68811. disable(): void;
  68812. /**
  68813. * Disposes the cylinder.
  68814. * @param force Specifies if the updraft should be disposed by force
  68815. */
  68816. dispose(force?: boolean): void;
  68817. private getImpostorHitData;
  68818. private _tick;
  68819. /*** Helpers ***/
  68820. private _prepareCylinder;
  68821. private _intersectsWithCylinder;
  68822. }
  68823. /**
  68824. * Represents a physics vortex event
  68825. */
  68826. class PhysicsVortexEvent {
  68827. private _scene;
  68828. private _origin;
  68829. private _options;
  68830. private _physicsEngine;
  68831. private _originTop;
  68832. private _tickCallback;
  68833. private _cylinder;
  68834. private _cylinderPosition;
  68835. private _dataFetched;
  68836. /**
  68837. * Initializes the physics vortex event
  68838. * @param _scene The BabylonJS scene
  68839. * @param _origin The origin position of the vortex
  68840. * @param _options The options for the vortex event
  68841. */
  68842. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68843. /**
  68844. * Returns the data related to the vortex event (cylinder).
  68845. * @returns The physics vortex event data
  68846. */
  68847. getData(): PhysicsVortexEventData;
  68848. /**
  68849. * Enables the vortex.
  68850. */
  68851. enable(): void;
  68852. /**
  68853. * Disables the cortex.
  68854. */
  68855. disable(): void;
  68856. /**
  68857. * Disposes the sphere.
  68858. * @param force
  68859. */
  68860. dispose(force?: boolean): void;
  68861. private getImpostorHitData;
  68862. private _tick;
  68863. /*** Helpers ***/
  68864. private _prepareCylinder;
  68865. private _intersectsWithCylinder;
  68866. }
  68867. /**
  68868. * Options fot the radial explosion event
  68869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68870. */
  68871. export class PhysicsRadialExplosionEventOptions {
  68872. /**
  68873. * The radius of the sphere for the radial explosion.
  68874. */
  68875. radius: number;
  68876. /**
  68877. * The strenth of the explosion.
  68878. */
  68879. strength: number;
  68880. /**
  68881. * The strenght of the force in correspondence to the distance of the affected object
  68882. */
  68883. falloff: PhysicsRadialImpulseFalloff;
  68884. /**
  68885. * Sphere options for the radial explosion.
  68886. */
  68887. sphere: {
  68888. segments: number;
  68889. diameter: number;
  68890. };
  68891. /**
  68892. * Sphere options for the radial explosion.
  68893. */
  68894. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68895. }
  68896. /**
  68897. * Options fot the updraft event
  68898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68899. */
  68900. export class PhysicsUpdraftEventOptions {
  68901. /**
  68902. * The radius of the cylinder for the vortex
  68903. */
  68904. radius: number;
  68905. /**
  68906. * The strenth of the updraft.
  68907. */
  68908. strength: number;
  68909. /**
  68910. * The height of the cylinder for the updraft.
  68911. */
  68912. height: number;
  68913. /**
  68914. * The mode for the the updraft.
  68915. */
  68916. updraftMode: PhysicsUpdraftMode;
  68917. }
  68918. /**
  68919. * Options fot the vortex event
  68920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68921. */
  68922. export class PhysicsVortexEventOptions {
  68923. /**
  68924. * The radius of the cylinder for the vortex
  68925. */
  68926. radius: number;
  68927. /**
  68928. * The strenth of the vortex.
  68929. */
  68930. strength: number;
  68931. /**
  68932. * The height of the cylinder for the vortex.
  68933. */
  68934. height: number;
  68935. /**
  68936. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68937. */
  68938. centripetalForceThreshold: number;
  68939. /**
  68940. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68941. */
  68942. centripetalForceMultiplier: number;
  68943. /**
  68944. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68945. */
  68946. centrifugalForceMultiplier: number;
  68947. /**
  68948. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68949. */
  68950. updraftForceMultiplier: number;
  68951. }
  68952. /**
  68953. * The strenght of the force in correspondence to the distance of the affected object
  68954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68955. */
  68956. export enum PhysicsRadialImpulseFalloff {
  68957. /** Defines that impulse is constant in strength across it's whole radius */
  68958. Constant = 0,
  68959. /** Defines that impulse gets weaker if it's further from the origin */
  68960. Linear = 1
  68961. }
  68962. /**
  68963. * The strength of the force in correspondence to the distance of the affected object
  68964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68965. */
  68966. export enum PhysicsUpdraftMode {
  68967. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68968. Center = 0,
  68969. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68970. Perpendicular = 1
  68971. }
  68972. /**
  68973. * Interface for a physics hit data
  68974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68975. */
  68976. export interface PhysicsHitData {
  68977. /**
  68978. * The force applied at the contact point
  68979. */
  68980. force: Vector3;
  68981. /**
  68982. * The contact point
  68983. */
  68984. contactPoint: Vector3;
  68985. /**
  68986. * The distance from the origin to the contact point
  68987. */
  68988. distanceFromOrigin: number;
  68989. }
  68990. /**
  68991. * Interface for radial explosion event data
  68992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68993. */
  68994. export interface PhysicsRadialExplosionEventData {
  68995. /**
  68996. * A sphere used for the radial explosion event
  68997. */
  68998. sphere: Mesh;
  68999. }
  69000. /**
  69001. * Interface for gravitational field event data
  69002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69003. */
  69004. export interface PhysicsGravitationalFieldEventData {
  69005. /**
  69006. * A sphere mesh used for the gravitational field event
  69007. */
  69008. sphere: Mesh;
  69009. }
  69010. /**
  69011. * Interface for updraft event data
  69012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69013. */
  69014. export interface PhysicsUpdraftEventData {
  69015. /**
  69016. * A cylinder used for the updraft event
  69017. */
  69018. cylinder: Mesh;
  69019. }
  69020. /**
  69021. * Interface for vortex event data
  69022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69023. */
  69024. export interface PhysicsVortexEventData {
  69025. /**
  69026. * A cylinder used for the vortex event
  69027. */
  69028. cylinder: Mesh;
  69029. }
  69030. /**
  69031. * Interface for an affected physics impostor
  69032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69033. */
  69034. export interface PhysicsAffectedImpostorWithData {
  69035. /**
  69036. * The impostor affected by the effect
  69037. */
  69038. impostor: PhysicsImpostor;
  69039. /**
  69040. * The data about the hit/horce from the explosion
  69041. */
  69042. hitData: PhysicsHitData;
  69043. }
  69044. }
  69045. declare module BABYLON {
  69046. /** @hidden */
  69047. export var blackAndWhitePixelShader: {
  69048. name: string;
  69049. shader: string;
  69050. };
  69051. }
  69052. declare module BABYLON {
  69053. /**
  69054. * Post process used to render in black and white
  69055. */
  69056. export class BlackAndWhitePostProcess extends PostProcess {
  69057. /**
  69058. * Linear about to convert he result to black and white (default: 1)
  69059. */
  69060. degree: number;
  69061. /**
  69062. * Gets a string identifying the name of the class
  69063. * @returns "BlackAndWhitePostProcess" string
  69064. */
  69065. getClassName(): string;
  69066. /**
  69067. * Creates a black and white post process
  69068. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69069. * @param name The name of the effect.
  69070. * @param options The required width/height ratio to downsize to before computing the render pass.
  69071. * @param camera The camera to apply the render pass to.
  69072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69073. * @param engine The engine which the post process will be applied. (default: current engine)
  69074. * @param reusable If the post process can be reused on the same frame. (default: false)
  69075. */
  69076. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69077. /** @hidden */
  69078. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69079. }
  69080. }
  69081. declare module BABYLON {
  69082. /**
  69083. * This represents a set of one or more post processes in Babylon.
  69084. * A post process can be used to apply a shader to a texture after it is rendered.
  69085. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69086. */
  69087. export class PostProcessRenderEffect {
  69088. private _postProcesses;
  69089. private _getPostProcesses;
  69090. private _singleInstance;
  69091. private _cameras;
  69092. private _indicesForCamera;
  69093. /**
  69094. * Name of the effect
  69095. * @hidden
  69096. */
  69097. _name: string;
  69098. /**
  69099. * Instantiates a post process render effect.
  69100. * A post process can be used to apply a shader to a texture after it is rendered.
  69101. * @param engine The engine the effect is tied to
  69102. * @param name The name of the effect
  69103. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69104. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69105. */
  69106. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69107. /**
  69108. * Checks if all the post processes in the effect are supported.
  69109. */
  69110. get isSupported(): boolean;
  69111. /**
  69112. * Updates the current state of the effect
  69113. * @hidden
  69114. */
  69115. _update(): void;
  69116. /**
  69117. * Attaches the effect on cameras
  69118. * @param cameras The camera to attach to.
  69119. * @hidden
  69120. */
  69121. _attachCameras(cameras: Camera): void;
  69122. /**
  69123. * Attaches the effect on cameras
  69124. * @param cameras The camera to attach to.
  69125. * @hidden
  69126. */
  69127. _attachCameras(cameras: Camera[]): void;
  69128. /**
  69129. * Detaches the effect on cameras
  69130. * @param cameras The camera to detatch from.
  69131. * @hidden
  69132. */
  69133. _detachCameras(cameras: Camera): void;
  69134. /**
  69135. * Detatches the effect on cameras
  69136. * @param cameras The camera to detatch from.
  69137. * @hidden
  69138. */
  69139. _detachCameras(cameras: Camera[]): void;
  69140. /**
  69141. * Enables the effect on given cameras
  69142. * @param cameras The camera to enable.
  69143. * @hidden
  69144. */
  69145. _enable(cameras: Camera): void;
  69146. /**
  69147. * Enables the effect on given cameras
  69148. * @param cameras The camera to enable.
  69149. * @hidden
  69150. */
  69151. _enable(cameras: Nullable<Camera[]>): void;
  69152. /**
  69153. * Disables the effect on the given cameras
  69154. * @param cameras The camera to disable.
  69155. * @hidden
  69156. */
  69157. _disable(cameras: Camera): void;
  69158. /**
  69159. * Disables the effect on the given cameras
  69160. * @param cameras The camera to disable.
  69161. * @hidden
  69162. */
  69163. _disable(cameras: Nullable<Camera[]>): void;
  69164. /**
  69165. * Gets a list of the post processes contained in the effect.
  69166. * @param camera The camera to get the post processes on.
  69167. * @returns The list of the post processes in the effect.
  69168. */
  69169. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69170. }
  69171. }
  69172. declare module BABYLON {
  69173. /** @hidden */
  69174. export var extractHighlightsPixelShader: {
  69175. name: string;
  69176. shader: string;
  69177. };
  69178. }
  69179. declare module BABYLON {
  69180. /**
  69181. * 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.
  69182. */
  69183. export class ExtractHighlightsPostProcess extends PostProcess {
  69184. /**
  69185. * The luminance threshold, pixels below this value will be set to black.
  69186. */
  69187. threshold: number;
  69188. /** @hidden */
  69189. _exposure: number;
  69190. /**
  69191. * Post process which has the input texture to be used when performing highlight extraction
  69192. * @hidden
  69193. */
  69194. _inputPostProcess: Nullable<PostProcess>;
  69195. /**
  69196. * Gets a string identifying the name of the class
  69197. * @returns "ExtractHighlightsPostProcess" string
  69198. */
  69199. getClassName(): string;
  69200. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69201. }
  69202. }
  69203. declare module BABYLON {
  69204. /** @hidden */
  69205. export var bloomMergePixelShader: {
  69206. name: string;
  69207. shader: string;
  69208. };
  69209. }
  69210. declare module BABYLON {
  69211. /**
  69212. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69213. */
  69214. export class BloomMergePostProcess extends PostProcess {
  69215. /** Weight of the bloom to be added to the original input. */
  69216. weight: number;
  69217. /**
  69218. * Gets a string identifying the name of the class
  69219. * @returns "BloomMergePostProcess" string
  69220. */
  69221. getClassName(): string;
  69222. /**
  69223. * Creates a new instance of @see BloomMergePostProcess
  69224. * @param name The name of the effect.
  69225. * @param originalFromInput Post process which's input will be used for the merge.
  69226. * @param blurred Blurred highlights post process which's output will be used.
  69227. * @param weight Weight of the bloom to be added to the original input.
  69228. * @param options The required width/height ratio to downsize to before computing the render pass.
  69229. * @param camera The camera to apply the render pass to.
  69230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69231. * @param engine The engine which the post process will be applied. (default: current engine)
  69232. * @param reusable If the post process can be reused on the same frame. (default: false)
  69233. * @param textureType Type of textures used when performing the post process. (default: 0)
  69234. * @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)
  69235. */
  69236. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69237. /** Weight of the bloom to be added to the original input. */
  69238. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69239. }
  69240. }
  69241. declare module BABYLON {
  69242. /**
  69243. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69244. */
  69245. export class BloomEffect extends PostProcessRenderEffect {
  69246. private bloomScale;
  69247. /**
  69248. * @hidden Internal
  69249. */
  69250. _effects: Array<PostProcess>;
  69251. /**
  69252. * @hidden Internal
  69253. */
  69254. _downscale: ExtractHighlightsPostProcess;
  69255. private _blurX;
  69256. private _blurY;
  69257. private _merge;
  69258. /**
  69259. * The luminance threshold to find bright areas of the image to bloom.
  69260. */
  69261. get threshold(): number;
  69262. set threshold(value: number);
  69263. /**
  69264. * The strength of the bloom.
  69265. */
  69266. get weight(): number;
  69267. set weight(value: number);
  69268. /**
  69269. * Specifies the size of the bloom blur kernel, relative to the final output size
  69270. */
  69271. get kernel(): number;
  69272. set kernel(value: number);
  69273. /**
  69274. * Creates a new instance of @see BloomEffect
  69275. * @param scene The scene the effect belongs to.
  69276. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69277. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69278. * @param bloomWeight The the strength of bloom.
  69279. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69280. * @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)
  69281. */
  69282. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69283. /**
  69284. * Disposes each of the internal effects for a given camera.
  69285. * @param camera The camera to dispose the effect on.
  69286. */
  69287. disposeEffects(camera: Camera): void;
  69288. /**
  69289. * @hidden Internal
  69290. */
  69291. _updateEffects(): void;
  69292. /**
  69293. * Internal
  69294. * @returns if all the contained post processes are ready.
  69295. * @hidden
  69296. */
  69297. _isReady(): boolean;
  69298. }
  69299. }
  69300. declare module BABYLON {
  69301. /** @hidden */
  69302. export var chromaticAberrationPixelShader: {
  69303. name: string;
  69304. shader: string;
  69305. };
  69306. }
  69307. declare module BABYLON {
  69308. /**
  69309. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69310. */
  69311. export class ChromaticAberrationPostProcess extends PostProcess {
  69312. /**
  69313. * The amount of seperation of rgb channels (default: 30)
  69314. */
  69315. aberrationAmount: number;
  69316. /**
  69317. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69318. */
  69319. radialIntensity: number;
  69320. /**
  69321. * 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))
  69322. */
  69323. direction: Vector2;
  69324. /**
  69325. * 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))
  69326. */
  69327. centerPosition: Vector2;
  69328. /** The width of the screen to apply the effect on */
  69329. screenWidth: number;
  69330. /** The height of the screen to apply the effect on */
  69331. screenHeight: number;
  69332. /**
  69333. * Gets a string identifying the name of the class
  69334. * @returns "ChromaticAberrationPostProcess" string
  69335. */
  69336. getClassName(): string;
  69337. /**
  69338. * Creates a new instance ChromaticAberrationPostProcess
  69339. * @param name The name of the effect.
  69340. * @param screenWidth The width of the screen to apply the effect on.
  69341. * @param screenHeight The height of the screen to apply the effect on.
  69342. * @param options The required width/height ratio to downsize to before computing the render pass.
  69343. * @param camera The camera to apply the render pass to.
  69344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69345. * @param engine The engine which the post process will be applied. (default: current engine)
  69346. * @param reusable If the post process can be reused on the same frame. (default: false)
  69347. * @param textureType Type of textures used when performing the post process. (default: 0)
  69348. * @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)
  69349. */
  69350. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69351. /** @hidden */
  69352. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69353. }
  69354. }
  69355. declare module BABYLON {
  69356. /** @hidden */
  69357. export var circleOfConfusionPixelShader: {
  69358. name: string;
  69359. shader: string;
  69360. };
  69361. }
  69362. declare module BABYLON {
  69363. /**
  69364. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69365. */
  69366. export class CircleOfConfusionPostProcess extends PostProcess {
  69367. /**
  69368. * 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.
  69369. */
  69370. lensSize: number;
  69371. /**
  69372. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69373. */
  69374. fStop: number;
  69375. /**
  69376. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69377. */
  69378. focusDistance: number;
  69379. /**
  69380. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69381. */
  69382. focalLength: number;
  69383. /**
  69384. * Gets a string identifying the name of the class
  69385. * @returns "CircleOfConfusionPostProcess" string
  69386. */
  69387. getClassName(): string;
  69388. private _depthTexture;
  69389. /**
  69390. * Creates a new instance CircleOfConfusionPostProcess
  69391. * @param name The name of the effect.
  69392. * @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.
  69393. * @param options The required width/height ratio to downsize to before computing the render pass.
  69394. * @param camera The camera to apply the render pass to.
  69395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69396. * @param engine The engine which the post process will be applied. (default: current engine)
  69397. * @param reusable If the post process can be reused on the same frame. (default: false)
  69398. * @param textureType Type of textures used when performing the post process. (default: 0)
  69399. * @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)
  69400. */
  69401. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69402. /**
  69403. * 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.
  69404. */
  69405. set depthTexture(value: RenderTargetTexture);
  69406. }
  69407. }
  69408. declare module BABYLON {
  69409. /** @hidden */
  69410. export var colorCorrectionPixelShader: {
  69411. name: string;
  69412. shader: string;
  69413. };
  69414. }
  69415. declare module BABYLON {
  69416. /**
  69417. *
  69418. * This post-process allows the modification of rendered colors by using
  69419. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69420. *
  69421. * The object needs to be provided an url to a texture containing the color
  69422. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69423. * Use an image editing software to tweak the LUT to match your needs.
  69424. *
  69425. * For an example of a color LUT, see here:
  69426. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69427. * For explanations on color grading, see here:
  69428. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69429. *
  69430. */
  69431. export class ColorCorrectionPostProcess extends PostProcess {
  69432. private _colorTableTexture;
  69433. /**
  69434. * Gets the color table url used to create the LUT texture
  69435. */
  69436. colorTableUrl: string;
  69437. /**
  69438. * Gets a string identifying the name of the class
  69439. * @returns "ColorCorrectionPostProcess" string
  69440. */
  69441. getClassName(): string;
  69442. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69443. /** @hidden */
  69444. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69445. }
  69446. }
  69447. declare module BABYLON {
  69448. /** @hidden */
  69449. export var convolutionPixelShader: {
  69450. name: string;
  69451. shader: string;
  69452. };
  69453. }
  69454. declare module BABYLON {
  69455. /**
  69456. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69457. * input texture to perform effects such as edge detection or sharpening
  69458. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69459. */
  69460. export class ConvolutionPostProcess extends PostProcess {
  69461. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69462. kernel: number[];
  69463. /**
  69464. * Gets a string identifying the name of the class
  69465. * @returns "ConvolutionPostProcess" string
  69466. */
  69467. getClassName(): string;
  69468. /**
  69469. * Creates a new instance ConvolutionPostProcess
  69470. * @param name The name of the effect.
  69471. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69472. * @param options The required width/height ratio to downsize to before computing the render pass.
  69473. * @param camera The camera to apply the render pass to.
  69474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69475. * @param engine The engine which the post process will be applied. (default: current engine)
  69476. * @param reusable If the post process can be reused on the same frame. (default: false)
  69477. * @param textureType Type of textures used when performing the post process. (default: 0)
  69478. */
  69479. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69480. /** @hidden */
  69481. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69482. /**
  69483. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69484. */
  69485. static EdgeDetect0Kernel: number[];
  69486. /**
  69487. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69488. */
  69489. static EdgeDetect1Kernel: number[];
  69490. /**
  69491. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69492. */
  69493. static EdgeDetect2Kernel: number[];
  69494. /**
  69495. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69496. */
  69497. static SharpenKernel: number[];
  69498. /**
  69499. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69500. */
  69501. static EmbossKernel: number[];
  69502. /**
  69503. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69504. */
  69505. static GaussianKernel: number[];
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /**
  69510. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69511. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69512. * based on samples that have a large difference in distance than the center pixel.
  69513. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69514. */
  69515. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69516. /**
  69517. * The direction the blur should be applied
  69518. */
  69519. direction: Vector2;
  69520. /**
  69521. * Gets a string identifying the name of the class
  69522. * @returns "DepthOfFieldBlurPostProcess" string
  69523. */
  69524. getClassName(): string;
  69525. /**
  69526. * Creates a new instance CircleOfConfusionPostProcess
  69527. * @param name The name of the effect.
  69528. * @param scene The scene the effect belongs to.
  69529. * @param direction The direction the blur should be applied.
  69530. * @param kernel The size of the kernel used to blur.
  69531. * @param options The required width/height ratio to downsize to before computing the render pass.
  69532. * @param camera The camera to apply the render pass to.
  69533. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69534. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69536. * @param engine The engine which the post process will be applied. (default: current engine)
  69537. * @param reusable If the post process can be reused on the same frame. (default: false)
  69538. * @param textureType Type of textures used when performing the post process. (default: 0)
  69539. * @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)
  69540. */
  69541. 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);
  69542. }
  69543. }
  69544. declare module BABYLON {
  69545. /** @hidden */
  69546. export var depthOfFieldMergePixelShader: {
  69547. name: string;
  69548. shader: string;
  69549. };
  69550. }
  69551. declare module BABYLON {
  69552. /**
  69553. * Options to be set when merging outputs from the default pipeline.
  69554. */
  69555. export class DepthOfFieldMergePostProcessOptions {
  69556. /**
  69557. * The original image to merge on top of
  69558. */
  69559. originalFromInput: PostProcess;
  69560. /**
  69561. * Parameters to perform the merge of the depth of field effect
  69562. */
  69563. depthOfField?: {
  69564. circleOfConfusion: PostProcess;
  69565. blurSteps: Array<PostProcess>;
  69566. };
  69567. /**
  69568. * Parameters to perform the merge of bloom effect
  69569. */
  69570. bloom?: {
  69571. blurred: PostProcess;
  69572. weight: number;
  69573. };
  69574. }
  69575. /**
  69576. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69577. */
  69578. export class DepthOfFieldMergePostProcess extends PostProcess {
  69579. private blurSteps;
  69580. /**
  69581. * Gets a string identifying the name of the class
  69582. * @returns "DepthOfFieldMergePostProcess" string
  69583. */
  69584. getClassName(): string;
  69585. /**
  69586. * Creates a new instance of DepthOfFieldMergePostProcess
  69587. * @param name The name of the effect.
  69588. * @param originalFromInput Post process which's input will be used for the merge.
  69589. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69590. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69591. * @param options The required width/height ratio to downsize to before computing the render pass.
  69592. * @param camera The camera to apply the render pass to.
  69593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69594. * @param engine The engine which the post process will be applied. (default: current engine)
  69595. * @param reusable If the post process can be reused on the same frame. (default: false)
  69596. * @param textureType Type of textures used when performing the post process. (default: 0)
  69597. * @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)
  69598. */
  69599. 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);
  69600. /**
  69601. * Updates the effect with the current post process compile time values and recompiles the shader.
  69602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69605. * @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
  69606. * @param onCompiled Called when the shader has been compiled.
  69607. * @param onError Called if there is an error when compiling a shader.
  69608. */
  69609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69610. }
  69611. }
  69612. declare module BABYLON {
  69613. /**
  69614. * Specifies the level of max blur that should be applied when using the depth of field effect
  69615. */
  69616. export enum DepthOfFieldEffectBlurLevel {
  69617. /**
  69618. * Subtle blur
  69619. */
  69620. Low = 0,
  69621. /**
  69622. * Medium blur
  69623. */
  69624. Medium = 1,
  69625. /**
  69626. * Large blur
  69627. */
  69628. High = 2
  69629. }
  69630. /**
  69631. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69632. */
  69633. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69634. private _circleOfConfusion;
  69635. /**
  69636. * @hidden Internal, blurs from high to low
  69637. */
  69638. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69639. private _depthOfFieldBlurY;
  69640. private _dofMerge;
  69641. /**
  69642. * @hidden Internal post processes in depth of field effect
  69643. */
  69644. _effects: Array<PostProcess>;
  69645. /**
  69646. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69647. */
  69648. set focalLength(value: number);
  69649. get focalLength(): number;
  69650. /**
  69651. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69652. */
  69653. set fStop(value: number);
  69654. get fStop(): number;
  69655. /**
  69656. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69657. */
  69658. set focusDistance(value: number);
  69659. get focusDistance(): number;
  69660. /**
  69661. * 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.
  69662. */
  69663. set lensSize(value: number);
  69664. get lensSize(): number;
  69665. /**
  69666. * Creates a new instance DepthOfFieldEffect
  69667. * @param scene The scene the effect belongs to.
  69668. * @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.
  69669. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  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(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69673. /**
  69674. * Get the current class name of the current effet
  69675. * @returns "DepthOfFieldEffect"
  69676. */
  69677. getClassName(): string;
  69678. /**
  69679. * 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.
  69680. */
  69681. set depthTexture(value: RenderTargetTexture);
  69682. /**
  69683. * Disposes each of the internal effects for a given camera.
  69684. * @param camera The camera to dispose the effect on.
  69685. */
  69686. disposeEffects(camera: Camera): void;
  69687. /**
  69688. * @hidden Internal
  69689. */
  69690. _updateEffects(): void;
  69691. /**
  69692. * Internal
  69693. * @returns if all the contained post processes are ready.
  69694. * @hidden
  69695. */
  69696. _isReady(): boolean;
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /** @hidden */
  69701. export var displayPassPixelShader: {
  69702. name: string;
  69703. shader: string;
  69704. };
  69705. }
  69706. declare module BABYLON {
  69707. /**
  69708. * DisplayPassPostProcess which produces an output the same as it's input
  69709. */
  69710. export class DisplayPassPostProcess extends PostProcess {
  69711. /**
  69712. * Gets a string identifying the name of the class
  69713. * @returns "DisplayPassPostProcess" string
  69714. */
  69715. getClassName(): string;
  69716. /**
  69717. * Creates the DisplayPassPostProcess
  69718. * @param name The name of the effect.
  69719. * @param options The required width/height ratio to downsize to before computing the render pass.
  69720. * @param camera The camera to apply the render pass to.
  69721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69722. * @param engine The engine which the post process will be applied. (default: current engine)
  69723. * @param reusable If the post process can be reused on the same frame. (default: false)
  69724. */
  69725. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69726. /** @hidden */
  69727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69728. }
  69729. }
  69730. declare module BABYLON {
  69731. /** @hidden */
  69732. export var filterPixelShader: {
  69733. name: string;
  69734. shader: string;
  69735. };
  69736. }
  69737. declare module BABYLON {
  69738. /**
  69739. * Applies a kernel filter to the image
  69740. */
  69741. export class FilterPostProcess extends PostProcess {
  69742. /** The matrix to be applied to the image */
  69743. kernelMatrix: Matrix;
  69744. /**
  69745. * Gets a string identifying the name of the class
  69746. * @returns "FilterPostProcess" string
  69747. */
  69748. getClassName(): string;
  69749. /**
  69750. *
  69751. * @param name The name of the effect.
  69752. * @param kernelMatrix The matrix to be applied to the image
  69753. * @param options The required width/height ratio to downsize to before computing the render pass.
  69754. * @param camera The camera to apply the render pass to.
  69755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69756. * @param engine The engine which the post process will be applied. (default: current engine)
  69757. * @param reusable If the post process can be reused on the same frame. (default: false)
  69758. */
  69759. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69760. /** @hidden */
  69761. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69762. }
  69763. }
  69764. declare module BABYLON {
  69765. /** @hidden */
  69766. export var fxaaPixelShader: {
  69767. name: string;
  69768. shader: string;
  69769. };
  69770. }
  69771. declare module BABYLON {
  69772. /** @hidden */
  69773. export var fxaaVertexShader: {
  69774. name: string;
  69775. shader: string;
  69776. };
  69777. }
  69778. declare module BABYLON {
  69779. /**
  69780. * Fxaa post process
  69781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69782. */
  69783. export class FxaaPostProcess extends PostProcess {
  69784. /**
  69785. * Gets a string identifying the name of the class
  69786. * @returns "FxaaPostProcess" string
  69787. */
  69788. getClassName(): string;
  69789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69790. private _getDefines;
  69791. /** @hidden */
  69792. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /** @hidden */
  69797. export var grainPixelShader: {
  69798. name: string;
  69799. shader: string;
  69800. };
  69801. }
  69802. declare module BABYLON {
  69803. /**
  69804. * The GrainPostProcess adds noise to the image at mid luminance levels
  69805. */
  69806. export class GrainPostProcess extends PostProcess {
  69807. /**
  69808. * The intensity of the grain added (default: 30)
  69809. */
  69810. intensity: number;
  69811. /**
  69812. * If the grain should be randomized on every frame
  69813. */
  69814. animated: boolean;
  69815. /**
  69816. * Gets a string identifying the name of the class
  69817. * @returns "GrainPostProcess" string
  69818. */
  69819. getClassName(): string;
  69820. /**
  69821. * Creates a new instance of @see GrainPostProcess
  69822. * @param name The name of the effect.
  69823. * @param options The required width/height ratio to downsize to before computing the render pass.
  69824. * @param camera The camera to apply the render pass to.
  69825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69826. * @param engine The engine which the post process will be applied. (default: current engine)
  69827. * @param reusable If the post process can be reused on the same frame. (default: false)
  69828. * @param textureType Type of textures used when performing the post process. (default: 0)
  69829. * @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)
  69830. */
  69831. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69832. /** @hidden */
  69833. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69834. }
  69835. }
  69836. declare module BABYLON {
  69837. /** @hidden */
  69838. export var highlightsPixelShader: {
  69839. name: string;
  69840. shader: string;
  69841. };
  69842. }
  69843. declare module BABYLON {
  69844. /**
  69845. * Extracts highlights from the image
  69846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69847. */
  69848. export class HighlightsPostProcess extends PostProcess {
  69849. /**
  69850. * Gets a string identifying the name of the class
  69851. * @returns "HighlightsPostProcess" string
  69852. */
  69853. getClassName(): string;
  69854. /**
  69855. * Extracts highlights from the image
  69856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69857. * @param name The name of the effect.
  69858. * @param options The required width/height ratio to downsize to before computing the render pass.
  69859. * @param camera The camera to apply the render pass to.
  69860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69861. * @param engine The engine which the post process will be applied. (default: current engine)
  69862. * @param reusable If the post process can be reused on the same frame. (default: false)
  69863. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69864. */
  69865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69866. }
  69867. }
  69868. declare module BABYLON {
  69869. /** @hidden */
  69870. export var mrtFragmentDeclaration: {
  69871. name: string;
  69872. shader: string;
  69873. };
  69874. }
  69875. declare module BABYLON {
  69876. /** @hidden */
  69877. export var geometryPixelShader: {
  69878. name: string;
  69879. shader: string;
  69880. };
  69881. }
  69882. declare module BABYLON {
  69883. /** @hidden */
  69884. export var geometryVertexShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module BABYLON {
  69890. /** @hidden */
  69891. interface ISavedTransformationMatrix {
  69892. world: Matrix;
  69893. viewProjection: Matrix;
  69894. }
  69895. /**
  69896. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69897. */
  69898. export class GeometryBufferRenderer {
  69899. /**
  69900. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69901. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69902. */
  69903. static readonly POSITION_TEXTURE_TYPE: number;
  69904. /**
  69905. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69906. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69907. */
  69908. static readonly VELOCITY_TEXTURE_TYPE: number;
  69909. /**
  69910. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69911. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69912. */
  69913. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69914. /**
  69915. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69916. * in order to compute objects velocities when enableVelocity is set to "true"
  69917. * @hidden
  69918. */
  69919. _previousTransformationMatrices: {
  69920. [index: number]: ISavedTransformationMatrix;
  69921. };
  69922. /**
  69923. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69924. * in order to compute objects velocities when enableVelocity is set to "true"
  69925. * @hidden
  69926. */
  69927. _previousBonesTransformationMatrices: {
  69928. [index: number]: Float32Array;
  69929. };
  69930. /**
  69931. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69932. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69933. */
  69934. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69935. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69936. renderTransparentMeshes: boolean;
  69937. private _scene;
  69938. private _resizeObserver;
  69939. private _multiRenderTarget;
  69940. private _ratio;
  69941. private _enablePosition;
  69942. private _enableVelocity;
  69943. private _enableReflectivity;
  69944. private _positionIndex;
  69945. private _velocityIndex;
  69946. private _reflectivityIndex;
  69947. protected _effect: Effect;
  69948. protected _cachedDefines: string;
  69949. /**
  69950. * Set the render list (meshes to be rendered) used in the G buffer.
  69951. */
  69952. set renderList(meshes: Mesh[]);
  69953. /**
  69954. * Gets wether or not G buffer are supported by the running hardware.
  69955. * This requires draw buffer supports
  69956. */
  69957. get isSupported(): boolean;
  69958. /**
  69959. * Returns the index of the given texture type in the G-Buffer textures array
  69960. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69961. * @returns the index of the given texture type in the G-Buffer textures array
  69962. */
  69963. getTextureIndex(textureType: number): number;
  69964. /**
  69965. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69966. */
  69967. get enablePosition(): boolean;
  69968. /**
  69969. * Sets whether or not objects positions are enabled for the G buffer.
  69970. */
  69971. set enablePosition(enable: boolean);
  69972. /**
  69973. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69974. */
  69975. get enableVelocity(): boolean;
  69976. /**
  69977. * Sets wether or not objects velocities are enabled for the G buffer.
  69978. */
  69979. set enableVelocity(enable: boolean);
  69980. /**
  69981. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69982. */
  69983. get enableReflectivity(): boolean;
  69984. /**
  69985. * Sets wether or not objects roughness are enabled for the G buffer.
  69986. */
  69987. set enableReflectivity(enable: boolean);
  69988. /**
  69989. * Gets the scene associated with the buffer.
  69990. */
  69991. get scene(): Scene;
  69992. /**
  69993. * Gets the ratio used by the buffer during its creation.
  69994. * How big is the buffer related to the main canvas.
  69995. */
  69996. get ratio(): number;
  69997. /** @hidden */
  69998. static _SceneComponentInitialization: (scene: Scene) => void;
  69999. /**
  70000. * Creates a new G Buffer for the scene
  70001. * @param scene The scene the buffer belongs to
  70002. * @param ratio How big is the buffer related to the main canvas.
  70003. */
  70004. constructor(scene: Scene, ratio?: number);
  70005. /**
  70006. * Checks wether everything is ready to render a submesh to the G buffer.
  70007. * @param subMesh the submesh to check readiness for
  70008. * @param useInstances is the mesh drawn using instance or not
  70009. * @returns true if ready otherwise false
  70010. */
  70011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70012. /**
  70013. * Gets the current underlying G Buffer.
  70014. * @returns the buffer
  70015. */
  70016. getGBuffer(): MultiRenderTarget;
  70017. /**
  70018. * Gets the number of samples used to render the buffer (anti aliasing).
  70019. */
  70020. get samples(): number;
  70021. /**
  70022. * Sets the number of samples used to render the buffer (anti aliasing).
  70023. */
  70024. set samples(value: number);
  70025. /**
  70026. * Disposes the renderer and frees up associated resources.
  70027. */
  70028. dispose(): void;
  70029. protected _createRenderTargets(): void;
  70030. private _copyBonesTransformationMatrices;
  70031. }
  70032. }
  70033. declare module BABYLON {
  70034. interface Scene {
  70035. /** @hidden (Backing field) */
  70036. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70037. /**
  70038. * Gets or Sets the current geometry buffer associated to the scene.
  70039. */
  70040. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70041. /**
  70042. * Enables a GeometryBufferRender and associates it with the scene
  70043. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70044. * @returns the GeometryBufferRenderer
  70045. */
  70046. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70047. /**
  70048. * Disables the GeometryBufferRender associated with the scene
  70049. */
  70050. disableGeometryBufferRenderer(): void;
  70051. }
  70052. /**
  70053. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70054. * in several rendering techniques.
  70055. */
  70056. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70057. /**
  70058. * The component name helpful to identify the component in the list of scene components.
  70059. */
  70060. readonly name: string;
  70061. /**
  70062. * The scene the component belongs to.
  70063. */
  70064. scene: Scene;
  70065. /**
  70066. * Creates a new instance of the component for the given scene
  70067. * @param scene Defines the scene to register the component in
  70068. */
  70069. constructor(scene: Scene);
  70070. /**
  70071. * Registers the component in a given scene
  70072. */
  70073. register(): void;
  70074. /**
  70075. * Rebuilds the elements related to this component in case of
  70076. * context lost for instance.
  70077. */
  70078. rebuild(): void;
  70079. /**
  70080. * Disposes the component and the associated ressources
  70081. */
  70082. dispose(): void;
  70083. private _gatherRenderTargets;
  70084. }
  70085. }
  70086. declare module BABYLON {
  70087. /** @hidden */
  70088. export var motionBlurPixelShader: {
  70089. name: string;
  70090. shader: string;
  70091. };
  70092. }
  70093. declare module BABYLON {
  70094. /**
  70095. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70096. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70097. * As an example, all you have to do is to create the post-process:
  70098. * var mb = new BABYLON.MotionBlurPostProcess(
  70099. * 'mb', // The name of the effect.
  70100. * scene, // The scene containing the objects to blur according to their velocity.
  70101. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70102. * camera // The camera to apply the render pass to.
  70103. * );
  70104. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70105. */
  70106. export class MotionBlurPostProcess extends PostProcess {
  70107. /**
  70108. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70109. */
  70110. motionStrength: number;
  70111. /**
  70112. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70113. */
  70114. get motionBlurSamples(): number;
  70115. /**
  70116. * Sets the number of iterations to be used for motion blur quality
  70117. */
  70118. set motionBlurSamples(samples: number);
  70119. private _motionBlurSamples;
  70120. private _geometryBufferRenderer;
  70121. /**
  70122. * Gets a string identifying the name of the class
  70123. * @returns "MotionBlurPostProcess" string
  70124. */
  70125. getClassName(): string;
  70126. /**
  70127. * Creates a new instance MotionBlurPostProcess
  70128. * @param name The name of the effect.
  70129. * @param scene The scene containing the objects to blur according to their velocity.
  70130. * @param options The required width/height ratio to downsize to before computing the render pass.
  70131. * @param camera The camera to apply the render pass to.
  70132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70133. * @param engine The engine which the post process will be applied. (default: current engine)
  70134. * @param reusable If the post process can be reused on the same frame. (default: false)
  70135. * @param textureType Type of textures used when performing the post process. (default: 0)
  70136. * @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)
  70137. */
  70138. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70139. /**
  70140. * Excludes the given skinned mesh from computing bones velocities.
  70141. * 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.
  70142. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70143. */
  70144. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70145. /**
  70146. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70147. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70148. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70149. */
  70150. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70151. /**
  70152. * Disposes the post process.
  70153. * @param camera The camera to dispose the post process on.
  70154. */
  70155. dispose(camera?: Camera): void;
  70156. /** @hidden */
  70157. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70158. }
  70159. }
  70160. declare module BABYLON {
  70161. /** @hidden */
  70162. export var refractionPixelShader: {
  70163. name: string;
  70164. shader: string;
  70165. };
  70166. }
  70167. declare module BABYLON {
  70168. /**
  70169. * Post process which applies a refractin texture
  70170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70171. */
  70172. export class RefractionPostProcess extends PostProcess {
  70173. private _refTexture;
  70174. private _ownRefractionTexture;
  70175. /** the base color of the refraction (used to taint the rendering) */
  70176. color: Color3;
  70177. /** simulated refraction depth */
  70178. depth: number;
  70179. /** the coefficient of the base color (0 to remove base color tainting) */
  70180. colorLevel: number;
  70181. /** Gets the url used to load the refraction texture */
  70182. refractionTextureUrl: string;
  70183. /**
  70184. * Gets or sets the refraction texture
  70185. * Please note that you are responsible for disposing the texture if you set it manually
  70186. */
  70187. get refractionTexture(): Texture;
  70188. set refractionTexture(value: Texture);
  70189. /**
  70190. * Gets a string identifying the name of the class
  70191. * @returns "RefractionPostProcess" string
  70192. */
  70193. getClassName(): string;
  70194. /**
  70195. * Initializes the RefractionPostProcess
  70196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70197. * @param name The name of the effect.
  70198. * @param refractionTextureUrl Url of the refraction texture to use
  70199. * @param color the base color of the refraction (used to taint the rendering)
  70200. * @param depth simulated refraction depth
  70201. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70202. * @param camera The camera to apply the render pass to.
  70203. * @param options The required width/height ratio to downsize to before computing the render pass.
  70204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70205. * @param engine The engine which the post process will be applied. (default: current engine)
  70206. * @param reusable If the post process can be reused on the same frame. (default: false)
  70207. */
  70208. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70209. /**
  70210. * Disposes of the post process
  70211. * @param camera Camera to dispose post process on
  70212. */
  70213. dispose(camera: Camera): void;
  70214. /** @hidden */
  70215. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70216. }
  70217. }
  70218. declare module BABYLON {
  70219. /** @hidden */
  70220. export var sharpenPixelShader: {
  70221. name: string;
  70222. shader: string;
  70223. };
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70228. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70229. */
  70230. export class SharpenPostProcess extends PostProcess {
  70231. /**
  70232. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70233. */
  70234. colorAmount: number;
  70235. /**
  70236. * How much sharpness should be applied (default: 0.3)
  70237. */
  70238. edgeAmount: number;
  70239. /**
  70240. * Gets a string identifying the name of the class
  70241. * @returns "SharpenPostProcess" string
  70242. */
  70243. getClassName(): string;
  70244. /**
  70245. * Creates a new instance ConvolutionPostProcess
  70246. * @param name The name of the effect.
  70247. * @param options The required width/height ratio to downsize to before computing the render pass.
  70248. * @param camera The camera to apply the render pass to.
  70249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70250. * @param engine The engine which the post process will be applied. (default: current engine)
  70251. * @param reusable If the post process can be reused on the same frame. (default: false)
  70252. * @param textureType Type of textures used when performing the post process. (default: 0)
  70253. * @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)
  70254. */
  70255. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70256. /** @hidden */
  70257. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70258. }
  70259. }
  70260. declare module BABYLON {
  70261. /**
  70262. * PostProcessRenderPipeline
  70263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70264. */
  70265. export class PostProcessRenderPipeline {
  70266. private engine;
  70267. private _renderEffects;
  70268. private _renderEffectsForIsolatedPass;
  70269. /**
  70270. * List of inspectable custom properties (used by the Inspector)
  70271. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70272. */
  70273. inspectableCustomProperties: IInspectable[];
  70274. /**
  70275. * @hidden
  70276. */
  70277. protected _cameras: Camera[];
  70278. /** @hidden */
  70279. _name: string;
  70280. /**
  70281. * Gets pipeline name
  70282. */
  70283. get name(): string;
  70284. /** Gets the list of attached cameras */
  70285. get cameras(): Camera[];
  70286. /**
  70287. * Initializes a PostProcessRenderPipeline
  70288. * @param engine engine to add the pipeline to
  70289. * @param name name of the pipeline
  70290. */
  70291. constructor(engine: Engine, name: string);
  70292. /**
  70293. * Gets the class name
  70294. * @returns "PostProcessRenderPipeline"
  70295. */
  70296. getClassName(): string;
  70297. /**
  70298. * If all the render effects in the pipeline are supported
  70299. */
  70300. get isSupported(): boolean;
  70301. /**
  70302. * Adds an effect to the pipeline
  70303. * @param renderEffect the effect to add
  70304. */
  70305. addEffect(renderEffect: PostProcessRenderEffect): void;
  70306. /** @hidden */
  70307. _rebuild(): void;
  70308. /** @hidden */
  70309. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70310. /** @hidden */
  70311. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70312. /** @hidden */
  70313. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70314. /** @hidden */
  70315. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70316. /** @hidden */
  70317. _attachCameras(cameras: Camera, unique: boolean): void;
  70318. /** @hidden */
  70319. _attachCameras(cameras: Camera[], unique: boolean): void;
  70320. /** @hidden */
  70321. _detachCameras(cameras: Camera): void;
  70322. /** @hidden */
  70323. _detachCameras(cameras: Nullable<Camera[]>): void;
  70324. /** @hidden */
  70325. _update(): void;
  70326. /** @hidden */
  70327. _reset(): void;
  70328. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70329. /**
  70330. * Sets the required values to the prepass renderer.
  70331. * @param prePassRenderer defines the prepass renderer to setup.
  70332. * @returns true if the pre pass is needed.
  70333. */
  70334. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70335. /**
  70336. * Disposes of the pipeline
  70337. */
  70338. dispose(): void;
  70339. }
  70340. }
  70341. declare module BABYLON {
  70342. /**
  70343. * PostProcessRenderPipelineManager class
  70344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70345. */
  70346. export class PostProcessRenderPipelineManager {
  70347. private _renderPipelines;
  70348. /**
  70349. * Initializes a PostProcessRenderPipelineManager
  70350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70351. */
  70352. constructor();
  70353. /**
  70354. * Gets the list of supported render pipelines
  70355. */
  70356. get supportedPipelines(): PostProcessRenderPipeline[];
  70357. /**
  70358. * Adds a pipeline to the manager
  70359. * @param renderPipeline The pipeline to add
  70360. */
  70361. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70362. /**
  70363. * Attaches a camera to the pipeline
  70364. * @param renderPipelineName The name of the pipeline to attach to
  70365. * @param cameras the camera to attach
  70366. * @param unique if the camera can be attached multiple times to the pipeline
  70367. */
  70368. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70369. /**
  70370. * Detaches a camera from the pipeline
  70371. * @param renderPipelineName The name of the pipeline to detach from
  70372. * @param cameras the camera to detach
  70373. */
  70374. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70375. /**
  70376. * Enables an effect by name on a pipeline
  70377. * @param renderPipelineName the name of the pipeline to enable the effect in
  70378. * @param renderEffectName the name of the effect to enable
  70379. * @param cameras the cameras that the effect should be enabled on
  70380. */
  70381. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70382. /**
  70383. * Disables an effect by name on a pipeline
  70384. * @param renderPipelineName the name of the pipeline to disable the effect in
  70385. * @param renderEffectName the name of the effect to disable
  70386. * @param cameras the cameras that the effect should be disabled on
  70387. */
  70388. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70389. /**
  70390. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70391. */
  70392. update(): void;
  70393. /** @hidden */
  70394. _rebuild(): void;
  70395. /**
  70396. * Disposes of the manager and pipelines
  70397. */
  70398. dispose(): void;
  70399. }
  70400. }
  70401. declare module BABYLON {
  70402. interface Scene {
  70403. /** @hidden (Backing field) */
  70404. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70405. /**
  70406. * Gets the postprocess render pipeline manager
  70407. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70408. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70409. */
  70410. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70411. }
  70412. /**
  70413. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70414. */
  70415. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70416. /**
  70417. * The component name helpfull to identify the component in the list of scene components.
  70418. */
  70419. readonly name: string;
  70420. /**
  70421. * The scene the component belongs to.
  70422. */
  70423. scene: Scene;
  70424. /**
  70425. * Creates a new instance of the component for the given scene
  70426. * @param scene Defines the scene to register the component in
  70427. */
  70428. constructor(scene: Scene);
  70429. /**
  70430. * Registers the component in a given scene
  70431. */
  70432. register(): void;
  70433. /**
  70434. * Rebuilds the elements related to this component in case of
  70435. * context lost for instance.
  70436. */
  70437. rebuild(): void;
  70438. /**
  70439. * Disposes the component and the associated ressources
  70440. */
  70441. dispose(): void;
  70442. private _gatherRenderTargets;
  70443. }
  70444. }
  70445. declare module BABYLON {
  70446. /**
  70447. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70448. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70449. */
  70450. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70451. private _scene;
  70452. private _camerasToBeAttached;
  70453. /**
  70454. * ID of the sharpen post process,
  70455. */
  70456. private readonly SharpenPostProcessId;
  70457. /**
  70458. * @ignore
  70459. * ID of the image processing post process;
  70460. */
  70461. readonly ImageProcessingPostProcessId: string;
  70462. /**
  70463. * @ignore
  70464. * ID of the Fast Approximate Anti-Aliasing post process;
  70465. */
  70466. readonly FxaaPostProcessId: string;
  70467. /**
  70468. * ID of the chromatic aberration post process,
  70469. */
  70470. private readonly ChromaticAberrationPostProcessId;
  70471. /**
  70472. * ID of the grain post process
  70473. */
  70474. private readonly GrainPostProcessId;
  70475. /**
  70476. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70477. */
  70478. sharpen: SharpenPostProcess;
  70479. private _sharpenEffect;
  70480. private bloom;
  70481. /**
  70482. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70483. */
  70484. depthOfField: DepthOfFieldEffect;
  70485. /**
  70486. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70487. */
  70488. fxaa: FxaaPostProcess;
  70489. /**
  70490. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70491. */
  70492. imageProcessing: ImageProcessingPostProcess;
  70493. /**
  70494. * Chromatic aberration post process which will shift rgb colors in the image
  70495. */
  70496. chromaticAberration: ChromaticAberrationPostProcess;
  70497. private _chromaticAberrationEffect;
  70498. /**
  70499. * Grain post process which add noise to the image
  70500. */
  70501. grain: GrainPostProcess;
  70502. private _grainEffect;
  70503. /**
  70504. * Glow post process which adds a glow to emissive areas of the image
  70505. */
  70506. private _glowLayer;
  70507. /**
  70508. * Animations which can be used to tweak settings over a period of time
  70509. */
  70510. animations: Animation[];
  70511. private _imageProcessingConfigurationObserver;
  70512. private _sharpenEnabled;
  70513. private _bloomEnabled;
  70514. private _depthOfFieldEnabled;
  70515. private _depthOfFieldBlurLevel;
  70516. private _fxaaEnabled;
  70517. private _imageProcessingEnabled;
  70518. private _defaultPipelineTextureType;
  70519. private _bloomScale;
  70520. private _chromaticAberrationEnabled;
  70521. private _grainEnabled;
  70522. private _buildAllowed;
  70523. /**
  70524. * Gets active scene
  70525. */
  70526. get scene(): Scene;
  70527. /**
  70528. * Enable or disable the sharpen process from the pipeline
  70529. */
  70530. set sharpenEnabled(enabled: boolean);
  70531. get sharpenEnabled(): boolean;
  70532. private _resizeObserver;
  70533. private _hardwareScaleLevel;
  70534. private _bloomKernel;
  70535. /**
  70536. * Specifies the size of the bloom blur kernel, relative to the final output size
  70537. */
  70538. get bloomKernel(): number;
  70539. set bloomKernel(value: number);
  70540. /**
  70541. * Specifies the weight of the bloom in the final rendering
  70542. */
  70543. private _bloomWeight;
  70544. /**
  70545. * Specifies the luma threshold for the area that will be blurred by the bloom
  70546. */
  70547. private _bloomThreshold;
  70548. private _hdr;
  70549. /**
  70550. * The strength of the bloom.
  70551. */
  70552. set bloomWeight(value: number);
  70553. get bloomWeight(): number;
  70554. /**
  70555. * The strength of the bloom.
  70556. */
  70557. set bloomThreshold(value: number);
  70558. get bloomThreshold(): number;
  70559. /**
  70560. * The scale of the bloom, lower value will provide better performance.
  70561. */
  70562. set bloomScale(value: number);
  70563. get bloomScale(): number;
  70564. /**
  70565. * Enable or disable the bloom from the pipeline
  70566. */
  70567. set bloomEnabled(enabled: boolean);
  70568. get bloomEnabled(): boolean;
  70569. private _rebuildBloom;
  70570. /**
  70571. * If the depth of field is enabled.
  70572. */
  70573. get depthOfFieldEnabled(): boolean;
  70574. set depthOfFieldEnabled(enabled: boolean);
  70575. /**
  70576. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70577. */
  70578. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70579. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70580. /**
  70581. * If the anti aliasing is enabled.
  70582. */
  70583. set fxaaEnabled(enabled: boolean);
  70584. get fxaaEnabled(): boolean;
  70585. private _samples;
  70586. /**
  70587. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70588. */
  70589. set samples(sampleCount: number);
  70590. get samples(): number;
  70591. /**
  70592. * If image processing is enabled.
  70593. */
  70594. set imageProcessingEnabled(enabled: boolean);
  70595. get imageProcessingEnabled(): boolean;
  70596. /**
  70597. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70598. */
  70599. set glowLayerEnabled(enabled: boolean);
  70600. get glowLayerEnabled(): boolean;
  70601. /**
  70602. * Gets the glow layer (or null if not defined)
  70603. */
  70604. get glowLayer(): Nullable<GlowLayer>;
  70605. /**
  70606. * Enable or disable the chromaticAberration process from the pipeline
  70607. */
  70608. set chromaticAberrationEnabled(enabled: boolean);
  70609. get chromaticAberrationEnabled(): boolean;
  70610. /**
  70611. * Enable or disable the grain process from the pipeline
  70612. */
  70613. set grainEnabled(enabled: boolean);
  70614. get grainEnabled(): boolean;
  70615. /**
  70616. * @constructor
  70617. * @param name - The rendering pipeline name (default: "")
  70618. * @param hdr - If high dynamic range textures should be used (default: true)
  70619. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70620. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70621. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70622. */
  70623. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70624. /**
  70625. * Get the class name
  70626. * @returns "DefaultRenderingPipeline"
  70627. */
  70628. getClassName(): string;
  70629. /**
  70630. * Force the compilation of the entire pipeline.
  70631. */
  70632. prepare(): void;
  70633. private _hasCleared;
  70634. private _prevPostProcess;
  70635. private _prevPrevPostProcess;
  70636. private _setAutoClearAndTextureSharing;
  70637. private _depthOfFieldSceneObserver;
  70638. private _buildPipeline;
  70639. private _disposePostProcesses;
  70640. /**
  70641. * Adds a camera to the pipeline
  70642. * @param camera the camera to be added
  70643. */
  70644. addCamera(camera: Camera): void;
  70645. /**
  70646. * Removes a camera from the pipeline
  70647. * @param camera the camera to remove
  70648. */
  70649. removeCamera(camera: Camera): void;
  70650. /**
  70651. * Dispose of the pipeline and stop all post processes
  70652. */
  70653. dispose(): void;
  70654. /**
  70655. * Serialize the rendering pipeline (Used when exporting)
  70656. * @returns the serialized object
  70657. */
  70658. serialize(): any;
  70659. /**
  70660. * Parse the serialized pipeline
  70661. * @param source Source pipeline.
  70662. * @param scene The scene to load the pipeline to.
  70663. * @param rootUrl The URL of the serialized pipeline.
  70664. * @returns An instantiated pipeline from the serialized object.
  70665. */
  70666. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70667. }
  70668. }
  70669. declare module BABYLON {
  70670. /** @hidden */
  70671. export var lensHighlightsPixelShader: {
  70672. name: string;
  70673. shader: string;
  70674. };
  70675. }
  70676. declare module BABYLON {
  70677. /** @hidden */
  70678. export var depthOfFieldPixelShader: {
  70679. name: string;
  70680. shader: string;
  70681. };
  70682. }
  70683. declare module BABYLON {
  70684. /**
  70685. * BABYLON.JS Chromatic Aberration GLSL Shader
  70686. * Author: Olivier Guyot
  70687. * Separates very slightly R, G and B colors on the edges of the screen
  70688. * Inspired by Francois Tarlier & Martins Upitis
  70689. */
  70690. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70691. /**
  70692. * @ignore
  70693. * The chromatic aberration PostProcess id in the pipeline
  70694. */
  70695. LensChromaticAberrationEffect: string;
  70696. /**
  70697. * @ignore
  70698. * The highlights enhancing PostProcess id in the pipeline
  70699. */
  70700. HighlightsEnhancingEffect: string;
  70701. /**
  70702. * @ignore
  70703. * The depth-of-field PostProcess id in the pipeline
  70704. */
  70705. LensDepthOfFieldEffect: string;
  70706. private _scene;
  70707. private _depthTexture;
  70708. private _grainTexture;
  70709. private _chromaticAberrationPostProcess;
  70710. private _highlightsPostProcess;
  70711. private _depthOfFieldPostProcess;
  70712. private _edgeBlur;
  70713. private _grainAmount;
  70714. private _chromaticAberration;
  70715. private _distortion;
  70716. private _highlightsGain;
  70717. private _highlightsThreshold;
  70718. private _dofDistance;
  70719. private _dofAperture;
  70720. private _dofDarken;
  70721. private _dofPentagon;
  70722. private _blurNoise;
  70723. /**
  70724. * @constructor
  70725. *
  70726. * Effect parameters are as follow:
  70727. * {
  70728. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70729. * edge_blur: number; // from 0 to x (1 for realism)
  70730. * distortion: number; // from 0 to x (1 for realism)
  70731. * grain_amount: number; // from 0 to 1
  70732. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70733. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70734. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70735. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70736. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70737. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70738. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70739. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70740. * }
  70741. * Note: if an effect parameter is unset, effect is disabled
  70742. *
  70743. * @param name The rendering pipeline name
  70744. * @param parameters - An object containing all parameters (see above)
  70745. * @param scene The scene linked to this pipeline
  70746. * @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)
  70747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70748. */
  70749. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70750. /**
  70751. * Get the class name
  70752. * @returns "LensRenderingPipeline"
  70753. */
  70754. getClassName(): string;
  70755. /**
  70756. * Gets associated scene
  70757. */
  70758. get scene(): Scene;
  70759. /**
  70760. * Gets or sets the edge blur
  70761. */
  70762. get edgeBlur(): number;
  70763. set edgeBlur(value: number);
  70764. /**
  70765. * Gets or sets the grain amount
  70766. */
  70767. get grainAmount(): number;
  70768. set grainAmount(value: number);
  70769. /**
  70770. * Gets or sets the chromatic aberration amount
  70771. */
  70772. get chromaticAberration(): number;
  70773. set chromaticAberration(value: number);
  70774. /**
  70775. * Gets or sets the depth of field aperture
  70776. */
  70777. get dofAperture(): number;
  70778. set dofAperture(value: number);
  70779. /**
  70780. * Gets or sets the edge distortion
  70781. */
  70782. get edgeDistortion(): number;
  70783. set edgeDistortion(value: number);
  70784. /**
  70785. * Gets or sets the depth of field distortion
  70786. */
  70787. get dofDistortion(): number;
  70788. set dofDistortion(value: number);
  70789. /**
  70790. * Gets or sets the darken out of focus amount
  70791. */
  70792. get darkenOutOfFocus(): number;
  70793. set darkenOutOfFocus(value: number);
  70794. /**
  70795. * Gets or sets a boolean indicating if blur noise is enabled
  70796. */
  70797. get blurNoise(): boolean;
  70798. set blurNoise(value: boolean);
  70799. /**
  70800. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70801. */
  70802. get pentagonBokeh(): boolean;
  70803. set pentagonBokeh(value: boolean);
  70804. /**
  70805. * Gets or sets the highlight grain amount
  70806. */
  70807. get highlightsGain(): number;
  70808. set highlightsGain(value: number);
  70809. /**
  70810. * Gets or sets the highlight threshold
  70811. */
  70812. get highlightsThreshold(): number;
  70813. set highlightsThreshold(value: number);
  70814. /**
  70815. * Sets the amount of blur at the edges
  70816. * @param amount blur amount
  70817. */
  70818. setEdgeBlur(amount: number): void;
  70819. /**
  70820. * Sets edge blur to 0
  70821. */
  70822. disableEdgeBlur(): void;
  70823. /**
  70824. * Sets the amout of grain
  70825. * @param amount Amount of grain
  70826. */
  70827. setGrainAmount(amount: number): void;
  70828. /**
  70829. * Set grain amount to 0
  70830. */
  70831. disableGrain(): void;
  70832. /**
  70833. * Sets the chromatic aberration amount
  70834. * @param amount amount of chromatic aberration
  70835. */
  70836. setChromaticAberration(amount: number): void;
  70837. /**
  70838. * Sets chromatic aberration amount to 0
  70839. */
  70840. disableChromaticAberration(): void;
  70841. /**
  70842. * Sets the EdgeDistortion amount
  70843. * @param amount amount of EdgeDistortion
  70844. */
  70845. setEdgeDistortion(amount: number): void;
  70846. /**
  70847. * Sets edge distortion to 0
  70848. */
  70849. disableEdgeDistortion(): void;
  70850. /**
  70851. * Sets the FocusDistance amount
  70852. * @param amount amount of FocusDistance
  70853. */
  70854. setFocusDistance(amount: number): void;
  70855. /**
  70856. * Disables depth of field
  70857. */
  70858. disableDepthOfField(): void;
  70859. /**
  70860. * Sets the Aperture amount
  70861. * @param amount amount of Aperture
  70862. */
  70863. setAperture(amount: number): void;
  70864. /**
  70865. * Sets the DarkenOutOfFocus amount
  70866. * @param amount amount of DarkenOutOfFocus
  70867. */
  70868. setDarkenOutOfFocus(amount: number): void;
  70869. private _pentagonBokehIsEnabled;
  70870. /**
  70871. * Creates a pentagon bokeh effect
  70872. */
  70873. enablePentagonBokeh(): void;
  70874. /**
  70875. * Disables the pentagon bokeh effect
  70876. */
  70877. disablePentagonBokeh(): void;
  70878. /**
  70879. * Enables noise blur
  70880. */
  70881. enableNoiseBlur(): void;
  70882. /**
  70883. * Disables noise blur
  70884. */
  70885. disableNoiseBlur(): void;
  70886. /**
  70887. * Sets the HighlightsGain amount
  70888. * @param amount amount of HighlightsGain
  70889. */
  70890. setHighlightsGain(amount: number): void;
  70891. /**
  70892. * Sets the HighlightsThreshold amount
  70893. * @param amount amount of HighlightsThreshold
  70894. */
  70895. setHighlightsThreshold(amount: number): void;
  70896. /**
  70897. * Disables highlights
  70898. */
  70899. disableHighlights(): void;
  70900. /**
  70901. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70902. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70903. */
  70904. dispose(disableDepthRender?: boolean): void;
  70905. private _createChromaticAberrationPostProcess;
  70906. private _createHighlightsPostProcess;
  70907. private _createDepthOfFieldPostProcess;
  70908. private _createGrainTexture;
  70909. }
  70910. }
  70911. declare module BABYLON {
  70912. /** @hidden */
  70913. export var ssao2PixelShader: {
  70914. name: string;
  70915. shader: string;
  70916. };
  70917. }
  70918. declare module BABYLON {
  70919. /** @hidden */
  70920. export var ssaoCombinePixelShader: {
  70921. name: string;
  70922. shader: string;
  70923. };
  70924. }
  70925. declare module BABYLON {
  70926. /**
  70927. * Render pipeline to produce ssao effect
  70928. */
  70929. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70930. /**
  70931. * @ignore
  70932. * The PassPostProcess id in the pipeline that contains the original scene color
  70933. */
  70934. SSAOOriginalSceneColorEffect: string;
  70935. /**
  70936. * @ignore
  70937. * The SSAO PostProcess id in the pipeline
  70938. */
  70939. SSAORenderEffect: string;
  70940. /**
  70941. * @ignore
  70942. * The horizontal blur PostProcess id in the pipeline
  70943. */
  70944. SSAOBlurHRenderEffect: string;
  70945. /**
  70946. * @ignore
  70947. * The vertical blur PostProcess id in the pipeline
  70948. */
  70949. SSAOBlurVRenderEffect: string;
  70950. /**
  70951. * @ignore
  70952. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70953. */
  70954. SSAOCombineRenderEffect: string;
  70955. /**
  70956. * The output strength of the SSAO post-process. Default value is 1.0.
  70957. */
  70958. totalStrength: number;
  70959. /**
  70960. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70961. */
  70962. maxZ: number;
  70963. /**
  70964. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70965. */
  70966. minZAspect: number;
  70967. private _samples;
  70968. /**
  70969. * Number of samples used for the SSAO calculations. Default value is 8
  70970. */
  70971. set samples(n: number);
  70972. get samples(): number;
  70973. private _textureSamples;
  70974. /**
  70975. * Number of samples to use for antialiasing
  70976. */
  70977. set textureSamples(n: number);
  70978. get textureSamples(): number;
  70979. /**
  70980. * Force rendering the geometry through geometry buffer
  70981. */
  70982. private _forceGeometryBuffer;
  70983. /**
  70984. * Ratio object used for SSAO ratio and blur ratio
  70985. */
  70986. private _ratio;
  70987. /**
  70988. * Dynamically generated sphere sampler.
  70989. */
  70990. private _sampleSphere;
  70991. /**
  70992. * Blur filter offsets
  70993. */
  70994. private _samplerOffsets;
  70995. private _expensiveBlur;
  70996. /**
  70997. * If bilateral blur should be used
  70998. */
  70999. set expensiveBlur(b: boolean);
  71000. get expensiveBlur(): boolean;
  71001. /**
  71002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71003. */
  71004. radius: number;
  71005. /**
  71006. * The base color of the SSAO post-process
  71007. * The final result is "base + ssao" between [0, 1]
  71008. */
  71009. base: number;
  71010. /**
  71011. * Support test.
  71012. */
  71013. static get IsSupported(): boolean;
  71014. private _scene;
  71015. private _randomTexture;
  71016. private _originalColorPostProcess;
  71017. private _ssaoPostProcess;
  71018. private _blurHPostProcess;
  71019. private _blurVPostProcess;
  71020. private _ssaoCombinePostProcess;
  71021. private _prePassRenderer;
  71022. /**
  71023. * Gets active scene
  71024. */
  71025. get scene(): Scene;
  71026. /**
  71027. * @constructor
  71028. * @param name The rendering pipeline name
  71029. * @param scene The scene linked to this pipeline
  71030. * @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 }
  71031. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71032. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71033. */
  71034. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71035. /**
  71036. * Get the class name
  71037. * @returns "SSAO2RenderingPipeline"
  71038. */
  71039. getClassName(): string;
  71040. /**
  71041. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71042. */
  71043. dispose(disableGeometryBufferRenderer?: boolean): void;
  71044. private _createBlurPostProcess;
  71045. /** @hidden */
  71046. _rebuild(): void;
  71047. private _bits;
  71048. private _radicalInverse_VdC;
  71049. private _hammersley;
  71050. private _hemisphereSample_uniform;
  71051. private _generateHemisphere;
  71052. private _getDefinesForSSAO;
  71053. private _createSSAOPostProcess;
  71054. private _createSSAOCombinePostProcess;
  71055. private _createRandomTexture;
  71056. /**
  71057. * Serialize the rendering pipeline (Used when exporting)
  71058. * @returns the serialized object
  71059. */
  71060. serialize(): any;
  71061. /**
  71062. * Parse the serialized pipeline
  71063. * @param source Source pipeline.
  71064. * @param scene The scene to load the pipeline to.
  71065. * @param rootUrl The URL of the serialized pipeline.
  71066. * @returns An instantiated pipeline from the serialized object.
  71067. */
  71068. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71069. /**
  71070. * Sets the required values to the prepass renderer.
  71071. * @param prePassRenderer defines the prepass renderer to setup
  71072. * @returns true if the pre pass is needed.
  71073. */
  71074. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71075. }
  71076. }
  71077. declare module BABYLON {
  71078. /** @hidden */
  71079. export var ssaoPixelShader: {
  71080. name: string;
  71081. shader: string;
  71082. };
  71083. }
  71084. declare module BABYLON {
  71085. /**
  71086. * Render pipeline to produce ssao effect
  71087. */
  71088. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71089. /**
  71090. * @ignore
  71091. * The PassPostProcess id in the pipeline that contains the original scene color
  71092. */
  71093. SSAOOriginalSceneColorEffect: string;
  71094. /**
  71095. * @ignore
  71096. * The SSAO PostProcess id in the pipeline
  71097. */
  71098. SSAORenderEffect: string;
  71099. /**
  71100. * @ignore
  71101. * The horizontal blur PostProcess id in the pipeline
  71102. */
  71103. SSAOBlurHRenderEffect: string;
  71104. /**
  71105. * @ignore
  71106. * The vertical blur PostProcess id in the pipeline
  71107. */
  71108. SSAOBlurVRenderEffect: string;
  71109. /**
  71110. * @ignore
  71111. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71112. */
  71113. SSAOCombineRenderEffect: string;
  71114. /**
  71115. * The output strength of the SSAO post-process. Default value is 1.0.
  71116. */
  71117. totalStrength: number;
  71118. /**
  71119. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71120. */
  71121. radius: number;
  71122. /**
  71123. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71124. * Must not be equal to fallOff and superior to fallOff.
  71125. * Default value is 0.0075
  71126. */
  71127. area: number;
  71128. /**
  71129. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71130. * Must not be equal to area and inferior to area.
  71131. * Default value is 0.000001
  71132. */
  71133. fallOff: number;
  71134. /**
  71135. * The base color of the SSAO post-process
  71136. * The final result is "base + ssao" between [0, 1]
  71137. */
  71138. base: number;
  71139. private _scene;
  71140. private _depthTexture;
  71141. private _randomTexture;
  71142. private _originalColorPostProcess;
  71143. private _ssaoPostProcess;
  71144. private _blurHPostProcess;
  71145. private _blurVPostProcess;
  71146. private _ssaoCombinePostProcess;
  71147. private _firstUpdate;
  71148. /**
  71149. * Gets active scene
  71150. */
  71151. get scene(): Scene;
  71152. /**
  71153. * @constructor
  71154. * @param name - The rendering pipeline name
  71155. * @param scene - The scene linked to this pipeline
  71156. * @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 }
  71157. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71158. */
  71159. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71160. /**
  71161. * Get the class name
  71162. * @returns "SSAORenderingPipeline"
  71163. */
  71164. getClassName(): string;
  71165. /**
  71166. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71167. */
  71168. dispose(disableDepthRender?: boolean): void;
  71169. private _createBlurPostProcess;
  71170. /** @hidden */
  71171. _rebuild(): void;
  71172. private _createSSAOPostProcess;
  71173. private _createSSAOCombinePostProcess;
  71174. private _createRandomTexture;
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. /** @hidden */
  71179. export var screenSpaceReflectionPixelShader: {
  71180. name: string;
  71181. shader: string;
  71182. };
  71183. }
  71184. declare module BABYLON {
  71185. /**
  71186. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71187. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71188. */
  71189. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71190. /**
  71191. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71192. */
  71193. threshold: number;
  71194. /**
  71195. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71196. */
  71197. strength: number;
  71198. /**
  71199. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71200. */
  71201. reflectionSpecularFalloffExponent: number;
  71202. /**
  71203. * 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]
  71204. */
  71205. step: number;
  71206. /**
  71207. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71208. */
  71209. roughnessFactor: number;
  71210. private _geometryBufferRenderer;
  71211. private _enableSmoothReflections;
  71212. private _reflectionSamples;
  71213. private _smoothSteps;
  71214. /**
  71215. * Gets a string identifying the name of the class
  71216. * @returns "ScreenSpaceReflectionPostProcess" string
  71217. */
  71218. getClassName(): string;
  71219. /**
  71220. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71221. * @param name The name of the effect.
  71222. * @param scene The scene containing the objects to calculate reflections.
  71223. * @param options The required width/height ratio to downsize to before computing the render pass.
  71224. * @param camera The camera to apply the render pass to.
  71225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71226. * @param engine The engine which the post process will be applied. (default: current engine)
  71227. * @param reusable If the post process can be reused on the same frame. (default: false)
  71228. * @param textureType Type of textures used when performing the post process. (default: 0)
  71229. * @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)
  71230. */
  71231. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71232. /**
  71233. * Gets wether or not smoothing reflections is enabled.
  71234. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71235. */
  71236. get enableSmoothReflections(): boolean;
  71237. /**
  71238. * Sets wether or not smoothing reflections is enabled.
  71239. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71240. */
  71241. set enableSmoothReflections(enabled: boolean);
  71242. /**
  71243. * Gets the number of samples taken while computing reflections. More samples count is high,
  71244. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71245. */
  71246. get reflectionSamples(): number;
  71247. /**
  71248. * Sets the number of samples taken while computing reflections. More samples count is high,
  71249. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71250. */
  71251. set reflectionSamples(samples: number);
  71252. /**
  71253. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71254. * more the post-process will require GPU power and can generate a drop in FPS.
  71255. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71256. */
  71257. get smoothSteps(): number;
  71258. set smoothSteps(steps: number);
  71259. private _updateEffectDefines;
  71260. /** @hidden */
  71261. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71262. }
  71263. }
  71264. declare module BABYLON {
  71265. /** @hidden */
  71266. export var standardPixelShader: {
  71267. name: string;
  71268. shader: string;
  71269. };
  71270. }
  71271. declare module BABYLON {
  71272. /**
  71273. * Standard rendering pipeline
  71274. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71275. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71276. */
  71277. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71278. /**
  71279. * Public members
  71280. */
  71281. /**
  71282. * Post-process which contains the original scene color before the pipeline applies all the effects
  71283. */
  71284. originalPostProcess: Nullable<PostProcess>;
  71285. /**
  71286. * Post-process used to down scale an image x4
  71287. */
  71288. downSampleX4PostProcess: Nullable<PostProcess>;
  71289. /**
  71290. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71291. */
  71292. brightPassPostProcess: Nullable<PostProcess>;
  71293. /**
  71294. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71295. */
  71296. blurHPostProcesses: PostProcess[];
  71297. /**
  71298. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71299. */
  71300. blurVPostProcesses: PostProcess[];
  71301. /**
  71302. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71303. */
  71304. textureAdderPostProcess: Nullable<PostProcess>;
  71305. /**
  71306. * Post-process used to create volumetric lighting effect
  71307. */
  71308. volumetricLightPostProcess: Nullable<PostProcess>;
  71309. /**
  71310. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71311. */
  71312. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71313. /**
  71314. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71315. */
  71316. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71317. /**
  71318. * Post-process used to merge the volumetric light effect and the real scene color
  71319. */
  71320. volumetricLightMergePostProces: Nullable<PostProcess>;
  71321. /**
  71322. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71323. */
  71324. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71325. /**
  71326. * Base post-process used to calculate the average luminance of the final image for HDR
  71327. */
  71328. luminancePostProcess: Nullable<PostProcess>;
  71329. /**
  71330. * Post-processes used to create down sample post-processes in order to get
  71331. * the average luminance of the final image for HDR
  71332. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71333. */
  71334. luminanceDownSamplePostProcesses: PostProcess[];
  71335. /**
  71336. * Post-process used to create a HDR effect (light adaptation)
  71337. */
  71338. hdrPostProcess: Nullable<PostProcess>;
  71339. /**
  71340. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71341. */
  71342. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71343. /**
  71344. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71345. */
  71346. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71347. /**
  71348. * Post-process used to merge the final HDR post-process and the real scene color
  71349. */
  71350. hdrFinalPostProcess: Nullable<PostProcess>;
  71351. /**
  71352. * Post-process used to create a lens flare effect
  71353. */
  71354. lensFlarePostProcess: Nullable<PostProcess>;
  71355. /**
  71356. * Post-process that merges the result of the lens flare post-process and the real scene color
  71357. */
  71358. lensFlareComposePostProcess: Nullable<PostProcess>;
  71359. /**
  71360. * Post-process used to create a motion blur effect
  71361. */
  71362. motionBlurPostProcess: Nullable<PostProcess>;
  71363. /**
  71364. * Post-process used to create a depth of field effect
  71365. */
  71366. depthOfFieldPostProcess: Nullable<PostProcess>;
  71367. /**
  71368. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71369. */
  71370. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71371. /**
  71372. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71373. */
  71374. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71375. /**
  71376. * Represents the brightness threshold in order to configure the illuminated surfaces
  71377. */
  71378. brightThreshold: number;
  71379. /**
  71380. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71381. */
  71382. blurWidth: number;
  71383. /**
  71384. * Sets if the blur for highlighted surfaces must be only horizontal
  71385. */
  71386. horizontalBlur: boolean;
  71387. /**
  71388. * Gets the overall exposure used by the pipeline
  71389. */
  71390. get exposure(): number;
  71391. /**
  71392. * Sets the overall exposure used by the pipeline
  71393. */
  71394. set exposure(value: number);
  71395. /**
  71396. * Texture used typically to simulate "dirty" on camera lens
  71397. */
  71398. lensTexture: Nullable<Texture>;
  71399. /**
  71400. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71401. */
  71402. volumetricLightCoefficient: number;
  71403. /**
  71404. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71405. */
  71406. volumetricLightPower: number;
  71407. /**
  71408. * Used the set the blur intensity to smooth the volumetric lights
  71409. */
  71410. volumetricLightBlurScale: number;
  71411. /**
  71412. * Light (spot or directional) used to generate the volumetric lights rays
  71413. * The source light must have a shadow generate so the pipeline can get its
  71414. * depth map
  71415. */
  71416. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71417. /**
  71418. * For eye adaptation, represents the minimum luminance the eye can see
  71419. */
  71420. hdrMinimumLuminance: number;
  71421. /**
  71422. * For eye adaptation, represents the decrease luminance speed
  71423. */
  71424. hdrDecreaseRate: number;
  71425. /**
  71426. * For eye adaptation, represents the increase luminance speed
  71427. */
  71428. hdrIncreaseRate: number;
  71429. /**
  71430. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71431. */
  71432. get hdrAutoExposure(): boolean;
  71433. /**
  71434. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71435. */
  71436. set hdrAutoExposure(value: boolean);
  71437. /**
  71438. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71439. */
  71440. lensColorTexture: Nullable<Texture>;
  71441. /**
  71442. * The overall strengh for the lens flare effect
  71443. */
  71444. lensFlareStrength: number;
  71445. /**
  71446. * Dispersion coefficient for lens flare ghosts
  71447. */
  71448. lensFlareGhostDispersal: number;
  71449. /**
  71450. * Main lens flare halo width
  71451. */
  71452. lensFlareHaloWidth: number;
  71453. /**
  71454. * Based on the lens distortion effect, defines how much the lens flare result
  71455. * is distorted
  71456. */
  71457. lensFlareDistortionStrength: number;
  71458. /**
  71459. * Configures the blur intensity used for for lens flare (halo)
  71460. */
  71461. lensFlareBlurWidth: number;
  71462. /**
  71463. * Lens star texture must be used to simulate rays on the flares and is available
  71464. * in the documentation
  71465. */
  71466. lensStarTexture: Nullable<Texture>;
  71467. /**
  71468. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71469. * flare effect by taking account of the dirt texture
  71470. */
  71471. lensFlareDirtTexture: Nullable<Texture>;
  71472. /**
  71473. * Represents the focal length for the depth of field effect
  71474. */
  71475. depthOfFieldDistance: number;
  71476. /**
  71477. * Represents the blur intensity for the blurred part of the depth of field effect
  71478. */
  71479. depthOfFieldBlurWidth: number;
  71480. /**
  71481. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71482. */
  71483. get motionStrength(): number;
  71484. /**
  71485. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71486. */
  71487. set motionStrength(strength: number);
  71488. /**
  71489. * Gets wether or not the motion blur post-process is object based or screen based.
  71490. */
  71491. get objectBasedMotionBlur(): boolean;
  71492. /**
  71493. * Sets wether or not the motion blur post-process should be object based or screen based
  71494. */
  71495. set objectBasedMotionBlur(value: boolean);
  71496. /**
  71497. * List of animations for the pipeline (IAnimatable implementation)
  71498. */
  71499. animations: Animation[];
  71500. /**
  71501. * Private members
  71502. */
  71503. private _scene;
  71504. private _currentDepthOfFieldSource;
  71505. private _basePostProcess;
  71506. private _fixedExposure;
  71507. private _currentExposure;
  71508. private _hdrAutoExposure;
  71509. private _hdrCurrentLuminance;
  71510. private _motionStrength;
  71511. private _isObjectBasedMotionBlur;
  71512. private _floatTextureType;
  71513. private _camerasToBeAttached;
  71514. private _ratio;
  71515. private _bloomEnabled;
  71516. private _depthOfFieldEnabled;
  71517. private _vlsEnabled;
  71518. private _lensFlareEnabled;
  71519. private _hdrEnabled;
  71520. private _motionBlurEnabled;
  71521. private _fxaaEnabled;
  71522. private _screenSpaceReflectionsEnabled;
  71523. private _motionBlurSamples;
  71524. private _volumetricLightStepsCount;
  71525. private _samples;
  71526. /**
  71527. * @ignore
  71528. * Specifies if the bloom pipeline is enabled
  71529. */
  71530. get BloomEnabled(): boolean;
  71531. set BloomEnabled(enabled: boolean);
  71532. /**
  71533. * @ignore
  71534. * Specifies if the depth of field pipeline is enabed
  71535. */
  71536. get DepthOfFieldEnabled(): boolean;
  71537. set DepthOfFieldEnabled(enabled: boolean);
  71538. /**
  71539. * @ignore
  71540. * Specifies if the lens flare pipeline is enabed
  71541. */
  71542. get LensFlareEnabled(): boolean;
  71543. set LensFlareEnabled(enabled: boolean);
  71544. /**
  71545. * @ignore
  71546. * Specifies if the HDR pipeline is enabled
  71547. */
  71548. get HDREnabled(): boolean;
  71549. set HDREnabled(enabled: boolean);
  71550. /**
  71551. * @ignore
  71552. * Specifies if the volumetric lights scattering effect is enabled
  71553. */
  71554. get VLSEnabled(): boolean;
  71555. set VLSEnabled(enabled: boolean);
  71556. /**
  71557. * @ignore
  71558. * Specifies if the motion blur effect is enabled
  71559. */
  71560. get MotionBlurEnabled(): boolean;
  71561. set MotionBlurEnabled(enabled: boolean);
  71562. /**
  71563. * Specifies if anti-aliasing is enabled
  71564. */
  71565. get fxaaEnabled(): boolean;
  71566. set fxaaEnabled(enabled: boolean);
  71567. /**
  71568. * Specifies if screen space reflections are enabled.
  71569. */
  71570. get screenSpaceReflectionsEnabled(): boolean;
  71571. set screenSpaceReflectionsEnabled(enabled: boolean);
  71572. /**
  71573. * Specifies the number of steps used to calculate the volumetric lights
  71574. * Typically in interval [50, 200]
  71575. */
  71576. get volumetricLightStepsCount(): number;
  71577. set volumetricLightStepsCount(count: number);
  71578. /**
  71579. * Specifies the number of samples used for the motion blur effect
  71580. * Typically in interval [16, 64]
  71581. */
  71582. get motionBlurSamples(): number;
  71583. set motionBlurSamples(samples: number);
  71584. /**
  71585. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71586. */
  71587. get samples(): number;
  71588. set samples(sampleCount: number);
  71589. /**
  71590. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71591. * @constructor
  71592. * @param name The rendering pipeline name
  71593. * @param scene The scene linked to this pipeline
  71594. * @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)
  71595. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71597. */
  71598. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71599. private _buildPipeline;
  71600. private _createDownSampleX4PostProcess;
  71601. private _createBrightPassPostProcess;
  71602. private _createBlurPostProcesses;
  71603. private _createTextureAdderPostProcess;
  71604. private _createVolumetricLightPostProcess;
  71605. private _createLuminancePostProcesses;
  71606. private _createHdrPostProcess;
  71607. private _createLensFlarePostProcess;
  71608. private _createDepthOfFieldPostProcess;
  71609. private _createMotionBlurPostProcess;
  71610. private _getDepthTexture;
  71611. private _disposePostProcesses;
  71612. /**
  71613. * Dispose of the pipeline and stop all post processes
  71614. */
  71615. dispose(): void;
  71616. /**
  71617. * Serialize the rendering pipeline (Used when exporting)
  71618. * @returns the serialized object
  71619. */
  71620. serialize(): any;
  71621. /**
  71622. * Parse the serialized pipeline
  71623. * @param source Source pipeline.
  71624. * @param scene The scene to load the pipeline to.
  71625. * @param rootUrl The URL of the serialized pipeline.
  71626. * @returns An instantiated pipeline from the serialized object.
  71627. */
  71628. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71629. /**
  71630. * Luminance steps
  71631. */
  71632. static LuminanceSteps: number;
  71633. }
  71634. }
  71635. declare module BABYLON {
  71636. /** @hidden */
  71637. export var stereoscopicInterlacePixelShader: {
  71638. name: string;
  71639. shader: string;
  71640. };
  71641. }
  71642. declare module BABYLON {
  71643. /**
  71644. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71645. */
  71646. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71647. private _stepSize;
  71648. private _passedProcess;
  71649. /**
  71650. * Gets a string identifying the name of the class
  71651. * @returns "StereoscopicInterlacePostProcessI" string
  71652. */
  71653. getClassName(): string;
  71654. /**
  71655. * Initializes a StereoscopicInterlacePostProcessI
  71656. * @param name The name of the effect.
  71657. * @param rigCameras The rig cameras to be appled to the post process
  71658. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71659. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71661. * @param engine The engine which the post process will be applied. (default: current engine)
  71662. * @param reusable If the post process can be reused on the same frame. (default: false)
  71663. */
  71664. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71665. }
  71666. /**
  71667. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71668. */
  71669. export class StereoscopicInterlacePostProcess extends PostProcess {
  71670. private _stepSize;
  71671. private _passedProcess;
  71672. /**
  71673. * Gets a string identifying the name of the class
  71674. * @returns "StereoscopicInterlacePostProcess" string
  71675. */
  71676. getClassName(): string;
  71677. /**
  71678. * Initializes a StereoscopicInterlacePostProcess
  71679. * @param name The name of the effect.
  71680. * @param rigCameras The rig cameras to be appled to the post process
  71681. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71683. * @param engine The engine which the post process will be applied. (default: current engine)
  71684. * @param reusable If the post process can be reused on the same frame. (default: false)
  71685. */
  71686. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71687. }
  71688. }
  71689. declare module BABYLON {
  71690. /** @hidden */
  71691. export var tonemapPixelShader: {
  71692. name: string;
  71693. shader: string;
  71694. };
  71695. }
  71696. declare module BABYLON {
  71697. /** Defines operator used for tonemapping */
  71698. export enum TonemappingOperator {
  71699. /** Hable */
  71700. Hable = 0,
  71701. /** Reinhard */
  71702. Reinhard = 1,
  71703. /** HejiDawson */
  71704. HejiDawson = 2,
  71705. /** Photographic */
  71706. Photographic = 3
  71707. }
  71708. /**
  71709. * Defines a post process to apply tone mapping
  71710. */
  71711. export class TonemapPostProcess extends PostProcess {
  71712. private _operator;
  71713. /** Defines the required exposure adjustement */
  71714. exposureAdjustment: number;
  71715. /**
  71716. * Gets a string identifying the name of the class
  71717. * @returns "TonemapPostProcess" string
  71718. */
  71719. getClassName(): string;
  71720. /**
  71721. * Creates a new TonemapPostProcess
  71722. * @param name defines the name of the postprocess
  71723. * @param _operator defines the operator to use
  71724. * @param exposureAdjustment defines the required exposure adjustement
  71725. * @param camera defines the camera to use (can be null)
  71726. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71727. * @param engine defines the hosting engine (can be ignore if camera is set)
  71728. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71729. */
  71730. constructor(name: string, _operator: TonemappingOperator,
  71731. /** Defines the required exposure adjustement */
  71732. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71733. }
  71734. }
  71735. declare module BABYLON {
  71736. /** @hidden */
  71737. export var volumetricLightScatteringPixelShader: {
  71738. name: string;
  71739. shader: string;
  71740. };
  71741. }
  71742. declare module BABYLON {
  71743. /** @hidden */
  71744. export var volumetricLightScatteringPassVertexShader: {
  71745. name: string;
  71746. shader: string;
  71747. };
  71748. }
  71749. declare module BABYLON {
  71750. /** @hidden */
  71751. export var volumetricLightScatteringPassPixelShader: {
  71752. name: string;
  71753. shader: string;
  71754. };
  71755. }
  71756. declare module BABYLON {
  71757. /**
  71758. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71759. */
  71760. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71761. private _volumetricLightScatteringPass;
  71762. private _volumetricLightScatteringRTT;
  71763. private _viewPort;
  71764. private _screenCoordinates;
  71765. private _cachedDefines;
  71766. /**
  71767. * If not undefined, the mesh position is computed from the attached node position
  71768. */
  71769. attachedNode: {
  71770. position: Vector3;
  71771. };
  71772. /**
  71773. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71774. */
  71775. customMeshPosition: Vector3;
  71776. /**
  71777. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71778. */
  71779. useCustomMeshPosition: boolean;
  71780. /**
  71781. * If the post-process should inverse the light scattering direction
  71782. */
  71783. invert: boolean;
  71784. /**
  71785. * The internal mesh used by the post-process
  71786. */
  71787. mesh: Mesh;
  71788. /**
  71789. * @hidden
  71790. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71791. */
  71792. get useDiffuseColor(): boolean;
  71793. set useDiffuseColor(useDiffuseColor: boolean);
  71794. /**
  71795. * Array containing the excluded meshes not rendered in the internal pass
  71796. */
  71797. excludedMeshes: AbstractMesh[];
  71798. /**
  71799. * Controls the overall intensity of the post-process
  71800. */
  71801. exposure: number;
  71802. /**
  71803. * Dissipates each sample's contribution in range [0, 1]
  71804. */
  71805. decay: number;
  71806. /**
  71807. * Controls the overall intensity of each sample
  71808. */
  71809. weight: number;
  71810. /**
  71811. * Controls the density of each sample
  71812. */
  71813. density: number;
  71814. /**
  71815. * @constructor
  71816. * @param name The post-process name
  71817. * @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)
  71818. * @param camera The camera that the post-process will be attached to
  71819. * @param mesh The mesh used to create the light scattering
  71820. * @param samples The post-process quality, default 100
  71821. * @param samplingModeThe post-process filtering mode
  71822. * @param engine The babylon engine
  71823. * @param reusable If the post-process is reusable
  71824. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71825. */
  71826. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71827. /**
  71828. * Returns the string "VolumetricLightScatteringPostProcess"
  71829. * @returns "VolumetricLightScatteringPostProcess"
  71830. */
  71831. getClassName(): string;
  71832. private _isReady;
  71833. /**
  71834. * Sets the new light position for light scattering effect
  71835. * @param position The new custom light position
  71836. */
  71837. setCustomMeshPosition(position: Vector3): void;
  71838. /**
  71839. * Returns the light position for light scattering effect
  71840. * @return Vector3 The custom light position
  71841. */
  71842. getCustomMeshPosition(): Vector3;
  71843. /**
  71844. * Disposes the internal assets and detaches the post-process from the camera
  71845. */
  71846. dispose(camera: Camera): void;
  71847. /**
  71848. * Returns the render target texture used by the post-process
  71849. * @return the render target texture used by the post-process
  71850. */
  71851. getPass(): RenderTargetTexture;
  71852. private _meshExcluded;
  71853. private _createPass;
  71854. private _updateMeshScreenCoordinates;
  71855. /**
  71856. * Creates a default mesh for the Volumeric Light Scattering post-process
  71857. * @param name The mesh name
  71858. * @param scene The scene where to create the mesh
  71859. * @return the default mesh
  71860. */
  71861. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /** @hidden */
  71866. export var screenSpaceCurvaturePixelShader: {
  71867. name: string;
  71868. shader: string;
  71869. };
  71870. }
  71871. declare module BABYLON {
  71872. /**
  71873. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71874. */
  71875. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71876. /**
  71877. * Defines how much ridge the curvature effect displays.
  71878. */
  71879. ridge: number;
  71880. /**
  71881. * Defines how much valley the curvature effect displays.
  71882. */
  71883. valley: number;
  71884. private _geometryBufferRenderer;
  71885. /**
  71886. * Gets a string identifying the name of the class
  71887. * @returns "ScreenSpaceCurvaturePostProcess" string
  71888. */
  71889. getClassName(): string;
  71890. /**
  71891. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71892. * @param name The name of the effect.
  71893. * @param scene The scene containing the objects to blur according to their velocity.
  71894. * @param options The required width/height ratio to downsize to before computing the render pass.
  71895. * @param camera The camera to apply the render pass to.
  71896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71897. * @param engine The engine which the post process will be applied. (default: current engine)
  71898. * @param reusable If the post process can be reused on the same frame. (default: false)
  71899. * @param textureType Type of textures used when performing the post process. (default: 0)
  71900. * @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)
  71901. */
  71902. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71903. /**
  71904. * Support test.
  71905. */
  71906. static get IsSupported(): boolean;
  71907. /** @hidden */
  71908. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71909. }
  71910. }
  71911. declare module BABYLON {
  71912. interface Scene {
  71913. /** @hidden (Backing field) */
  71914. _boundingBoxRenderer: BoundingBoxRenderer;
  71915. /** @hidden (Backing field) */
  71916. _forceShowBoundingBoxes: boolean;
  71917. /**
  71918. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71919. */
  71920. forceShowBoundingBoxes: boolean;
  71921. /**
  71922. * Gets the bounding box renderer associated with the scene
  71923. * @returns a BoundingBoxRenderer
  71924. */
  71925. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71926. }
  71927. interface AbstractMesh {
  71928. /** @hidden (Backing field) */
  71929. _showBoundingBox: boolean;
  71930. /**
  71931. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71932. */
  71933. showBoundingBox: boolean;
  71934. }
  71935. /**
  71936. * Component responsible of rendering the bounding box of the meshes in a scene.
  71937. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71938. */
  71939. export class BoundingBoxRenderer implements ISceneComponent {
  71940. /**
  71941. * The component name helpfull to identify the component in the list of scene components.
  71942. */
  71943. readonly name: string;
  71944. /**
  71945. * The scene the component belongs to.
  71946. */
  71947. scene: Scene;
  71948. /**
  71949. * Color of the bounding box lines placed in front of an object
  71950. */
  71951. frontColor: Color3;
  71952. /**
  71953. * Color of the bounding box lines placed behind an object
  71954. */
  71955. backColor: Color3;
  71956. /**
  71957. * Defines if the renderer should show the back lines or not
  71958. */
  71959. showBackLines: boolean;
  71960. /**
  71961. * Observable raised before rendering a bounding box
  71962. */
  71963. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71964. /**
  71965. * Observable raised after rendering a bounding box
  71966. */
  71967. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71968. /**
  71969. * @hidden
  71970. */
  71971. renderList: SmartArray<BoundingBox>;
  71972. private _colorShader;
  71973. private _vertexBuffers;
  71974. private _indexBuffer;
  71975. private _fillIndexBuffer;
  71976. private _fillIndexData;
  71977. /**
  71978. * Instantiates a new bounding box renderer in a scene.
  71979. * @param scene the scene the renderer renders in
  71980. */
  71981. constructor(scene: Scene);
  71982. /**
  71983. * Registers the component in a given scene
  71984. */
  71985. register(): void;
  71986. private _evaluateSubMesh;
  71987. private _activeMesh;
  71988. private _prepareRessources;
  71989. private _createIndexBuffer;
  71990. /**
  71991. * Rebuilds the elements related to this component in case of
  71992. * context lost for instance.
  71993. */
  71994. rebuild(): void;
  71995. /**
  71996. * @hidden
  71997. */
  71998. reset(): void;
  71999. /**
  72000. * Render the bounding boxes of a specific rendering group
  72001. * @param renderingGroupId defines the rendering group to render
  72002. */
  72003. render(renderingGroupId: number): void;
  72004. /**
  72005. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72006. * @param mesh Define the mesh to render the occlusion bounding box for
  72007. */
  72008. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72009. /**
  72010. * Dispose and release the resources attached to this renderer.
  72011. */
  72012. dispose(): void;
  72013. }
  72014. }
  72015. declare module BABYLON {
  72016. interface Scene {
  72017. /** @hidden (Backing field) */
  72018. _depthRenderer: {
  72019. [id: string]: DepthRenderer;
  72020. };
  72021. /**
  72022. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72023. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72024. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72025. * @returns the created depth renderer
  72026. */
  72027. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72028. /**
  72029. * Disables a depth renderer for a given camera
  72030. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72031. */
  72032. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72033. }
  72034. /**
  72035. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72036. * in several rendering techniques.
  72037. */
  72038. export class DepthRendererSceneComponent implements ISceneComponent {
  72039. /**
  72040. * The component name helpfull to identify the component in the list of scene components.
  72041. */
  72042. readonly name: string;
  72043. /**
  72044. * The scene the component belongs to.
  72045. */
  72046. scene: Scene;
  72047. /**
  72048. * Creates a new instance of the component for the given scene
  72049. * @param scene Defines the scene to register the component in
  72050. */
  72051. constructor(scene: Scene);
  72052. /**
  72053. * Registers the component in a given scene
  72054. */
  72055. register(): void;
  72056. /**
  72057. * Rebuilds the elements related to this component in case of
  72058. * context lost for instance.
  72059. */
  72060. rebuild(): void;
  72061. /**
  72062. * Disposes the component and the associated ressources
  72063. */
  72064. dispose(): void;
  72065. private _gatherRenderTargets;
  72066. private _gatherActiveCameraRenderTargets;
  72067. }
  72068. }
  72069. declare module BABYLON {
  72070. interface AbstractScene {
  72071. /** @hidden (Backing field) */
  72072. _prePassRenderer: Nullable<PrePassRenderer>;
  72073. /**
  72074. * Gets or Sets the current prepass renderer associated to the scene.
  72075. */
  72076. prePassRenderer: Nullable<PrePassRenderer>;
  72077. /**
  72078. * Enables the prepass and associates it with the scene
  72079. * @returns the PrePassRenderer
  72080. */
  72081. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72082. /**
  72083. * Disables the prepass associated with the scene
  72084. */
  72085. disablePrePassRenderer(): void;
  72086. }
  72087. /**
  72088. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72089. * in several rendering techniques.
  72090. */
  72091. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  72092. /**
  72093. * The component name helpful to identify the component in the list of scene components.
  72094. */
  72095. readonly name: string;
  72096. /**
  72097. * The scene the component belongs to.
  72098. */
  72099. scene: Scene;
  72100. /**
  72101. * Creates a new instance of the component for the given scene
  72102. * @param scene Defines the scene to register the component in
  72103. */
  72104. constructor(scene: Scene);
  72105. /**
  72106. * Registers the component in a given scene
  72107. */
  72108. register(): void;
  72109. private _beforeCameraDraw;
  72110. private _afterCameraDraw;
  72111. private _beforeClearStage;
  72112. /**
  72113. * Serializes the component data to the specified json object
  72114. * @param serializationObject The object to serialize to
  72115. */
  72116. serialize(serializationObject: any): void;
  72117. /**
  72118. * Adds all the elements from the container to the scene
  72119. * @param container the container holding the elements
  72120. */
  72121. addFromContainer(container: AbstractScene): void;
  72122. /**
  72123. * Removes all the elements in the container from the scene
  72124. * @param container contains the elements to remove
  72125. * @param dispose if the removed element should be disposed (default: false)
  72126. */
  72127. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72128. /**
  72129. * Rebuilds the elements related to this component in case of
  72130. * context lost for instance.
  72131. */
  72132. rebuild(): void;
  72133. /**
  72134. * Disposes the component and the associated ressources
  72135. */
  72136. dispose(): void;
  72137. }
  72138. }
  72139. declare module BABYLON {
  72140. /** @hidden */
  72141. export var outlinePixelShader: {
  72142. name: string;
  72143. shader: string;
  72144. };
  72145. }
  72146. declare module BABYLON {
  72147. /** @hidden */
  72148. export var outlineVertexShader: {
  72149. name: string;
  72150. shader: string;
  72151. };
  72152. }
  72153. declare module BABYLON {
  72154. interface Scene {
  72155. /** @hidden */
  72156. _outlineRenderer: OutlineRenderer;
  72157. /**
  72158. * Gets the outline renderer associated with the scene
  72159. * @returns a OutlineRenderer
  72160. */
  72161. getOutlineRenderer(): OutlineRenderer;
  72162. }
  72163. interface AbstractMesh {
  72164. /** @hidden (Backing field) */
  72165. _renderOutline: boolean;
  72166. /**
  72167. * Gets or sets a boolean indicating if the outline must be rendered as well
  72168. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72169. */
  72170. renderOutline: boolean;
  72171. /** @hidden (Backing field) */
  72172. _renderOverlay: boolean;
  72173. /**
  72174. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72175. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72176. */
  72177. renderOverlay: boolean;
  72178. }
  72179. /**
  72180. * This class is responsible to draw bothe outline/overlay of meshes.
  72181. * It should not be used directly but through the available method on mesh.
  72182. */
  72183. export class OutlineRenderer implements ISceneComponent {
  72184. /**
  72185. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72186. */
  72187. private static _StencilReference;
  72188. /**
  72189. * The name of the component. Each component must have a unique name.
  72190. */
  72191. name: string;
  72192. /**
  72193. * The scene the component belongs to.
  72194. */
  72195. scene: Scene;
  72196. /**
  72197. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72198. */
  72199. zOffset: number;
  72200. private _engine;
  72201. private _effect;
  72202. private _cachedDefines;
  72203. private _savedDepthWrite;
  72204. /**
  72205. * Instantiates a new outline renderer. (There could be only one per scene).
  72206. * @param scene Defines the scene it belongs to
  72207. */
  72208. constructor(scene: Scene);
  72209. /**
  72210. * Register the component to one instance of a scene.
  72211. */
  72212. register(): void;
  72213. /**
  72214. * Rebuilds the elements related to this component in case of
  72215. * context lost for instance.
  72216. */
  72217. rebuild(): void;
  72218. /**
  72219. * Disposes the component and the associated ressources.
  72220. */
  72221. dispose(): void;
  72222. /**
  72223. * Renders the outline in the canvas.
  72224. * @param subMesh Defines the sumesh to render
  72225. * @param batch Defines the batch of meshes in case of instances
  72226. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72227. */
  72228. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72229. /**
  72230. * Returns whether or not the outline renderer is ready for a given submesh.
  72231. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72232. * @param subMesh Defines the submesh to check readyness for
  72233. * @param useInstances Defines wheter wee are trying to render instances or not
  72234. * @returns true if ready otherwise false
  72235. */
  72236. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72237. private _beforeRenderingMesh;
  72238. private _afterRenderingMesh;
  72239. }
  72240. }
  72241. declare module BABYLON {
  72242. /**
  72243. * Defines the basic options interface of a Sprite Frame Source Size.
  72244. */
  72245. export interface ISpriteJSONSpriteSourceSize {
  72246. /**
  72247. * number of the original width of the Frame
  72248. */
  72249. w: number;
  72250. /**
  72251. * number of the original height of the Frame
  72252. */
  72253. h: number;
  72254. }
  72255. /**
  72256. * Defines the basic options interface of a Sprite Frame Data.
  72257. */
  72258. export interface ISpriteJSONSpriteFrameData {
  72259. /**
  72260. * number of the x offset of the Frame
  72261. */
  72262. x: number;
  72263. /**
  72264. * number of the y offset of the Frame
  72265. */
  72266. y: number;
  72267. /**
  72268. * number of the width of the Frame
  72269. */
  72270. w: number;
  72271. /**
  72272. * number of the height of the Frame
  72273. */
  72274. h: number;
  72275. }
  72276. /**
  72277. * Defines the basic options interface of a JSON Sprite.
  72278. */
  72279. export interface ISpriteJSONSprite {
  72280. /**
  72281. * string name of the Frame
  72282. */
  72283. filename: string;
  72284. /**
  72285. * ISpriteJSONSpriteFrame basic object of the frame data
  72286. */
  72287. frame: ISpriteJSONSpriteFrameData;
  72288. /**
  72289. * boolean to flag is the frame was rotated.
  72290. */
  72291. rotated: boolean;
  72292. /**
  72293. * boolean to flag is the frame was trimmed.
  72294. */
  72295. trimmed: boolean;
  72296. /**
  72297. * ISpriteJSONSpriteFrame basic object of the source data
  72298. */
  72299. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72300. /**
  72301. * ISpriteJSONSpriteFrame basic object of the source data
  72302. */
  72303. sourceSize: ISpriteJSONSpriteSourceSize;
  72304. }
  72305. /**
  72306. * Defines the basic options interface of a JSON atlas.
  72307. */
  72308. export interface ISpriteJSONAtlas {
  72309. /**
  72310. * Array of objects that contain the frame data.
  72311. */
  72312. frames: Array<ISpriteJSONSprite>;
  72313. /**
  72314. * object basic object containing the sprite meta data.
  72315. */
  72316. meta?: object;
  72317. }
  72318. }
  72319. declare module BABYLON {
  72320. /** @hidden */
  72321. export var spriteMapPixelShader: {
  72322. name: string;
  72323. shader: string;
  72324. };
  72325. }
  72326. declare module BABYLON {
  72327. /** @hidden */
  72328. export var spriteMapVertexShader: {
  72329. name: string;
  72330. shader: string;
  72331. };
  72332. }
  72333. declare module BABYLON {
  72334. /**
  72335. * Defines the basic options interface of a SpriteMap
  72336. */
  72337. export interface ISpriteMapOptions {
  72338. /**
  72339. * Vector2 of the number of cells in the grid.
  72340. */
  72341. stageSize?: Vector2;
  72342. /**
  72343. * Vector2 of the size of the output plane in World Units.
  72344. */
  72345. outputSize?: Vector2;
  72346. /**
  72347. * Vector3 of the position of the output plane in World Units.
  72348. */
  72349. outputPosition?: Vector3;
  72350. /**
  72351. * Vector3 of the rotation of the output plane.
  72352. */
  72353. outputRotation?: Vector3;
  72354. /**
  72355. * number of layers that the system will reserve in resources.
  72356. */
  72357. layerCount?: number;
  72358. /**
  72359. * number of max animation frames a single cell will reserve in resources.
  72360. */
  72361. maxAnimationFrames?: number;
  72362. /**
  72363. * number cell index of the base tile when the system compiles.
  72364. */
  72365. baseTile?: number;
  72366. /**
  72367. * boolean flip the sprite after its been repositioned by the framing data.
  72368. */
  72369. flipU?: boolean;
  72370. /**
  72371. * Vector3 scalar of the global RGB values of the SpriteMap.
  72372. */
  72373. colorMultiply?: Vector3;
  72374. }
  72375. /**
  72376. * Defines the IDisposable interface in order to be cleanable from resources.
  72377. */
  72378. export interface ISpriteMap extends IDisposable {
  72379. /**
  72380. * String name of the SpriteMap.
  72381. */
  72382. name: string;
  72383. /**
  72384. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72385. */
  72386. atlasJSON: ISpriteJSONAtlas;
  72387. /**
  72388. * Texture of the SpriteMap.
  72389. */
  72390. spriteSheet: Texture;
  72391. /**
  72392. * The parameters to initialize the SpriteMap with.
  72393. */
  72394. options: ISpriteMapOptions;
  72395. }
  72396. /**
  72397. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72398. */
  72399. export class SpriteMap implements ISpriteMap {
  72400. /** The Name of the spriteMap */
  72401. name: string;
  72402. /** The JSON file with the frame and meta data */
  72403. atlasJSON: ISpriteJSONAtlas;
  72404. /** The systems Sprite Sheet Texture */
  72405. spriteSheet: Texture;
  72406. /** Arguments passed with the Constructor */
  72407. options: ISpriteMapOptions;
  72408. /** Public Sprite Storage array, parsed from atlasJSON */
  72409. sprites: Array<ISpriteJSONSprite>;
  72410. /** Returns the Number of Sprites in the System */
  72411. get spriteCount(): number;
  72412. /** Returns the Position of Output Plane*/
  72413. get position(): Vector3;
  72414. /** Returns the Position of Output Plane*/
  72415. set position(v: Vector3);
  72416. /** Returns the Rotation of Output Plane*/
  72417. get rotation(): Vector3;
  72418. /** Returns the Rotation of Output Plane*/
  72419. set rotation(v: Vector3);
  72420. /** Sets the AnimationMap*/
  72421. get animationMap(): RawTexture;
  72422. /** Sets the AnimationMap*/
  72423. set animationMap(v: RawTexture);
  72424. /** Scene that the SpriteMap was created in */
  72425. private _scene;
  72426. /** Texture Buffer of Float32 that holds tile frame data*/
  72427. private _frameMap;
  72428. /** Texture Buffers of Float32 that holds tileMap data*/
  72429. private _tileMaps;
  72430. /** Texture Buffer of Float32 that holds Animation Data*/
  72431. private _animationMap;
  72432. /** Custom ShaderMaterial Central to the System*/
  72433. private _material;
  72434. /** Custom ShaderMaterial Central to the System*/
  72435. private _output;
  72436. /** Systems Time Ticker*/
  72437. private _time;
  72438. /**
  72439. * Creates a new SpriteMap
  72440. * @param name defines the SpriteMaps Name
  72441. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72442. * @param spriteSheet is the Texture that the Sprites are on.
  72443. * @param options a basic deployment configuration
  72444. * @param scene The Scene that the map is deployed on
  72445. */
  72446. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72447. /**
  72448. * Returns tileID location
  72449. * @returns Vector2 the cell position ID
  72450. */
  72451. getTileID(): Vector2;
  72452. /**
  72453. * Gets the UV location of the mouse over the SpriteMap.
  72454. * @returns Vector2 the UV position of the mouse interaction
  72455. */
  72456. getMousePosition(): Vector2;
  72457. /**
  72458. * Creates the "frame" texture Buffer
  72459. * -------------------------------------
  72460. * Structure of frames
  72461. * "filename": "Falling-Water-2.png",
  72462. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72463. * "rotated": true,
  72464. * "trimmed": true,
  72465. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72466. * "sourceSize": {"w":32,"h":32}
  72467. * @returns RawTexture of the frameMap
  72468. */
  72469. private _createFrameBuffer;
  72470. /**
  72471. * Creates the tileMap texture Buffer
  72472. * @param buffer normally and array of numbers, or a false to generate from scratch
  72473. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72474. * @returns RawTexture of the tileMap
  72475. */
  72476. private _createTileBuffer;
  72477. /**
  72478. * Modifies the data of the tileMaps
  72479. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72480. * @param pos is the iVector2 Coordinates of the Tile
  72481. * @param tile The SpriteIndex of the new Tile
  72482. */
  72483. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72484. /**
  72485. * Creates the animationMap texture Buffer
  72486. * @param buffer normally and array of numbers, or a false to generate from scratch
  72487. * @returns RawTexture of the animationMap
  72488. */
  72489. private _createTileAnimationBuffer;
  72490. /**
  72491. * Modifies the data of the animationMap
  72492. * @param cellID is the Index of the Sprite
  72493. * @param _frame is the target Animation frame
  72494. * @param toCell is the Target Index of the next frame of the animation
  72495. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72496. * @param speed is a global scalar of the time variable on the map.
  72497. */
  72498. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72499. /**
  72500. * Exports the .tilemaps file
  72501. */
  72502. saveTileMaps(): void;
  72503. /**
  72504. * Imports the .tilemaps file
  72505. * @param url of the .tilemaps file
  72506. */
  72507. loadTileMaps(url: string): void;
  72508. /**
  72509. * Release associated resources
  72510. */
  72511. dispose(): void;
  72512. }
  72513. }
  72514. declare module BABYLON {
  72515. /**
  72516. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72517. * @see https://doc.babylonjs.com/babylon101/sprites
  72518. */
  72519. export class SpritePackedManager extends SpriteManager {
  72520. /** defines the packed manager's name */
  72521. name: string;
  72522. /**
  72523. * Creates a new sprite manager from a packed sprite sheet
  72524. * @param name defines the manager's name
  72525. * @param imgUrl defines the sprite sheet url
  72526. * @param capacity defines the maximum allowed number of sprites
  72527. * @param scene defines the hosting scene
  72528. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72529. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72530. * @param samplingMode defines the smapling mode to use with spritesheet
  72531. * @param fromPacked set to true; do not alter
  72532. */
  72533. constructor(
  72534. /** defines the packed manager's name */
  72535. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72536. }
  72537. }
  72538. declare module BABYLON {
  72539. /**
  72540. * Defines the list of states available for a task inside a AssetsManager
  72541. */
  72542. export enum AssetTaskState {
  72543. /**
  72544. * Initialization
  72545. */
  72546. INIT = 0,
  72547. /**
  72548. * Running
  72549. */
  72550. RUNNING = 1,
  72551. /**
  72552. * Done
  72553. */
  72554. DONE = 2,
  72555. /**
  72556. * Error
  72557. */
  72558. ERROR = 3
  72559. }
  72560. /**
  72561. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72562. */
  72563. export abstract class AbstractAssetTask {
  72564. /**
  72565. * Task name
  72566. */ name: string;
  72567. /**
  72568. * Callback called when the task is successful
  72569. */
  72570. onSuccess: (task: any) => void;
  72571. /**
  72572. * Callback called when the task is not successful
  72573. */
  72574. onError: (task: any, message?: string, exception?: any) => void;
  72575. /**
  72576. * Creates a new AssetsManager
  72577. * @param name defines the name of the task
  72578. */
  72579. constructor(
  72580. /**
  72581. * Task name
  72582. */ name: string);
  72583. private _isCompleted;
  72584. private _taskState;
  72585. private _errorObject;
  72586. /**
  72587. * Get if the task is completed
  72588. */
  72589. get isCompleted(): boolean;
  72590. /**
  72591. * Gets the current state of the task
  72592. */
  72593. get taskState(): AssetTaskState;
  72594. /**
  72595. * Gets the current error object (if task is in error)
  72596. */
  72597. get errorObject(): {
  72598. message?: string;
  72599. exception?: any;
  72600. };
  72601. /**
  72602. * Internal only
  72603. * @hidden
  72604. */
  72605. _setErrorObject(message?: string, exception?: any): void;
  72606. /**
  72607. * Execute the current task
  72608. * @param scene defines the scene where you want your assets to be loaded
  72609. * @param onSuccess is a callback called when the task is successfully executed
  72610. * @param onError is a callback called if an error occurs
  72611. */
  72612. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72613. /**
  72614. * Execute the current task
  72615. * @param scene defines the scene where you want your assets to be loaded
  72616. * @param onSuccess is a callback called when the task is successfully executed
  72617. * @param onError is a callback called if an error occurs
  72618. */
  72619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72620. /**
  72621. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72622. * This can be used with failed tasks that have the reason for failure fixed.
  72623. */
  72624. reset(): void;
  72625. private onErrorCallback;
  72626. private onDoneCallback;
  72627. }
  72628. /**
  72629. * Define the interface used by progress events raised during assets loading
  72630. */
  72631. export interface IAssetsProgressEvent {
  72632. /**
  72633. * Defines the number of remaining tasks to process
  72634. */
  72635. remainingCount: number;
  72636. /**
  72637. * Defines the total number of tasks
  72638. */
  72639. totalCount: number;
  72640. /**
  72641. * Defines the task that was just processed
  72642. */
  72643. task: AbstractAssetTask;
  72644. }
  72645. /**
  72646. * Class used to share progress information about assets loading
  72647. */
  72648. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72649. /**
  72650. * Defines the number of remaining tasks to process
  72651. */
  72652. remainingCount: number;
  72653. /**
  72654. * Defines the total number of tasks
  72655. */
  72656. totalCount: number;
  72657. /**
  72658. * Defines the task that was just processed
  72659. */
  72660. task: AbstractAssetTask;
  72661. /**
  72662. * Creates a AssetsProgressEvent
  72663. * @param remainingCount defines the number of remaining tasks to process
  72664. * @param totalCount defines the total number of tasks
  72665. * @param task defines the task that was just processed
  72666. */
  72667. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72668. }
  72669. /**
  72670. * Define a task used by AssetsManager to load assets into a container
  72671. */
  72672. export class ContainerAssetTask extends AbstractAssetTask {
  72673. /**
  72674. * Defines the name of the task
  72675. */
  72676. name: string;
  72677. /**
  72678. * Defines the list of mesh's names you want to load
  72679. */
  72680. meshesNames: any;
  72681. /**
  72682. * Defines the root url to use as a base to load your meshes and associated resources
  72683. */
  72684. rootUrl: string;
  72685. /**
  72686. * Defines the filename or File of the scene to load from
  72687. */
  72688. sceneFilename: string | File;
  72689. /**
  72690. * Get the loaded asset container
  72691. */
  72692. loadedContainer: AssetContainer;
  72693. /**
  72694. * Gets the list of loaded meshes
  72695. */
  72696. loadedMeshes: Array<AbstractMesh>;
  72697. /**
  72698. * Gets the list of loaded particle systems
  72699. */
  72700. loadedParticleSystems: Array<IParticleSystem>;
  72701. /**
  72702. * Gets the list of loaded skeletons
  72703. */
  72704. loadedSkeletons: Array<Skeleton>;
  72705. /**
  72706. * Gets the list of loaded animation groups
  72707. */
  72708. loadedAnimationGroups: Array<AnimationGroup>;
  72709. /**
  72710. * Callback called when the task is successful
  72711. */
  72712. onSuccess: (task: ContainerAssetTask) => void;
  72713. /**
  72714. * Callback called when the task is successful
  72715. */
  72716. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72717. /**
  72718. * Creates a new ContainerAssetTask
  72719. * @param name defines the name of the task
  72720. * @param meshesNames defines the list of mesh's names you want to load
  72721. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72722. * @param sceneFilename defines the filename or File of the scene to load from
  72723. */
  72724. constructor(
  72725. /**
  72726. * Defines the name of the task
  72727. */
  72728. name: string,
  72729. /**
  72730. * Defines the list of mesh's names you want to load
  72731. */
  72732. meshesNames: any,
  72733. /**
  72734. * Defines the root url to use as a base to load your meshes and associated resources
  72735. */
  72736. rootUrl: string,
  72737. /**
  72738. * Defines the filename or File of the scene to load from
  72739. */
  72740. sceneFilename: string | File);
  72741. /**
  72742. * Execute the current task
  72743. * @param scene defines the scene where you want your assets to be loaded
  72744. * @param onSuccess is a callback called when the task is successfully executed
  72745. * @param onError is a callback called if an error occurs
  72746. */
  72747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72748. }
  72749. /**
  72750. * Define a task used by AssetsManager to load meshes
  72751. */
  72752. export class MeshAssetTask extends AbstractAssetTask {
  72753. /**
  72754. * Defines the name of the task
  72755. */
  72756. name: string;
  72757. /**
  72758. * Defines the list of mesh's names you want to load
  72759. */
  72760. meshesNames: any;
  72761. /**
  72762. * Defines the root url to use as a base to load your meshes and associated resources
  72763. */
  72764. rootUrl: string;
  72765. /**
  72766. * Defines the filename or File of the scene to load from
  72767. */
  72768. sceneFilename: string | File;
  72769. /**
  72770. * Gets the list of loaded meshes
  72771. */
  72772. loadedMeshes: Array<AbstractMesh>;
  72773. /**
  72774. * Gets the list of loaded particle systems
  72775. */
  72776. loadedParticleSystems: Array<IParticleSystem>;
  72777. /**
  72778. * Gets the list of loaded skeletons
  72779. */
  72780. loadedSkeletons: Array<Skeleton>;
  72781. /**
  72782. * Gets the list of loaded animation groups
  72783. */
  72784. loadedAnimationGroups: Array<AnimationGroup>;
  72785. /**
  72786. * Callback called when the task is successful
  72787. */
  72788. onSuccess: (task: MeshAssetTask) => void;
  72789. /**
  72790. * Callback called when the task is successful
  72791. */
  72792. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72793. /**
  72794. * Creates a new MeshAssetTask
  72795. * @param name defines the name of the task
  72796. * @param meshesNames defines the list of mesh's names you want to load
  72797. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72798. * @param sceneFilename defines the filename or File of the scene to load from
  72799. */
  72800. constructor(
  72801. /**
  72802. * Defines the name of the task
  72803. */
  72804. name: string,
  72805. /**
  72806. * Defines the list of mesh's names you want to load
  72807. */
  72808. meshesNames: any,
  72809. /**
  72810. * Defines the root url to use as a base to load your meshes and associated resources
  72811. */
  72812. rootUrl: string,
  72813. /**
  72814. * Defines the filename or File of the scene to load from
  72815. */
  72816. sceneFilename: string | File);
  72817. /**
  72818. * Execute the current task
  72819. * @param scene defines the scene where you want your assets to be loaded
  72820. * @param onSuccess is a callback called when the task is successfully executed
  72821. * @param onError is a callback called if an error occurs
  72822. */
  72823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72824. }
  72825. /**
  72826. * Define a task used by AssetsManager to load text content
  72827. */
  72828. export class TextFileAssetTask extends AbstractAssetTask {
  72829. /**
  72830. * Defines the name of the task
  72831. */
  72832. name: string;
  72833. /**
  72834. * Defines the location of the file to load
  72835. */
  72836. url: string;
  72837. /**
  72838. * Gets the loaded text string
  72839. */
  72840. text: string;
  72841. /**
  72842. * Callback called when the task is successful
  72843. */
  72844. onSuccess: (task: TextFileAssetTask) => void;
  72845. /**
  72846. * Callback called when the task is successful
  72847. */
  72848. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72849. /**
  72850. * Creates a new TextFileAssetTask object
  72851. * @param name defines the name of the task
  72852. * @param url defines the location of the file to load
  72853. */
  72854. constructor(
  72855. /**
  72856. * Defines the name of the task
  72857. */
  72858. name: string,
  72859. /**
  72860. * Defines the location of the file to load
  72861. */
  72862. url: string);
  72863. /**
  72864. * Execute the current task
  72865. * @param scene defines the scene where you want your assets to be loaded
  72866. * @param onSuccess is a callback called when the task is successfully executed
  72867. * @param onError is a callback called if an error occurs
  72868. */
  72869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72870. }
  72871. /**
  72872. * Define a task used by AssetsManager to load binary data
  72873. */
  72874. export class BinaryFileAssetTask extends AbstractAssetTask {
  72875. /**
  72876. * Defines the name of the task
  72877. */
  72878. name: string;
  72879. /**
  72880. * Defines the location of the file to load
  72881. */
  72882. url: string;
  72883. /**
  72884. * Gets the lodaded data (as an array buffer)
  72885. */
  72886. data: ArrayBuffer;
  72887. /**
  72888. * Callback called when the task is successful
  72889. */
  72890. onSuccess: (task: BinaryFileAssetTask) => void;
  72891. /**
  72892. * Callback called when the task is successful
  72893. */
  72894. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72895. /**
  72896. * Creates a new BinaryFileAssetTask object
  72897. * @param name defines the name of the new task
  72898. * @param url defines the location of the file to load
  72899. */
  72900. constructor(
  72901. /**
  72902. * Defines the name of the task
  72903. */
  72904. name: string,
  72905. /**
  72906. * Defines the location of the file to load
  72907. */
  72908. url: string);
  72909. /**
  72910. * Execute the current task
  72911. * @param scene defines the scene where you want your assets to be loaded
  72912. * @param onSuccess is a callback called when the task is successfully executed
  72913. * @param onError is a callback called if an error occurs
  72914. */
  72915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72916. }
  72917. /**
  72918. * Define a task used by AssetsManager to load images
  72919. */
  72920. export class ImageAssetTask extends AbstractAssetTask {
  72921. /**
  72922. * Defines the name of the task
  72923. */
  72924. name: string;
  72925. /**
  72926. * Defines the location of the image to load
  72927. */
  72928. url: string;
  72929. /**
  72930. * Gets the loaded images
  72931. */
  72932. image: HTMLImageElement;
  72933. /**
  72934. * Callback called when the task is successful
  72935. */
  72936. onSuccess: (task: ImageAssetTask) => void;
  72937. /**
  72938. * Callback called when the task is successful
  72939. */
  72940. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72941. /**
  72942. * Creates a new ImageAssetTask
  72943. * @param name defines the name of the task
  72944. * @param url defines the location of the image to load
  72945. */
  72946. constructor(
  72947. /**
  72948. * Defines the name of the task
  72949. */
  72950. name: string,
  72951. /**
  72952. * Defines the location of the image to load
  72953. */
  72954. url: string);
  72955. /**
  72956. * Execute the current task
  72957. * @param scene defines the scene where you want your assets to be loaded
  72958. * @param onSuccess is a callback called when the task is successfully executed
  72959. * @param onError is a callback called if an error occurs
  72960. */
  72961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72962. }
  72963. /**
  72964. * Defines the interface used by texture loading tasks
  72965. */
  72966. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72967. /**
  72968. * Gets the loaded texture
  72969. */
  72970. texture: TEX;
  72971. }
  72972. /**
  72973. * Define a task used by AssetsManager to load 2D textures
  72974. */
  72975. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72976. /**
  72977. * Defines the name of the task
  72978. */
  72979. name: string;
  72980. /**
  72981. * Defines the location of the file to load
  72982. */
  72983. url: string;
  72984. /**
  72985. * Defines if mipmap should not be generated (default is false)
  72986. */
  72987. noMipmap?: boolean | undefined;
  72988. /**
  72989. * Defines if texture must be inverted on Y axis (default is true)
  72990. */
  72991. invertY: boolean;
  72992. /**
  72993. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72994. */
  72995. samplingMode: number;
  72996. /**
  72997. * Gets the loaded texture
  72998. */
  72999. texture: Texture;
  73000. /**
  73001. * Callback called when the task is successful
  73002. */
  73003. onSuccess: (task: TextureAssetTask) => void;
  73004. /**
  73005. * Callback called when the task is successful
  73006. */
  73007. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73008. /**
  73009. * Creates a new TextureAssetTask object
  73010. * @param name defines the name of the task
  73011. * @param url defines the location of the file to load
  73012. * @param noMipmap defines if mipmap should not be generated (default is false)
  73013. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73014. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73015. */
  73016. constructor(
  73017. /**
  73018. * Defines the name of the task
  73019. */
  73020. name: string,
  73021. /**
  73022. * Defines the location of the file to load
  73023. */
  73024. url: string,
  73025. /**
  73026. * Defines if mipmap should not be generated (default is false)
  73027. */
  73028. noMipmap?: boolean | undefined,
  73029. /**
  73030. * Defines if texture must be inverted on Y axis (default is true)
  73031. */
  73032. invertY?: boolean,
  73033. /**
  73034. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73035. */
  73036. samplingMode?: number);
  73037. /**
  73038. * Execute the current task
  73039. * @param scene defines the scene where you want your assets to be loaded
  73040. * @param onSuccess is a callback called when the task is successfully executed
  73041. * @param onError is a callback called if an error occurs
  73042. */
  73043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73044. }
  73045. /**
  73046. * Define a task used by AssetsManager to load cube textures
  73047. */
  73048. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73049. /**
  73050. * Defines the name of the task
  73051. */
  73052. name: string;
  73053. /**
  73054. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73055. */
  73056. url: string;
  73057. /**
  73058. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73059. */
  73060. extensions?: string[] | undefined;
  73061. /**
  73062. * Defines if mipmaps should not be generated (default is false)
  73063. */
  73064. noMipmap?: boolean | undefined;
  73065. /**
  73066. * Defines the explicit list of files (undefined by default)
  73067. */
  73068. files?: string[] | undefined;
  73069. /**
  73070. * Gets the loaded texture
  73071. */
  73072. texture: CubeTexture;
  73073. /**
  73074. * Callback called when the task is successful
  73075. */
  73076. onSuccess: (task: CubeTextureAssetTask) => void;
  73077. /**
  73078. * Callback called when the task is successful
  73079. */
  73080. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73081. /**
  73082. * Creates a new CubeTextureAssetTask
  73083. * @param name defines the name of the task
  73084. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73085. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73086. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73087. * @param files defines the explicit list of files (undefined by default)
  73088. */
  73089. constructor(
  73090. /**
  73091. * Defines the name of the task
  73092. */
  73093. name: string,
  73094. /**
  73095. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73096. */
  73097. url: string,
  73098. /**
  73099. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73100. */
  73101. extensions?: string[] | undefined,
  73102. /**
  73103. * Defines if mipmaps should not be generated (default is false)
  73104. */
  73105. noMipmap?: boolean | undefined,
  73106. /**
  73107. * Defines the explicit list of files (undefined by default)
  73108. */
  73109. files?: string[] | undefined);
  73110. /**
  73111. * Execute the current task
  73112. * @param scene defines the scene where you want your assets to be loaded
  73113. * @param onSuccess is a callback called when the task is successfully executed
  73114. * @param onError is a callback called if an error occurs
  73115. */
  73116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73117. }
  73118. /**
  73119. * Define a task used by AssetsManager to load HDR cube textures
  73120. */
  73121. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73122. /**
  73123. * Defines the name of the task
  73124. */
  73125. name: string;
  73126. /**
  73127. * Defines the location of the file to load
  73128. */
  73129. url: string;
  73130. /**
  73131. * Defines the desired size (the more it increases the longer the generation will be)
  73132. */
  73133. size: number;
  73134. /**
  73135. * Defines if mipmaps should not be generated (default is false)
  73136. */
  73137. noMipmap: boolean;
  73138. /**
  73139. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73140. */
  73141. generateHarmonics: boolean;
  73142. /**
  73143. * 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)
  73144. */
  73145. gammaSpace: boolean;
  73146. /**
  73147. * Internal Use Only
  73148. */
  73149. reserved: boolean;
  73150. /**
  73151. * Gets the loaded texture
  73152. */
  73153. texture: HDRCubeTexture;
  73154. /**
  73155. * Callback called when the task is successful
  73156. */
  73157. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73158. /**
  73159. * Callback called when the task is successful
  73160. */
  73161. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73162. /**
  73163. * Creates a new HDRCubeTextureAssetTask object
  73164. * @param name defines the name of the task
  73165. * @param url defines the location of the file to load
  73166. * @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.
  73167. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73168. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73169. * @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)
  73170. * @param reserved Internal use only
  73171. */
  73172. constructor(
  73173. /**
  73174. * Defines the name of the task
  73175. */
  73176. name: string,
  73177. /**
  73178. * Defines the location of the file to load
  73179. */
  73180. url: string,
  73181. /**
  73182. * Defines the desired size (the more it increases the longer the generation will be)
  73183. */
  73184. size: number,
  73185. /**
  73186. * Defines if mipmaps should not be generated (default is false)
  73187. */
  73188. noMipmap?: boolean,
  73189. /**
  73190. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73191. */
  73192. generateHarmonics?: boolean,
  73193. /**
  73194. * 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)
  73195. */
  73196. gammaSpace?: boolean,
  73197. /**
  73198. * Internal Use Only
  73199. */
  73200. reserved?: boolean);
  73201. /**
  73202. * Execute the current task
  73203. * @param scene defines the scene where you want your assets to be loaded
  73204. * @param onSuccess is a callback called when the task is successfully executed
  73205. * @param onError is a callback called if an error occurs
  73206. */
  73207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73208. }
  73209. /**
  73210. * Define a task used by AssetsManager to load Equirectangular cube textures
  73211. */
  73212. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73213. /**
  73214. * Defines the name of the task
  73215. */
  73216. name: string;
  73217. /**
  73218. * Defines the location of the file to load
  73219. */
  73220. url: string;
  73221. /**
  73222. * Defines the desired size (the more it increases the longer the generation will be)
  73223. */
  73224. size: number;
  73225. /**
  73226. * Defines if mipmaps should not be generated (default is false)
  73227. */
  73228. noMipmap: boolean;
  73229. /**
  73230. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73231. * but the standard material would require them in Gamma space) (default is true)
  73232. */
  73233. gammaSpace: boolean;
  73234. /**
  73235. * Gets the loaded texture
  73236. */
  73237. texture: EquiRectangularCubeTexture;
  73238. /**
  73239. * Callback called when the task is successful
  73240. */
  73241. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73242. /**
  73243. * Callback called when the task is successful
  73244. */
  73245. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73246. /**
  73247. * Creates a new EquiRectangularCubeTextureAssetTask object
  73248. * @param name defines the name of the task
  73249. * @param url defines the location of the file to load
  73250. * @param size defines the desired size (the more it increases the longer the generation will be)
  73251. * If the size is omitted this implies you are using a preprocessed cubemap.
  73252. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73253. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73254. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73255. * (default is true)
  73256. */
  73257. constructor(
  73258. /**
  73259. * Defines the name of the task
  73260. */
  73261. name: string,
  73262. /**
  73263. * Defines the location of the file to load
  73264. */
  73265. url: string,
  73266. /**
  73267. * Defines the desired size (the more it increases the longer the generation will be)
  73268. */
  73269. size: number,
  73270. /**
  73271. * Defines if mipmaps should not be generated (default is false)
  73272. */
  73273. noMipmap?: boolean,
  73274. /**
  73275. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73276. * but the standard material would require them in Gamma space) (default is true)
  73277. */
  73278. gammaSpace?: boolean);
  73279. /**
  73280. * Execute the current task
  73281. * @param scene defines the scene where you want your assets to be loaded
  73282. * @param onSuccess is a callback called when the task is successfully executed
  73283. * @param onError is a callback called if an error occurs
  73284. */
  73285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73286. }
  73287. /**
  73288. * This class can be used to easily import assets into a scene
  73289. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73290. */
  73291. export class AssetsManager {
  73292. private _scene;
  73293. private _isLoading;
  73294. protected _tasks: AbstractAssetTask[];
  73295. protected _waitingTasksCount: number;
  73296. protected _totalTasksCount: number;
  73297. /**
  73298. * Callback called when all tasks are processed
  73299. */
  73300. onFinish: (tasks: AbstractAssetTask[]) => void;
  73301. /**
  73302. * Callback called when a task is successful
  73303. */
  73304. onTaskSuccess: (task: AbstractAssetTask) => void;
  73305. /**
  73306. * Callback called when a task had an error
  73307. */
  73308. onTaskError: (task: AbstractAssetTask) => void;
  73309. /**
  73310. * Callback called when a task is done (whatever the result is)
  73311. */
  73312. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73313. /**
  73314. * Observable called when all tasks are processed
  73315. */
  73316. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73317. /**
  73318. * Observable called when a task had an error
  73319. */
  73320. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73321. /**
  73322. * Observable called when all tasks were executed
  73323. */
  73324. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73325. /**
  73326. * Observable called when a task is done (whatever the result is)
  73327. */
  73328. onProgressObservable: Observable<IAssetsProgressEvent>;
  73329. /**
  73330. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73331. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73332. */
  73333. useDefaultLoadingScreen: boolean;
  73334. /**
  73335. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73336. * when all assets have been downloaded.
  73337. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73338. */
  73339. autoHideLoadingUI: boolean;
  73340. /**
  73341. * Creates a new AssetsManager
  73342. * @param scene defines the scene to work on
  73343. */
  73344. constructor(scene: Scene);
  73345. /**
  73346. * Add a ContainerAssetTask to the list of active tasks
  73347. * @param taskName defines the name of the new task
  73348. * @param meshesNames defines the name of meshes to load
  73349. * @param rootUrl defines the root url to use to locate files
  73350. * @param sceneFilename defines the filename of the scene file
  73351. * @returns a new ContainerAssetTask object
  73352. */
  73353. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73354. /**
  73355. * Add a MeshAssetTask to the list of active tasks
  73356. * @param taskName defines the name of the new task
  73357. * @param meshesNames defines the name of meshes to load
  73358. * @param rootUrl defines the root url to use to locate files
  73359. * @param sceneFilename defines the filename of the scene file
  73360. * @returns a new MeshAssetTask object
  73361. */
  73362. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73363. /**
  73364. * Add a TextFileAssetTask to the list of active tasks
  73365. * @param taskName defines the name of the new task
  73366. * @param url defines the url of the file to load
  73367. * @returns a new TextFileAssetTask object
  73368. */
  73369. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73370. /**
  73371. * Add a BinaryFileAssetTask to the list of active tasks
  73372. * @param taskName defines the name of the new task
  73373. * @param url defines the url of the file to load
  73374. * @returns a new BinaryFileAssetTask object
  73375. */
  73376. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73377. /**
  73378. * Add a ImageAssetTask to the list of active tasks
  73379. * @param taskName defines the name of the new task
  73380. * @param url defines the url of the file to load
  73381. * @returns a new ImageAssetTask object
  73382. */
  73383. addImageTask(taskName: string, url: string): ImageAssetTask;
  73384. /**
  73385. * Add a TextureAssetTask to the list of active tasks
  73386. * @param taskName defines the name of the new task
  73387. * @param url defines the url of the file to load
  73388. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73389. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73390. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73391. * @returns a new TextureAssetTask object
  73392. */
  73393. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73394. /**
  73395. * Add a CubeTextureAssetTask to the list of active tasks
  73396. * @param taskName defines the name of the new task
  73397. * @param url defines the url of the file to load
  73398. * @param extensions defines the extension to use to load the cube map (can be null)
  73399. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73400. * @param files defines the list of files to load (can be null)
  73401. * @returns a new CubeTextureAssetTask object
  73402. */
  73403. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73404. /**
  73405. *
  73406. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73407. * @param taskName defines the name of the new task
  73408. * @param url defines the url of the file to load
  73409. * @param size defines the size you want for the cubemap (can be null)
  73410. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73411. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73412. * @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)
  73413. * @param reserved Internal use only
  73414. * @returns a new HDRCubeTextureAssetTask object
  73415. */
  73416. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73417. /**
  73418. *
  73419. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73420. * @param taskName defines the name of the new task
  73421. * @param url defines the url of the file to load
  73422. * @param size defines the size you want for the cubemap (can be null)
  73423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73424. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73425. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73426. * @returns a new EquiRectangularCubeTextureAssetTask object
  73427. */
  73428. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73429. /**
  73430. * Remove a task from the assets manager.
  73431. * @param task the task to remove
  73432. */
  73433. removeTask(task: AbstractAssetTask): void;
  73434. private _decreaseWaitingTasksCount;
  73435. private _runTask;
  73436. /**
  73437. * Reset the AssetsManager and remove all tasks
  73438. * @return the current instance of the AssetsManager
  73439. */
  73440. reset(): AssetsManager;
  73441. /**
  73442. * Start the loading process
  73443. * @return the current instance of the AssetsManager
  73444. */
  73445. load(): AssetsManager;
  73446. /**
  73447. * Start the loading process as an async operation
  73448. * @return a promise returning the list of failed tasks
  73449. */
  73450. loadAsync(): Promise<void>;
  73451. }
  73452. }
  73453. declare module BABYLON {
  73454. /**
  73455. * Wrapper class for promise with external resolve and reject.
  73456. */
  73457. export class Deferred<T> {
  73458. /**
  73459. * The promise associated with this deferred object.
  73460. */
  73461. readonly promise: Promise<T>;
  73462. private _resolve;
  73463. private _reject;
  73464. /**
  73465. * The resolve method of the promise associated with this deferred object.
  73466. */
  73467. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73468. /**
  73469. * The reject method of the promise associated with this deferred object.
  73470. */
  73471. get reject(): (reason?: any) => void;
  73472. /**
  73473. * Constructor for this deferred object.
  73474. */
  73475. constructor();
  73476. }
  73477. }
  73478. declare module BABYLON {
  73479. /**
  73480. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73481. */
  73482. export class MeshExploder {
  73483. private _centerMesh;
  73484. private _meshes;
  73485. private _meshesOrigins;
  73486. private _toCenterVectors;
  73487. private _scaledDirection;
  73488. private _newPosition;
  73489. private _centerPosition;
  73490. /**
  73491. * Explodes meshes from a center mesh.
  73492. * @param meshes The meshes to explode.
  73493. * @param centerMesh The mesh to be center of explosion.
  73494. */
  73495. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73496. private _setCenterMesh;
  73497. /**
  73498. * Get class name
  73499. * @returns "MeshExploder"
  73500. */
  73501. getClassName(): string;
  73502. /**
  73503. * "Exploded meshes"
  73504. * @returns Array of meshes with the centerMesh at index 0.
  73505. */
  73506. getMeshes(): Array<Mesh>;
  73507. /**
  73508. * Explodes meshes giving a specific direction
  73509. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73510. */
  73511. explode(direction?: number): void;
  73512. }
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Class used to help managing file picking and drag'n'drop
  73517. */
  73518. export class FilesInput {
  73519. /**
  73520. * List of files ready to be loaded
  73521. */
  73522. static get FilesToLoad(): {
  73523. [key: string]: File;
  73524. };
  73525. /**
  73526. * Callback called when a file is processed
  73527. */
  73528. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73529. private _engine;
  73530. private _currentScene;
  73531. private _sceneLoadedCallback;
  73532. private _progressCallback;
  73533. private _additionalRenderLoopLogicCallback;
  73534. private _textureLoadingCallback;
  73535. private _startingProcessingFilesCallback;
  73536. private _onReloadCallback;
  73537. private _errorCallback;
  73538. private _elementToMonitor;
  73539. private _sceneFileToLoad;
  73540. private _filesToLoad;
  73541. /**
  73542. * Creates a new FilesInput
  73543. * @param engine defines the rendering engine
  73544. * @param scene defines the hosting scene
  73545. * @param sceneLoadedCallback callback called when scene is loaded
  73546. * @param progressCallback callback called to track progress
  73547. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73548. * @param textureLoadingCallback callback called when a texture is loading
  73549. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73550. * @param onReloadCallback callback called when a reload is requested
  73551. * @param errorCallback callback call if an error occurs
  73552. */
  73553. 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>);
  73554. private _dragEnterHandler;
  73555. private _dragOverHandler;
  73556. private _dropHandler;
  73557. /**
  73558. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73559. * @param elementToMonitor defines the DOM element to track
  73560. */
  73561. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73562. /** Gets the current list of files to load */
  73563. get filesToLoad(): File[];
  73564. /**
  73565. * Release all associated resources
  73566. */
  73567. dispose(): void;
  73568. private renderFunction;
  73569. private drag;
  73570. private drop;
  73571. private _traverseFolder;
  73572. private _processFiles;
  73573. /**
  73574. * Load files from a drop event
  73575. * @param event defines the drop event to use as source
  73576. */
  73577. loadFiles(event: any): void;
  73578. private _processReload;
  73579. /**
  73580. * Reload the current scene from the loaded files
  73581. */
  73582. reload(): void;
  73583. }
  73584. }
  73585. declare module BABYLON {
  73586. /**
  73587. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73588. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73589. */
  73590. export class SceneOptimization {
  73591. /**
  73592. * Defines the priority of this optimization (0 by default which means first in the list)
  73593. */
  73594. priority: number;
  73595. /**
  73596. * Gets a string describing the action executed by the current optimization
  73597. * @returns description string
  73598. */
  73599. getDescription(): string;
  73600. /**
  73601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73602. * @param scene defines the current scene where to apply this optimization
  73603. * @param optimizer defines the current optimizer
  73604. * @returns true if everything that can be done was applied
  73605. */
  73606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73607. /**
  73608. * Creates the SceneOptimization object
  73609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73610. * @param desc defines the description associated with the optimization
  73611. */
  73612. constructor(
  73613. /**
  73614. * Defines the priority of this optimization (0 by default which means first in the list)
  73615. */
  73616. priority?: number);
  73617. }
  73618. /**
  73619. * Defines an optimization used to reduce the size of render target textures
  73620. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73621. */
  73622. export class TextureOptimization extends SceneOptimization {
  73623. /**
  73624. * Defines the priority of this optimization (0 by default which means first in the list)
  73625. */
  73626. priority: number;
  73627. /**
  73628. * 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
  73629. */
  73630. maximumSize: number;
  73631. /**
  73632. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73633. */
  73634. step: number;
  73635. /**
  73636. * Gets a string describing the action executed by the current optimization
  73637. * @returns description string
  73638. */
  73639. getDescription(): string;
  73640. /**
  73641. * Creates the TextureOptimization object
  73642. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73643. * @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
  73644. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73645. */
  73646. constructor(
  73647. /**
  73648. * Defines the priority of this optimization (0 by default which means first in the list)
  73649. */
  73650. priority?: number,
  73651. /**
  73652. * 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
  73653. */
  73654. maximumSize?: number,
  73655. /**
  73656. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73657. */
  73658. step?: number);
  73659. /**
  73660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73661. * @param scene defines the current scene where to apply this optimization
  73662. * @param optimizer defines the current optimizer
  73663. * @returns true if everything that can be done was applied
  73664. */
  73665. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73666. }
  73667. /**
  73668. * Defines an optimization used to increase or decrease the rendering resolution
  73669. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73670. */
  73671. export class HardwareScalingOptimization extends SceneOptimization {
  73672. /**
  73673. * Defines the priority of this optimization (0 by default which means first in the list)
  73674. */
  73675. priority: number;
  73676. /**
  73677. * Defines the maximum scale to use (2 by default)
  73678. */
  73679. maximumScale: number;
  73680. /**
  73681. * Defines the step to use between two passes (0.5 by default)
  73682. */
  73683. step: number;
  73684. private _currentScale;
  73685. private _directionOffset;
  73686. /**
  73687. * Gets a string describing the action executed by the current optimization
  73688. * @return description string
  73689. */
  73690. getDescription(): string;
  73691. /**
  73692. * Creates the HardwareScalingOptimization object
  73693. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73694. * @param maximumScale defines the maximum scale to use (2 by default)
  73695. * @param step defines the step to use between two passes (0.5 by default)
  73696. */
  73697. constructor(
  73698. /**
  73699. * Defines the priority of this optimization (0 by default which means first in the list)
  73700. */
  73701. priority?: number,
  73702. /**
  73703. * Defines the maximum scale to use (2 by default)
  73704. */
  73705. maximumScale?: number,
  73706. /**
  73707. * Defines the step to use between two passes (0.5 by default)
  73708. */
  73709. step?: number);
  73710. /**
  73711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73712. * @param scene defines the current scene where to apply this optimization
  73713. * @param optimizer defines the current optimizer
  73714. * @returns true if everything that can be done was applied
  73715. */
  73716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73717. }
  73718. /**
  73719. * Defines an optimization used to remove shadows
  73720. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73721. */
  73722. export class ShadowsOptimization extends SceneOptimization {
  73723. /**
  73724. * Gets a string describing the action executed by the current optimization
  73725. * @return description string
  73726. */
  73727. getDescription(): string;
  73728. /**
  73729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73730. * @param scene defines the current scene where to apply this optimization
  73731. * @param optimizer defines the current optimizer
  73732. * @returns true if everything that can be done was applied
  73733. */
  73734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73735. }
  73736. /**
  73737. * Defines an optimization used to turn post-processes off
  73738. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73739. */
  73740. export class PostProcessesOptimization extends SceneOptimization {
  73741. /**
  73742. * Gets a string describing the action executed by the current optimization
  73743. * @return description string
  73744. */
  73745. getDescription(): string;
  73746. /**
  73747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73748. * @param scene defines the current scene where to apply this optimization
  73749. * @param optimizer defines the current optimizer
  73750. * @returns true if everything that can be done was applied
  73751. */
  73752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73753. }
  73754. /**
  73755. * Defines an optimization used to turn lens flares off
  73756. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73757. */
  73758. export class LensFlaresOptimization extends SceneOptimization {
  73759. /**
  73760. * Gets a string describing the action executed by the current optimization
  73761. * @return description string
  73762. */
  73763. getDescription(): string;
  73764. /**
  73765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73766. * @param scene defines the current scene where to apply this optimization
  73767. * @param optimizer defines the current optimizer
  73768. * @returns true if everything that can be done was applied
  73769. */
  73770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73771. }
  73772. /**
  73773. * Defines an optimization based on user defined callback.
  73774. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73775. */
  73776. export class CustomOptimization extends SceneOptimization {
  73777. /**
  73778. * Callback called to apply the custom optimization.
  73779. */
  73780. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73781. /**
  73782. * Callback called to get custom description
  73783. */
  73784. onGetDescription: () => string;
  73785. /**
  73786. * Gets a string describing the action executed by the current optimization
  73787. * @returns description string
  73788. */
  73789. getDescription(): string;
  73790. /**
  73791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73792. * @param scene defines the current scene where to apply this optimization
  73793. * @param optimizer defines the current optimizer
  73794. * @returns true if everything that can be done was applied
  73795. */
  73796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73797. }
  73798. /**
  73799. * Defines an optimization used to turn particles off
  73800. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73801. */
  73802. export class ParticlesOptimization extends SceneOptimization {
  73803. /**
  73804. * Gets a string describing the action executed by the current optimization
  73805. * @return description string
  73806. */
  73807. getDescription(): string;
  73808. /**
  73809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73810. * @param scene defines the current scene where to apply this optimization
  73811. * @param optimizer defines the current optimizer
  73812. * @returns true if everything that can be done was applied
  73813. */
  73814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73815. }
  73816. /**
  73817. * Defines an optimization used to turn render targets off
  73818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73819. */
  73820. export class RenderTargetsOptimization extends SceneOptimization {
  73821. /**
  73822. * Gets a string describing the action executed by the current optimization
  73823. * @return description string
  73824. */
  73825. getDescription(): string;
  73826. /**
  73827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73828. * @param scene defines the current scene where to apply this optimization
  73829. * @param optimizer defines the current optimizer
  73830. * @returns true if everything that can be done was applied
  73831. */
  73832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73833. }
  73834. /**
  73835. * Defines an optimization used to merge meshes with compatible materials
  73836. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73837. */
  73838. export class MergeMeshesOptimization extends SceneOptimization {
  73839. private static _UpdateSelectionTree;
  73840. /**
  73841. * Gets or sets a boolean which defines if optimization octree has to be updated
  73842. */
  73843. static get UpdateSelectionTree(): boolean;
  73844. /**
  73845. * Gets or sets a boolean which defines if optimization octree has to be updated
  73846. */
  73847. static set UpdateSelectionTree(value: boolean);
  73848. /**
  73849. * Gets a string describing the action executed by the current optimization
  73850. * @return description string
  73851. */
  73852. getDescription(): string;
  73853. private _canBeMerged;
  73854. /**
  73855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73856. * @param scene defines the current scene where to apply this optimization
  73857. * @param optimizer defines the current optimizer
  73858. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73859. * @returns true if everything that can be done was applied
  73860. */
  73861. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73862. }
  73863. /**
  73864. * Defines a list of options used by SceneOptimizer
  73865. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73866. */
  73867. export class SceneOptimizerOptions {
  73868. /**
  73869. * Defines the target frame rate to reach (60 by default)
  73870. */
  73871. targetFrameRate: number;
  73872. /**
  73873. * Defines the interval between two checkes (2000ms by default)
  73874. */
  73875. trackerDuration: number;
  73876. /**
  73877. * Gets the list of optimizations to apply
  73878. */
  73879. optimizations: SceneOptimization[];
  73880. /**
  73881. * Creates a new list of options used by SceneOptimizer
  73882. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73883. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73884. */
  73885. constructor(
  73886. /**
  73887. * Defines the target frame rate to reach (60 by default)
  73888. */
  73889. targetFrameRate?: number,
  73890. /**
  73891. * Defines the interval between two checkes (2000ms by default)
  73892. */
  73893. trackerDuration?: number);
  73894. /**
  73895. * Add a new optimization
  73896. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73897. * @returns the current SceneOptimizerOptions
  73898. */
  73899. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73900. /**
  73901. * Add a new custom optimization
  73902. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73903. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73905. * @returns the current SceneOptimizerOptions
  73906. */
  73907. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73908. /**
  73909. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73910. * @param targetFrameRate defines the target frame rate (60 by default)
  73911. * @returns a SceneOptimizerOptions object
  73912. */
  73913. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73914. /**
  73915. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73916. * @param targetFrameRate defines the target frame rate (60 by default)
  73917. * @returns a SceneOptimizerOptions object
  73918. */
  73919. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73920. /**
  73921. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73922. * @param targetFrameRate defines the target frame rate (60 by default)
  73923. * @returns a SceneOptimizerOptions object
  73924. */
  73925. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73926. }
  73927. /**
  73928. * Class used to run optimizations in order to reach a target frame rate
  73929. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73930. */
  73931. export class SceneOptimizer implements IDisposable {
  73932. private _isRunning;
  73933. private _options;
  73934. private _scene;
  73935. private _currentPriorityLevel;
  73936. private _targetFrameRate;
  73937. private _trackerDuration;
  73938. private _currentFrameRate;
  73939. private _sceneDisposeObserver;
  73940. private _improvementMode;
  73941. /**
  73942. * Defines an observable called when the optimizer reaches the target frame rate
  73943. */
  73944. onSuccessObservable: Observable<SceneOptimizer>;
  73945. /**
  73946. * Defines an observable called when the optimizer enables an optimization
  73947. */
  73948. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73949. /**
  73950. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73951. */
  73952. onFailureObservable: Observable<SceneOptimizer>;
  73953. /**
  73954. * Gets a boolean indicating if the optimizer is in improvement mode
  73955. */
  73956. get isInImprovementMode(): boolean;
  73957. /**
  73958. * Gets the current priority level (0 at start)
  73959. */
  73960. get currentPriorityLevel(): number;
  73961. /**
  73962. * Gets the current frame rate checked by the SceneOptimizer
  73963. */
  73964. get currentFrameRate(): number;
  73965. /**
  73966. * Gets or sets the current target frame rate (60 by default)
  73967. */
  73968. get targetFrameRate(): number;
  73969. /**
  73970. * Gets or sets the current target frame rate (60 by default)
  73971. */
  73972. set targetFrameRate(value: number);
  73973. /**
  73974. * Gets or sets the current interval between two checks (every 2000ms by default)
  73975. */
  73976. get trackerDuration(): number;
  73977. /**
  73978. * Gets or sets the current interval between two checks (every 2000ms by default)
  73979. */
  73980. set trackerDuration(value: number);
  73981. /**
  73982. * Gets the list of active optimizations
  73983. */
  73984. get optimizations(): SceneOptimization[];
  73985. /**
  73986. * Creates a new SceneOptimizer
  73987. * @param scene defines the scene to work on
  73988. * @param options defines the options to use with the SceneOptimizer
  73989. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73990. * @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)
  73991. */
  73992. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73993. /**
  73994. * Stops the current optimizer
  73995. */
  73996. stop(): void;
  73997. /**
  73998. * Reset the optimizer to initial step (current priority level = 0)
  73999. */
  74000. reset(): void;
  74001. /**
  74002. * Start the optimizer. By default it will try to reach a specific framerate
  74003. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74004. */
  74005. start(): void;
  74006. private _checkCurrentState;
  74007. /**
  74008. * Release all resources
  74009. */
  74010. dispose(): void;
  74011. /**
  74012. * Helper function to create a SceneOptimizer with one single line of code
  74013. * @param scene defines the scene to work on
  74014. * @param options defines the options to use with the SceneOptimizer
  74015. * @param onSuccess defines a callback to call on success
  74016. * @param onFailure defines a callback to call on failure
  74017. * @returns the new SceneOptimizer object
  74018. */
  74019. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74020. }
  74021. }
  74022. declare module BABYLON {
  74023. /**
  74024. * Class used to serialize a scene into a string
  74025. */
  74026. export class SceneSerializer {
  74027. /**
  74028. * Clear cache used by a previous serialization
  74029. */
  74030. static ClearCache(): void;
  74031. /**
  74032. * Serialize a scene into a JSON compatible object
  74033. * @param scene defines the scene to serialize
  74034. * @returns a JSON compatible object
  74035. */
  74036. static Serialize(scene: Scene): any;
  74037. /**
  74038. * Serialize a mesh into a JSON compatible object
  74039. * @param toSerialize defines the mesh to serialize
  74040. * @param withParents defines if parents must be serialized as well
  74041. * @param withChildren defines if children must be serialized as well
  74042. * @returns a JSON compatible object
  74043. */
  74044. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74045. }
  74046. }
  74047. declare module BABYLON {
  74048. /**
  74049. * Class used to host texture specific utilities
  74050. */
  74051. export class TextureTools {
  74052. /**
  74053. * Uses the GPU to create a copy texture rescaled at a given size
  74054. * @param texture Texture to copy from
  74055. * @param width defines the desired width
  74056. * @param height defines the desired height
  74057. * @param useBilinearMode defines if bilinear mode has to be used
  74058. * @return the generated texture
  74059. */
  74060. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74061. }
  74062. }
  74063. declare module BABYLON {
  74064. /**
  74065. * This represents the different options available for the video capture.
  74066. */
  74067. export interface VideoRecorderOptions {
  74068. /** Defines the mime type of the video. */
  74069. mimeType: string;
  74070. /** Defines the FPS the video should be recorded at. */
  74071. fps: number;
  74072. /** Defines the chunk size for the recording data. */
  74073. recordChunckSize: number;
  74074. /** The audio tracks to attach to the recording. */
  74075. audioTracks?: MediaStreamTrack[];
  74076. }
  74077. /**
  74078. * This can help with recording videos from BabylonJS.
  74079. * This is based on the available WebRTC functionalities of the browser.
  74080. *
  74081. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74082. */
  74083. export class VideoRecorder {
  74084. private static readonly _defaultOptions;
  74085. /**
  74086. * Returns whether or not the VideoRecorder is available in your browser.
  74087. * @param engine Defines the Babylon Engine.
  74088. * @returns true if supported otherwise false.
  74089. */
  74090. static IsSupported(engine: Engine): boolean;
  74091. private readonly _options;
  74092. private _canvas;
  74093. private _mediaRecorder;
  74094. private _recordedChunks;
  74095. private _fileName;
  74096. private _resolve;
  74097. private _reject;
  74098. /**
  74099. * True when a recording is already in progress.
  74100. */
  74101. get isRecording(): boolean;
  74102. /**
  74103. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74104. * @param engine Defines the BabylonJS Engine you wish to record.
  74105. * @param options Defines options that can be used to customize the capture.
  74106. */
  74107. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74108. /**
  74109. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74110. */
  74111. stopRecording(): void;
  74112. /**
  74113. * Starts recording the canvas for a max duration specified in parameters.
  74114. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74115. * If null no automatic download will start and you can rely on the promise to get the data back.
  74116. * @param maxDuration Defines the maximum recording time in seconds.
  74117. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74118. * @return A promise callback at the end of the recording with the video data in Blob.
  74119. */
  74120. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74121. /**
  74122. * Releases internal resources used during the recording.
  74123. */
  74124. dispose(): void;
  74125. private _handleDataAvailable;
  74126. private _handleError;
  74127. private _handleStop;
  74128. }
  74129. }
  74130. declare module BABYLON {
  74131. /**
  74132. * Class containing a set of static utilities functions for screenshots
  74133. */
  74134. export class ScreenshotTools {
  74135. /**
  74136. * Captures a screenshot of the current rendering
  74137. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74138. * @param engine defines the rendering engine
  74139. * @param camera defines the source camera
  74140. * @param size This parameter can be set to a single number or to an object with the
  74141. * following (optional) properties: precision, width, height. If a single number is passed,
  74142. * it will be used for both width and height. If an object is passed, the screenshot size
  74143. * will be derived from the parameters. The precision property is a multiplier allowing
  74144. * rendering at a higher or lower resolution
  74145. * @param successCallback defines the callback receives a single parameter which contains the
  74146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74147. * src parameter of an <img> to display it
  74148. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74149. * Check your browser for supported MIME types
  74150. */
  74151. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74152. /**
  74153. * Captures a screenshot of the current rendering
  74154. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74155. * @param engine defines the rendering engine
  74156. * @param camera defines the source camera
  74157. * @param size This parameter can be set to a single number or to an object with the
  74158. * following (optional) properties: precision, width, height. If a single number is passed,
  74159. * it will be used for both width and height. If an object is passed, the screenshot size
  74160. * will be derived from the parameters. The precision property is a multiplier allowing
  74161. * rendering at a higher or lower resolution
  74162. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74163. * Check your browser for supported MIME types
  74164. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74165. * to the src parameter of an <img> to display it
  74166. */
  74167. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74168. /**
  74169. * Generates an image screenshot from the specified camera.
  74170. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74171. * @param engine The engine to use for rendering
  74172. * @param camera The camera to use for rendering
  74173. * @param size This parameter can be set to a single number or to an object with the
  74174. * following (optional) properties: precision, width, height. If a single number is passed,
  74175. * it will be used for both width and height. If an object is passed, the screenshot size
  74176. * will be derived from the parameters. The precision property is a multiplier allowing
  74177. * rendering at a higher or lower resolution
  74178. * @param successCallback The callback receives a single parameter which contains the
  74179. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74180. * src parameter of an <img> to display it
  74181. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74182. * Check your browser for supported MIME types
  74183. * @param samples Texture samples (default: 1)
  74184. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74185. * @param fileName A name for for the downloaded file.
  74186. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74187. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74188. */
  74189. 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;
  74190. /**
  74191. * Generates an image screenshot from the specified camera.
  74192. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74193. * @param engine The engine to use for rendering
  74194. * @param camera The camera to use for rendering
  74195. * @param size This parameter can be set to a single number or to an object with the
  74196. * following (optional) properties: precision, width, height. If a single number is passed,
  74197. * it will be used for both width and height. If an object is passed, the screenshot size
  74198. * will be derived from the parameters. The precision property is a multiplier allowing
  74199. * rendering at a higher or lower resolution
  74200. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74201. * Check your browser for supported MIME types
  74202. * @param samples Texture samples (default: 1)
  74203. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74204. * @param fileName A name for for the downloaded file.
  74205. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74206. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74207. * to the src parameter of an <img> to display it
  74208. */
  74209. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74210. /**
  74211. * Gets height and width for screenshot size
  74212. * @private
  74213. */
  74214. private static _getScreenshotSize;
  74215. }
  74216. }
  74217. declare module BABYLON {
  74218. /**
  74219. * Interface for a data buffer
  74220. */
  74221. export interface IDataBuffer {
  74222. /**
  74223. * Reads bytes from the data buffer.
  74224. * @param byteOffset The byte offset to read
  74225. * @param byteLength The byte length to read
  74226. * @returns A promise that resolves when the bytes are read
  74227. */
  74228. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74229. /**
  74230. * The byte length of the buffer.
  74231. */
  74232. readonly byteLength: number;
  74233. }
  74234. /**
  74235. * Utility class for reading from a data buffer
  74236. */
  74237. export class DataReader {
  74238. /**
  74239. * The data buffer associated with this data reader.
  74240. */
  74241. readonly buffer: IDataBuffer;
  74242. /**
  74243. * The current byte offset from the beginning of the data buffer.
  74244. */
  74245. byteOffset: number;
  74246. private _dataView;
  74247. private _dataByteOffset;
  74248. /**
  74249. * Constructor
  74250. * @param buffer The buffer to read
  74251. */
  74252. constructor(buffer: IDataBuffer);
  74253. /**
  74254. * Loads the given byte length.
  74255. * @param byteLength The byte length to load
  74256. * @returns A promise that resolves when the load is complete
  74257. */
  74258. loadAsync(byteLength: number): Promise<void>;
  74259. /**
  74260. * Read a unsigned 32-bit integer from the currently loaded data range.
  74261. * @returns The 32-bit integer read
  74262. */
  74263. readUint32(): number;
  74264. /**
  74265. * Read a byte array from the currently loaded data range.
  74266. * @param byteLength The byte length to read
  74267. * @returns The byte array read
  74268. */
  74269. readUint8Array(byteLength: number): Uint8Array;
  74270. /**
  74271. * Read a string from the currently loaded data range.
  74272. * @param byteLength The byte length to read
  74273. * @returns The string read
  74274. */
  74275. readString(byteLength: number): string;
  74276. /**
  74277. * Skips the given byte length the currently loaded data range.
  74278. * @param byteLength The byte length to skip
  74279. */
  74280. skipBytes(byteLength: number): void;
  74281. }
  74282. }
  74283. declare module BABYLON {
  74284. /**
  74285. * Class for storing data to local storage if available or in-memory storage otherwise
  74286. */
  74287. export class DataStorage {
  74288. private static _Storage;
  74289. private static _GetStorage;
  74290. /**
  74291. * Reads a string from the data storage
  74292. * @param key The key to read
  74293. * @param defaultValue The value if the key doesn't exist
  74294. * @returns The string value
  74295. */
  74296. static ReadString(key: string, defaultValue: string): string;
  74297. /**
  74298. * Writes a string to the data storage
  74299. * @param key The key to write
  74300. * @param value The value to write
  74301. */
  74302. static WriteString(key: string, value: string): void;
  74303. /**
  74304. * Reads a boolean from the data storage
  74305. * @param key The key to read
  74306. * @param defaultValue The value if the key doesn't exist
  74307. * @returns The boolean value
  74308. */
  74309. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74310. /**
  74311. * Writes a boolean to the data storage
  74312. * @param key The key to write
  74313. * @param value The value to write
  74314. */
  74315. static WriteBoolean(key: string, value: boolean): void;
  74316. /**
  74317. * Reads a number from the data storage
  74318. * @param key The key to read
  74319. * @param defaultValue The value if the key doesn't exist
  74320. * @returns The number value
  74321. */
  74322. static ReadNumber(key: string, defaultValue: number): number;
  74323. /**
  74324. * Writes a number to the data storage
  74325. * @param key The key to write
  74326. * @param value The value to write
  74327. */
  74328. static WriteNumber(key: string, value: number): void;
  74329. }
  74330. }
  74331. declare module BABYLON {
  74332. /**
  74333. * Class used to record delta files between 2 scene states
  74334. */
  74335. export class SceneRecorder {
  74336. private _trackedScene;
  74337. private _savedJSON;
  74338. /**
  74339. * Track a given scene. This means the current scene state will be considered the original state
  74340. * @param scene defines the scene to track
  74341. */
  74342. track(scene: Scene): void;
  74343. /**
  74344. * Get the delta between current state and original state
  74345. * @returns a string containing the delta
  74346. */
  74347. getDelta(): any;
  74348. private _compareArray;
  74349. private _compareObjects;
  74350. private _compareCollections;
  74351. private static GetShadowGeneratorById;
  74352. /**
  74353. * Apply a given delta to a given scene
  74354. * @param deltaJSON defines the JSON containing the delta
  74355. * @param scene defines the scene to apply the delta to
  74356. */
  74357. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74358. private static _ApplyPropertiesToEntity;
  74359. private static _ApplyDeltaForEntity;
  74360. }
  74361. }
  74362. declare module BABYLON {
  74363. /**
  74364. * An interface for all Hit test features
  74365. */
  74366. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74367. /**
  74368. * Triggered when new babylon (transformed) hit test results are available
  74369. */
  74370. onHitTestResultObservable: Observable<T[]>;
  74371. }
  74372. /**
  74373. * Options used for hit testing
  74374. */
  74375. export interface IWebXRLegacyHitTestOptions {
  74376. /**
  74377. * Only test when user interacted with the scene. Default - hit test every frame
  74378. */
  74379. testOnPointerDownOnly?: boolean;
  74380. /**
  74381. * The node to use to transform the local results to world coordinates
  74382. */
  74383. worldParentNode?: TransformNode;
  74384. }
  74385. /**
  74386. * Interface defining the babylon result of raycasting/hit-test
  74387. */
  74388. export interface IWebXRLegacyHitResult {
  74389. /**
  74390. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74391. */
  74392. transformationMatrix: Matrix;
  74393. /**
  74394. * The native hit test result
  74395. */
  74396. xrHitResult: XRHitResult | XRHitTestResult;
  74397. }
  74398. /**
  74399. * The currently-working hit-test module.
  74400. * Hit test (or Ray-casting) is used to interact with the real world.
  74401. * For further information read here - https://github.com/immersive-web/hit-test
  74402. */
  74403. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74404. /**
  74405. * options to use when constructing this feature
  74406. */
  74407. readonly options: IWebXRLegacyHitTestOptions;
  74408. private _direction;
  74409. private _mat;
  74410. private _onSelectEnabled;
  74411. private _origin;
  74412. /**
  74413. * The module's name
  74414. */
  74415. static readonly Name: string;
  74416. /**
  74417. * The (Babylon) version of this module.
  74418. * This is an integer representing the implementation version.
  74419. * This number does not correspond to the WebXR specs version
  74420. */
  74421. static readonly Version: number;
  74422. /**
  74423. * Populated with the last native XR Hit Results
  74424. */
  74425. lastNativeXRHitResults: XRHitResult[];
  74426. /**
  74427. * Triggered when new babylon (transformed) hit test results are available
  74428. */
  74429. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74430. /**
  74431. * Creates a new instance of the (legacy version) hit test feature
  74432. * @param _xrSessionManager an instance of WebXRSessionManager
  74433. * @param options options to use when constructing this feature
  74434. */
  74435. constructor(_xrSessionManager: WebXRSessionManager,
  74436. /**
  74437. * options to use when constructing this feature
  74438. */
  74439. options?: IWebXRLegacyHitTestOptions);
  74440. /**
  74441. * execute a hit test with an XR Ray
  74442. *
  74443. * @param xrSession a native xrSession that will execute this hit test
  74444. * @param xrRay the ray (position and direction) to use for ray-casting
  74445. * @param referenceSpace native XR reference space to use for the hit-test
  74446. * @param filter filter function that will filter the results
  74447. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74448. */
  74449. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74450. /**
  74451. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74452. * @param event the (select) event to use to select with
  74453. * @param referenceSpace the reference space to use for this hit test
  74454. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74455. */
  74456. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74457. /**
  74458. * attach this feature
  74459. * Will usually be called by the features manager
  74460. *
  74461. * @returns true if successful.
  74462. */
  74463. attach(): boolean;
  74464. /**
  74465. * detach this feature.
  74466. * Will usually be called by the features manager
  74467. *
  74468. * @returns true if successful.
  74469. */
  74470. detach(): boolean;
  74471. /**
  74472. * Dispose this feature and all of the resources attached
  74473. */
  74474. dispose(): void;
  74475. protected _onXRFrame(frame: XRFrame): void;
  74476. private _onHitTestResults;
  74477. private _onSelect;
  74478. }
  74479. }
  74480. declare module BABYLON {
  74481. /**
  74482. * Options used for hit testing (version 2)
  74483. */
  74484. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74485. /**
  74486. * Do not create a permanent hit test. Will usually be used when only
  74487. * transient inputs are needed.
  74488. */
  74489. disablePermanentHitTest?: boolean;
  74490. /**
  74491. * Enable transient (for example touch-based) hit test inspections
  74492. */
  74493. enableTransientHitTest?: boolean;
  74494. /**
  74495. * Offset ray for the permanent hit test
  74496. */
  74497. offsetRay?: Vector3;
  74498. /**
  74499. * Offset ray for the transient hit test
  74500. */
  74501. transientOffsetRay?: Vector3;
  74502. /**
  74503. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74504. */
  74505. useReferenceSpace?: boolean;
  74506. /**
  74507. * Override the default entity type(s) of the hit-test result
  74508. */
  74509. entityTypes?: XRHitTestTrackableType[];
  74510. }
  74511. /**
  74512. * Interface defining the babylon result of hit-test
  74513. */
  74514. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74515. /**
  74516. * The input source that generated this hit test (if transient)
  74517. */
  74518. inputSource?: XRInputSource;
  74519. /**
  74520. * Is this a transient hit test
  74521. */
  74522. isTransient?: boolean;
  74523. /**
  74524. * Position of the hit test result
  74525. */
  74526. position: Vector3;
  74527. /**
  74528. * Rotation of the hit test result
  74529. */
  74530. rotationQuaternion: Quaternion;
  74531. /**
  74532. * The native hit test result
  74533. */
  74534. xrHitResult: XRHitTestResult;
  74535. }
  74536. /**
  74537. * The currently-working hit-test module.
  74538. * Hit test (or Ray-casting) is used to interact with the real world.
  74539. * For further information read here - https://github.com/immersive-web/hit-test
  74540. *
  74541. * Tested on chrome (mobile) 80.
  74542. */
  74543. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74544. /**
  74545. * options to use when constructing this feature
  74546. */
  74547. readonly options: IWebXRHitTestOptions;
  74548. private _tmpMat;
  74549. private _tmpPos;
  74550. private _tmpQuat;
  74551. private _transientXrHitTestSource;
  74552. private _xrHitTestSource;
  74553. private initHitTestSource;
  74554. /**
  74555. * The module's name
  74556. */
  74557. static readonly Name: string;
  74558. /**
  74559. * The (Babylon) version of this module.
  74560. * This is an integer representing the implementation version.
  74561. * This number does not correspond to the WebXR specs version
  74562. */
  74563. static readonly Version: number;
  74564. /**
  74565. * When set to true, each hit test will have its own position/rotation objects
  74566. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74567. * the developers will clone them or copy them as they see fit.
  74568. */
  74569. autoCloneTransformation: boolean;
  74570. /**
  74571. * Triggered when new babylon (transformed) hit test results are available
  74572. * Note - this will be called when results come back from the device. It can be an empty array!!
  74573. */
  74574. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74575. /**
  74576. * Use this to temporarily pause hit test checks.
  74577. */
  74578. paused: boolean;
  74579. /**
  74580. * Creates a new instance of the hit test feature
  74581. * @param _xrSessionManager an instance of WebXRSessionManager
  74582. * @param options options to use when constructing this feature
  74583. */
  74584. constructor(_xrSessionManager: WebXRSessionManager,
  74585. /**
  74586. * options to use when constructing this feature
  74587. */
  74588. options?: IWebXRHitTestOptions);
  74589. /**
  74590. * attach this feature
  74591. * Will usually be called by the features manager
  74592. *
  74593. * @returns true if successful.
  74594. */
  74595. attach(): boolean;
  74596. /**
  74597. * detach this feature.
  74598. * Will usually be called by the features manager
  74599. *
  74600. * @returns true if successful.
  74601. */
  74602. detach(): boolean;
  74603. /**
  74604. * Dispose this feature and all of the resources attached
  74605. */
  74606. dispose(): void;
  74607. protected _onXRFrame(frame: XRFrame): void;
  74608. private _processWebXRHitTestResult;
  74609. }
  74610. }
  74611. declare module BABYLON {
  74612. /**
  74613. * Configuration options of the anchor system
  74614. */
  74615. export interface IWebXRAnchorSystemOptions {
  74616. /**
  74617. * a node that will be used to convert local to world coordinates
  74618. */
  74619. worldParentNode?: TransformNode;
  74620. /**
  74621. * If set to true a reference of the created anchors will be kept until the next session starts
  74622. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74623. */
  74624. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74625. }
  74626. /**
  74627. * A babylon container for an XR Anchor
  74628. */
  74629. export interface IWebXRAnchor {
  74630. /**
  74631. * A babylon-assigned ID for this anchor
  74632. */
  74633. id: number;
  74634. /**
  74635. * Transformation matrix to apply to an object attached to this anchor
  74636. */
  74637. transformationMatrix: Matrix;
  74638. /**
  74639. * The native anchor object
  74640. */
  74641. xrAnchor: XRAnchor;
  74642. /**
  74643. * if defined, this object will be constantly updated by the anchor's position and rotation
  74644. */
  74645. attachedNode?: TransformNode;
  74646. }
  74647. /**
  74648. * An implementation of the anchor system for WebXR.
  74649. * For further information see https://github.com/immersive-web/anchors/
  74650. */
  74651. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74652. private _options;
  74653. private _lastFrameDetected;
  74654. private _trackedAnchors;
  74655. private _referenceSpaceForFrameAnchors;
  74656. private _futureAnchors;
  74657. /**
  74658. * The module's name
  74659. */
  74660. static readonly Name: string;
  74661. /**
  74662. * The (Babylon) version of this module.
  74663. * This is an integer representing the implementation version.
  74664. * This number does not correspond to the WebXR specs version
  74665. */
  74666. static readonly Version: number;
  74667. /**
  74668. * Observers registered here will be executed when a new anchor was added to the session
  74669. */
  74670. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74671. /**
  74672. * Observers registered here will be executed when an anchor was removed from the session
  74673. */
  74674. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74675. /**
  74676. * Observers registered here will be executed when an existing anchor updates
  74677. * This can execute N times every frame
  74678. */
  74679. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74680. /**
  74681. * Set the reference space to use for anchor creation, when not using a hit test.
  74682. * Will default to the session's reference space if not defined
  74683. */
  74684. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74685. /**
  74686. * constructs a new anchor system
  74687. * @param _xrSessionManager an instance of WebXRSessionManager
  74688. * @param _options configuration object for this feature
  74689. */
  74690. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74691. private _tmpVector;
  74692. private _tmpQuaternion;
  74693. private _populateTmpTransformation;
  74694. /**
  74695. * Create a new anchor point using a hit test result at a specific point in the scene
  74696. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74697. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74698. *
  74699. * @param hitTestResult The hit test result to use for this anchor creation
  74700. * @param position an optional position offset for this anchor
  74701. * @param rotationQuaternion an optional rotation offset for this anchor
  74702. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74703. */
  74704. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74705. /**
  74706. * Add a new anchor at a specific position and rotation
  74707. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74708. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74709. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74710. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74711. *
  74712. * @param position the position in which to add an anchor
  74713. * @param rotationQuaternion an optional rotation for the anchor transformation
  74714. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74715. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74716. */
  74717. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74718. /**
  74719. * detach this feature.
  74720. * Will usually be called by the features manager
  74721. *
  74722. * @returns true if successful.
  74723. */
  74724. detach(): boolean;
  74725. /**
  74726. * Dispose this feature and all of the resources attached
  74727. */
  74728. dispose(): void;
  74729. protected _onXRFrame(frame: XRFrame): void;
  74730. /**
  74731. * avoiding using Array.find for global support.
  74732. * @param xrAnchor the plane to find in the array
  74733. */
  74734. private _findIndexInAnchorArray;
  74735. private _updateAnchorWithXRFrame;
  74736. private _createAnchorAtTransformation;
  74737. }
  74738. }
  74739. declare module BABYLON {
  74740. /**
  74741. * Options used in the plane detector module
  74742. */
  74743. export interface IWebXRPlaneDetectorOptions {
  74744. /**
  74745. * The node to use to transform the local results to world coordinates
  74746. */
  74747. worldParentNode?: TransformNode;
  74748. /**
  74749. * If set to true a reference of the created planes will be kept until the next session starts
  74750. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74751. */
  74752. doNotRemovePlanesOnSessionEnded?: boolean;
  74753. }
  74754. /**
  74755. * A babylon interface for a WebXR plane.
  74756. * A Plane is actually a polygon, built from N points in space
  74757. *
  74758. * Supported in chrome 79, not supported in canary 81 ATM
  74759. */
  74760. export interface IWebXRPlane {
  74761. /**
  74762. * a babylon-assigned ID for this polygon
  74763. */
  74764. id: number;
  74765. /**
  74766. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74767. */
  74768. polygonDefinition: Array<Vector3>;
  74769. /**
  74770. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74771. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74772. */
  74773. transformationMatrix: Matrix;
  74774. /**
  74775. * the native xr-plane object
  74776. */
  74777. xrPlane: XRPlane;
  74778. }
  74779. /**
  74780. * The plane detector is used to detect planes in the real world when in AR
  74781. * For more information see https://github.com/immersive-web/real-world-geometry/
  74782. */
  74783. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74784. private _options;
  74785. private _detectedPlanes;
  74786. private _enabled;
  74787. private _lastFrameDetected;
  74788. /**
  74789. * The module's name
  74790. */
  74791. static readonly Name: string;
  74792. /**
  74793. * The (Babylon) version of this module.
  74794. * This is an integer representing the implementation version.
  74795. * This number does not correspond to the WebXR specs version
  74796. */
  74797. static readonly Version: number;
  74798. /**
  74799. * Observers registered here will be executed when a new plane was added to the session
  74800. */
  74801. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74802. /**
  74803. * Observers registered here will be executed when a plane is no longer detected in the session
  74804. */
  74805. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74806. /**
  74807. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74808. * This can execute N times every frame
  74809. */
  74810. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74811. /**
  74812. * construct a new Plane Detector
  74813. * @param _xrSessionManager an instance of xr Session manager
  74814. * @param _options configuration to use when constructing this feature
  74815. */
  74816. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74817. /**
  74818. * detach this feature.
  74819. * Will usually be called by the features manager
  74820. *
  74821. * @returns true if successful.
  74822. */
  74823. detach(): boolean;
  74824. /**
  74825. * Dispose this feature and all of the resources attached
  74826. */
  74827. dispose(): void;
  74828. protected _onXRFrame(frame: XRFrame): void;
  74829. private _init;
  74830. private _updatePlaneWithXRPlane;
  74831. /**
  74832. * avoiding using Array.find for global support.
  74833. * @param xrPlane the plane to find in the array
  74834. */
  74835. private findIndexInPlaneArray;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * Options interface for the background remover plugin
  74841. */
  74842. export interface IWebXRBackgroundRemoverOptions {
  74843. /**
  74844. * Further background meshes to disable when entering AR
  74845. */
  74846. backgroundMeshes?: AbstractMesh[];
  74847. /**
  74848. * flags to configure the removal of the environment helper.
  74849. * If not set, the entire background will be removed. If set, flags should be set as well.
  74850. */
  74851. environmentHelperRemovalFlags?: {
  74852. /**
  74853. * Should the skybox be removed (default false)
  74854. */
  74855. skyBox?: boolean;
  74856. /**
  74857. * Should the ground be removed (default false)
  74858. */
  74859. ground?: boolean;
  74860. };
  74861. /**
  74862. * don't disable the environment helper
  74863. */
  74864. ignoreEnvironmentHelper?: boolean;
  74865. }
  74866. /**
  74867. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74868. */
  74869. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74870. /**
  74871. * read-only options to be used in this module
  74872. */
  74873. readonly options: IWebXRBackgroundRemoverOptions;
  74874. /**
  74875. * The module's name
  74876. */
  74877. static readonly Name: string;
  74878. /**
  74879. * The (Babylon) version of this module.
  74880. * This is an integer representing the implementation version.
  74881. * This number does not correspond to the WebXR specs version
  74882. */
  74883. static readonly Version: number;
  74884. /**
  74885. * registered observers will be triggered when the background state changes
  74886. */
  74887. onBackgroundStateChangedObservable: Observable<boolean>;
  74888. /**
  74889. * constructs a new background remover module
  74890. * @param _xrSessionManager the session manager for this module
  74891. * @param options read-only options to be used in this module
  74892. */
  74893. constructor(_xrSessionManager: WebXRSessionManager,
  74894. /**
  74895. * read-only options to be used in this module
  74896. */
  74897. options?: IWebXRBackgroundRemoverOptions);
  74898. /**
  74899. * attach this feature
  74900. * Will usually be called by the features manager
  74901. *
  74902. * @returns true if successful.
  74903. */
  74904. attach(): boolean;
  74905. /**
  74906. * detach this feature.
  74907. * Will usually be called by the features manager
  74908. *
  74909. * @returns true if successful.
  74910. */
  74911. detach(): boolean;
  74912. /**
  74913. * Dispose this feature and all of the resources attached
  74914. */
  74915. dispose(): void;
  74916. protected _onXRFrame(_xrFrame: XRFrame): void;
  74917. private _setBackgroundState;
  74918. }
  74919. }
  74920. declare module BABYLON {
  74921. /**
  74922. * Options for the controller physics feature
  74923. */
  74924. export class IWebXRControllerPhysicsOptions {
  74925. /**
  74926. * Should the headset get its own impostor
  74927. */
  74928. enableHeadsetImpostor?: boolean;
  74929. /**
  74930. * Optional parameters for the headset impostor
  74931. */
  74932. headsetImpostorParams?: {
  74933. /**
  74934. * The type of impostor to create. Default is sphere
  74935. */
  74936. impostorType: number;
  74937. /**
  74938. * the size of the impostor. Defaults to 10cm
  74939. */
  74940. impostorSize?: number | {
  74941. width: number;
  74942. height: number;
  74943. depth: number;
  74944. };
  74945. /**
  74946. * Friction definitions
  74947. */
  74948. friction?: number;
  74949. /**
  74950. * Restitution
  74951. */
  74952. restitution?: number;
  74953. };
  74954. /**
  74955. * The physics properties of the future impostors
  74956. */
  74957. physicsProperties?: {
  74958. /**
  74959. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74960. * Note that this requires a physics engine that supports mesh impostors!
  74961. */
  74962. useControllerMesh?: boolean;
  74963. /**
  74964. * The type of impostor to create. Default is sphere
  74965. */
  74966. impostorType?: number;
  74967. /**
  74968. * the size of the impostor. Defaults to 10cm
  74969. */
  74970. impostorSize?: number | {
  74971. width: number;
  74972. height: number;
  74973. depth: number;
  74974. };
  74975. /**
  74976. * Friction definitions
  74977. */
  74978. friction?: number;
  74979. /**
  74980. * Restitution
  74981. */
  74982. restitution?: number;
  74983. };
  74984. /**
  74985. * the xr input to use with this pointer selection
  74986. */
  74987. xrInput: WebXRInput;
  74988. }
  74989. /**
  74990. * Add physics impostor to your webxr controllers,
  74991. * including naive calculation of their linear and angular velocity
  74992. */
  74993. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74994. private readonly _options;
  74995. private _attachController;
  74996. private _controllers;
  74997. private _debugMode;
  74998. private _delta;
  74999. private _headsetImpostor?;
  75000. private _headsetMesh?;
  75001. private _lastTimestamp;
  75002. private _tmpQuaternion;
  75003. private _tmpVector;
  75004. /**
  75005. * The module's name
  75006. */
  75007. static readonly Name: string;
  75008. /**
  75009. * The (Babylon) version of this module.
  75010. * This is an integer representing the implementation version.
  75011. * This number does not correspond to the webxr specs version
  75012. */
  75013. static readonly Version: number;
  75014. /**
  75015. * Construct a new Controller Physics Feature
  75016. * @param _xrSessionManager the corresponding xr session manager
  75017. * @param _options options to create this feature with
  75018. */
  75019. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75020. /**
  75021. * @hidden
  75022. * enable debugging - will show console outputs and the impostor mesh
  75023. */
  75024. _enablePhysicsDebug(): void;
  75025. /**
  75026. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75027. * @param xrController the controller to add
  75028. */
  75029. addController(xrController: WebXRInputSource): void;
  75030. /**
  75031. * attach this feature
  75032. * Will usually be called by the features manager
  75033. *
  75034. * @returns true if successful.
  75035. */
  75036. attach(): boolean;
  75037. /**
  75038. * detach this feature.
  75039. * Will usually be called by the features manager
  75040. *
  75041. * @returns true if successful.
  75042. */
  75043. detach(): boolean;
  75044. /**
  75045. * Get the headset impostor, if enabled
  75046. * @returns the impostor
  75047. */
  75048. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75049. /**
  75050. * Get the physics impostor of a specific controller.
  75051. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75052. * @param controller the controller or the controller id of which to get the impostor
  75053. * @returns the impostor or null
  75054. */
  75055. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75056. /**
  75057. * Update the physics properties provided in the constructor
  75058. * @param newProperties the new properties object
  75059. */
  75060. setPhysicsProperties(newProperties: {
  75061. impostorType?: number;
  75062. impostorSize?: number | {
  75063. width: number;
  75064. height: number;
  75065. depth: number;
  75066. };
  75067. friction?: number;
  75068. restitution?: number;
  75069. }): void;
  75070. protected _onXRFrame(_xrFrame: any): void;
  75071. private _detachController;
  75072. }
  75073. }
  75074. declare module BABYLON {
  75075. /**
  75076. * A babylon interface for a "WebXR" feature point.
  75077. * Represents the position and confidence value of a given feature point.
  75078. */
  75079. export interface IWebXRFeaturePoint {
  75080. /**
  75081. * Represents the position of the feature point in world space.
  75082. */
  75083. position: Vector3;
  75084. /**
  75085. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75086. */
  75087. confidenceValue: number;
  75088. }
  75089. /**
  75090. * The feature point system is used to detect feature points from real world geometry.
  75091. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75092. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75093. */
  75094. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75095. private _enabled;
  75096. private _featurePointCloud;
  75097. /**
  75098. * The module's name
  75099. */
  75100. static readonly Name: string;
  75101. /**
  75102. * The (Babylon) version of this module.
  75103. * This is an integer representing the implementation version.
  75104. * This number does not correspond to the WebXR specs version
  75105. */
  75106. static readonly Version: number;
  75107. /**
  75108. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75109. * Will notify the observers about which feature points have been added.
  75110. */
  75111. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75112. /**
  75113. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75114. * Will notify the observers about which feature points have been updated.
  75115. */
  75116. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75117. /**
  75118. * The current feature point cloud maintained across frames.
  75119. */
  75120. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75121. /**
  75122. * construct the feature point system
  75123. * @param _xrSessionManager an instance of xr Session manager
  75124. */
  75125. constructor(_xrSessionManager: WebXRSessionManager);
  75126. /**
  75127. * Detach this feature.
  75128. * Will usually be called by the features manager
  75129. *
  75130. * @returns true if successful.
  75131. */
  75132. detach(): boolean;
  75133. /**
  75134. * Dispose this feature and all of the resources attached
  75135. */
  75136. dispose(): void;
  75137. /**
  75138. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75139. */
  75140. protected _onXRFrame(frame: XRFrame): void;
  75141. /**
  75142. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75143. */
  75144. private _init;
  75145. }
  75146. }
  75147. declare module BABYLON {
  75148. /**
  75149. * Configuration interface for the hand tracking feature
  75150. */
  75151. export interface IWebXRHandTrackingOptions {
  75152. /**
  75153. * The xrInput that will be used as source for new hands
  75154. */
  75155. xrInput: WebXRInput;
  75156. /**
  75157. * Configuration object for the joint meshes
  75158. */
  75159. jointMeshes?: {
  75160. /**
  75161. * Should the meshes created be invisible (defaults to false)
  75162. */
  75163. invisible?: boolean;
  75164. /**
  75165. * A source mesh to be used to create instances. Defaults to a sphere.
  75166. * This mesh will be the source for all other (25) meshes.
  75167. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75168. */
  75169. sourceMesh?: Mesh;
  75170. /**
  75171. * Should the source mesh stay visible. Defaults to false
  75172. */
  75173. keepOriginalVisible?: boolean;
  75174. /**
  75175. * Scale factor for all instances (defaults to 2)
  75176. */
  75177. scaleFactor?: number;
  75178. /**
  75179. * Should each instance have its own physics impostor
  75180. */
  75181. enablePhysics?: boolean;
  75182. /**
  75183. * If enabled, override default physics properties
  75184. */
  75185. physicsProps?: {
  75186. friction?: number;
  75187. restitution?: number;
  75188. impostorType?: number;
  75189. };
  75190. /**
  75191. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75192. */
  75193. handMesh?: AbstractMesh;
  75194. };
  75195. }
  75196. /**
  75197. * Parts of the hands divided to writs and finger names
  75198. */
  75199. export const enum HandPart {
  75200. /**
  75201. * HandPart - Wrist
  75202. */
  75203. WRIST = "wrist",
  75204. /**
  75205. * HandPart - The THumb
  75206. */
  75207. THUMB = "thumb",
  75208. /**
  75209. * HandPart - Index finger
  75210. */
  75211. INDEX = "index",
  75212. /**
  75213. * HandPart - Middle finger
  75214. */
  75215. MIDDLE = "middle",
  75216. /**
  75217. * HandPart - Ring finger
  75218. */
  75219. RING = "ring",
  75220. /**
  75221. * HandPart - Little finger
  75222. */
  75223. LITTLE = "little"
  75224. }
  75225. /**
  75226. * Representing a single hand (with its corresponding native XRHand object)
  75227. */
  75228. export class WebXRHand implements IDisposable {
  75229. /** the controller to which the hand correlates */
  75230. readonly xrController: WebXRInputSource;
  75231. /** the meshes to be used to track the hand joints */
  75232. readonly trackedMeshes: AbstractMesh[];
  75233. /**
  75234. * Hand-parts definition (key is HandPart)
  75235. */
  75236. handPartsDefinition: {
  75237. [key: string]: number[];
  75238. };
  75239. /**
  75240. * Populate the HandPartsDefinition object.
  75241. * This is called as a side effect since certain browsers don't have XRHand defined.
  75242. */
  75243. private generateHandPartsDefinition;
  75244. /**
  75245. * Construct a new hand object
  75246. * @param xrController the controller to which the hand correlates
  75247. * @param trackedMeshes the meshes to be used to track the hand joints
  75248. */
  75249. constructor(
  75250. /** the controller to which the hand correlates */
  75251. xrController: WebXRInputSource,
  75252. /** the meshes to be used to track the hand joints */
  75253. trackedMeshes: AbstractMesh[]);
  75254. /**
  75255. * Update this hand from the latest xr frame
  75256. * @param xrFrame xrFrame to update from
  75257. * @param referenceSpace The current viewer reference space
  75258. * @param scaleFactor optional scale factor for the meshes
  75259. */
  75260. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75261. /**
  75262. * Get meshes of part of the hand
  75263. * @param part the part of hand to get
  75264. * @returns An array of meshes that correlate to the hand part requested
  75265. */
  75266. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75267. /**
  75268. * Dispose this Hand object
  75269. */
  75270. dispose(): void;
  75271. }
  75272. /**
  75273. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75274. */
  75275. export class WebXRHandTracking extends WebXRAbstractFeature {
  75276. /**
  75277. * options to use when constructing this feature
  75278. */
  75279. readonly options: IWebXRHandTrackingOptions;
  75280. private static _idCounter;
  75281. /**
  75282. * The module's name
  75283. */
  75284. static readonly Name: string;
  75285. /**
  75286. * The (Babylon) version of this module.
  75287. * This is an integer representing the implementation version.
  75288. * This number does not correspond to the WebXR specs version
  75289. */
  75290. static readonly Version: number;
  75291. /**
  75292. * This observable will notify registered observers when a new hand object was added and initialized
  75293. */
  75294. onHandAddedObservable: Observable<WebXRHand>;
  75295. /**
  75296. * This observable will notify its observers right before the hand object is disposed
  75297. */
  75298. onHandRemovedObservable: Observable<WebXRHand>;
  75299. private _hands;
  75300. /**
  75301. * Creates a new instance of the hit test feature
  75302. * @param _xrSessionManager an instance of WebXRSessionManager
  75303. * @param options options to use when constructing this feature
  75304. */
  75305. constructor(_xrSessionManager: WebXRSessionManager,
  75306. /**
  75307. * options to use when constructing this feature
  75308. */
  75309. options: IWebXRHandTrackingOptions);
  75310. /**
  75311. * Check if the needed objects are defined.
  75312. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75313. */
  75314. isCompatible(): boolean;
  75315. /**
  75316. * attach this feature
  75317. * Will usually be called by the features manager
  75318. *
  75319. * @returns true if successful.
  75320. */
  75321. attach(): boolean;
  75322. /**
  75323. * detach this feature.
  75324. * Will usually be called by the features manager
  75325. *
  75326. * @returns true if successful.
  75327. */
  75328. detach(): boolean;
  75329. /**
  75330. * Dispose this feature and all of the resources attached
  75331. */
  75332. dispose(): void;
  75333. /**
  75334. * Get the hand object according to the controller id
  75335. * @param controllerId the controller id to which we want to get the hand
  75336. * @returns null if not found or the WebXRHand object if found
  75337. */
  75338. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75339. /**
  75340. * Get a hand object according to the requested handedness
  75341. * @param handedness the handedness to request
  75342. * @returns null if not found or the WebXRHand object if found
  75343. */
  75344. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75345. protected _onXRFrame(_xrFrame: XRFrame): void;
  75346. private _attachHand;
  75347. private _detachHand;
  75348. }
  75349. }
  75350. declare module BABYLON {
  75351. /**
  75352. * The motion controller class for all microsoft mixed reality controllers
  75353. */
  75354. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75355. protected readonly _mapping: {
  75356. defaultButton: {
  75357. valueNodeName: string;
  75358. unpressedNodeName: string;
  75359. pressedNodeName: string;
  75360. };
  75361. defaultAxis: {
  75362. valueNodeName: string;
  75363. minNodeName: string;
  75364. maxNodeName: string;
  75365. };
  75366. buttons: {
  75367. "xr-standard-trigger": {
  75368. rootNodeName: string;
  75369. componentProperty: string;
  75370. states: string[];
  75371. };
  75372. "xr-standard-squeeze": {
  75373. rootNodeName: string;
  75374. componentProperty: string;
  75375. states: string[];
  75376. };
  75377. "xr-standard-touchpad": {
  75378. rootNodeName: string;
  75379. labelAnchorNodeName: string;
  75380. touchPointNodeName: string;
  75381. };
  75382. "xr-standard-thumbstick": {
  75383. rootNodeName: string;
  75384. componentProperty: string;
  75385. states: string[];
  75386. };
  75387. };
  75388. axes: {
  75389. "xr-standard-touchpad": {
  75390. "x-axis": {
  75391. rootNodeName: string;
  75392. };
  75393. "y-axis": {
  75394. rootNodeName: string;
  75395. };
  75396. };
  75397. "xr-standard-thumbstick": {
  75398. "x-axis": {
  75399. rootNodeName: string;
  75400. };
  75401. "y-axis": {
  75402. rootNodeName: string;
  75403. };
  75404. };
  75405. };
  75406. };
  75407. /**
  75408. * The base url used to load the left and right controller models
  75409. */
  75410. static MODEL_BASE_URL: string;
  75411. /**
  75412. * The name of the left controller model file
  75413. */
  75414. static MODEL_LEFT_FILENAME: string;
  75415. /**
  75416. * The name of the right controller model file
  75417. */
  75418. static MODEL_RIGHT_FILENAME: string;
  75419. profileId: string;
  75420. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75421. protected _getFilenameAndPath(): {
  75422. filename: string;
  75423. path: string;
  75424. };
  75425. protected _getModelLoadingConstraints(): boolean;
  75426. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75427. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75428. protected _updateModel(): void;
  75429. }
  75430. }
  75431. declare module BABYLON {
  75432. /**
  75433. * The motion controller class for oculus touch (quest, rift).
  75434. * This class supports legacy mapping as well the standard xr mapping
  75435. */
  75436. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75437. private _forceLegacyControllers;
  75438. private _modelRootNode;
  75439. /**
  75440. * The base url used to load the left and right controller models
  75441. */
  75442. static MODEL_BASE_URL: string;
  75443. /**
  75444. * The name of the left controller model file
  75445. */
  75446. static MODEL_LEFT_FILENAME: string;
  75447. /**
  75448. * The name of the right controller model file
  75449. */
  75450. static MODEL_RIGHT_FILENAME: string;
  75451. /**
  75452. * Base Url for the Quest controller model.
  75453. */
  75454. static QUEST_MODEL_BASE_URL: string;
  75455. profileId: string;
  75456. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75457. protected _getFilenameAndPath(): {
  75458. filename: string;
  75459. path: string;
  75460. };
  75461. protected _getModelLoadingConstraints(): boolean;
  75462. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75463. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75464. protected _updateModel(): void;
  75465. /**
  75466. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75467. * between the touch and touch 2.
  75468. */
  75469. private _isQuest;
  75470. }
  75471. }
  75472. declare module BABYLON {
  75473. /**
  75474. * The motion controller class for the standard HTC-Vive controllers
  75475. */
  75476. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75477. private _modelRootNode;
  75478. /**
  75479. * The base url used to load the left and right controller models
  75480. */
  75481. static MODEL_BASE_URL: string;
  75482. /**
  75483. * File name for the controller model.
  75484. */
  75485. static MODEL_FILENAME: string;
  75486. profileId: string;
  75487. /**
  75488. * Create a new Vive motion controller object
  75489. * @param scene the scene to use to create this controller
  75490. * @param gamepadObject the corresponding gamepad object
  75491. * @param handedness the handedness of the controller
  75492. */
  75493. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75494. protected _getFilenameAndPath(): {
  75495. filename: string;
  75496. path: string;
  75497. };
  75498. protected _getModelLoadingConstraints(): boolean;
  75499. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75500. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75501. protected _updateModel(): void;
  75502. }
  75503. }
  75504. declare module BABYLON {
  75505. /**
  75506. * A cursor which tracks a point on a path
  75507. */
  75508. export class PathCursor {
  75509. private path;
  75510. /**
  75511. * Stores path cursor callbacks for when an onchange event is triggered
  75512. */
  75513. private _onchange;
  75514. /**
  75515. * The value of the path cursor
  75516. */
  75517. value: number;
  75518. /**
  75519. * The animation array of the path cursor
  75520. */
  75521. animations: Animation[];
  75522. /**
  75523. * Initializes the path cursor
  75524. * @param path The path to track
  75525. */
  75526. constructor(path: Path2);
  75527. /**
  75528. * Gets the cursor point on the path
  75529. * @returns A point on the path cursor at the cursor location
  75530. */
  75531. getPoint(): Vector3;
  75532. /**
  75533. * Moves the cursor ahead by the step amount
  75534. * @param step The amount to move the cursor forward
  75535. * @returns This path cursor
  75536. */
  75537. moveAhead(step?: number): PathCursor;
  75538. /**
  75539. * Moves the cursor behind by the step amount
  75540. * @param step The amount to move the cursor back
  75541. * @returns This path cursor
  75542. */
  75543. moveBack(step?: number): PathCursor;
  75544. /**
  75545. * Moves the cursor by the step amount
  75546. * If the step amount is greater than one, an exception is thrown
  75547. * @param step The amount to move the cursor
  75548. * @returns This path cursor
  75549. */
  75550. move(step: number): PathCursor;
  75551. /**
  75552. * Ensures that the value is limited between zero and one
  75553. * @returns This path cursor
  75554. */
  75555. private ensureLimits;
  75556. /**
  75557. * Runs onchange callbacks on change (used by the animation engine)
  75558. * @returns This path cursor
  75559. */
  75560. private raiseOnChange;
  75561. /**
  75562. * Executes a function on change
  75563. * @param f A path cursor onchange callback
  75564. * @returns This path cursor
  75565. */
  75566. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75567. }
  75568. }
  75569. declare module BABYLON {
  75570. /** @hidden */
  75571. export var blurPixelShader: {
  75572. name: string;
  75573. shader: string;
  75574. };
  75575. }
  75576. declare module BABYLON {
  75577. /** @hidden */
  75578. export var pointCloudVertexDeclaration: {
  75579. name: string;
  75580. shader: string;
  75581. };
  75582. }
  75583. // Mixins
  75584. interface Window {
  75585. mozIndexedDB: IDBFactory;
  75586. webkitIndexedDB: IDBFactory;
  75587. msIndexedDB: IDBFactory;
  75588. webkitURL: typeof URL;
  75589. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75590. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75591. WebGLRenderingContext: WebGLRenderingContext;
  75592. MSGesture: MSGesture;
  75593. CANNON: any;
  75594. AudioContext: AudioContext;
  75595. webkitAudioContext: AudioContext;
  75596. PointerEvent: any;
  75597. Math: Math;
  75598. Uint8Array: Uint8ArrayConstructor;
  75599. Float32Array: Float32ArrayConstructor;
  75600. mozURL: typeof URL;
  75601. msURL: typeof URL;
  75602. VRFrameData: any; // WebVR, from specs 1.1
  75603. DracoDecoderModule: any;
  75604. setImmediate(handler: (...args: any[]) => void): number;
  75605. }
  75606. interface HTMLCanvasElement {
  75607. requestPointerLock(): void;
  75608. msRequestPointerLock?(): void;
  75609. mozRequestPointerLock?(): void;
  75610. webkitRequestPointerLock?(): void;
  75611. /** Track wether a record is in progress */
  75612. isRecording: boolean;
  75613. /** Capture Stream method defined by some browsers */
  75614. captureStream(fps?: number): MediaStream;
  75615. }
  75616. interface CanvasRenderingContext2D {
  75617. msImageSmoothingEnabled: boolean;
  75618. }
  75619. interface MouseEvent {
  75620. mozMovementX: number;
  75621. mozMovementY: number;
  75622. webkitMovementX: number;
  75623. webkitMovementY: number;
  75624. msMovementX: number;
  75625. msMovementY: number;
  75626. }
  75627. interface Navigator {
  75628. mozGetVRDevices: (any: any) => any;
  75629. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75630. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75631. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75632. webkitGetGamepads(): Gamepad[];
  75633. msGetGamepads(): Gamepad[];
  75634. webkitGamepads(): Gamepad[];
  75635. }
  75636. interface HTMLVideoElement {
  75637. mozSrcObject: any;
  75638. }
  75639. interface Math {
  75640. fround(x: number): number;
  75641. imul(a: number, b: number): number;
  75642. }
  75643. interface WebGLRenderingContext {
  75644. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75645. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75646. vertexAttribDivisor(index: number, divisor: number): void;
  75647. createVertexArray(): any;
  75648. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75649. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75650. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75651. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75652. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75653. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75654. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75655. // Queries
  75656. createQuery(): WebGLQuery;
  75657. deleteQuery(query: WebGLQuery): void;
  75658. beginQuery(target: number, query: WebGLQuery): void;
  75659. endQuery(target: number): void;
  75660. getQueryParameter(query: WebGLQuery, pname: number): any;
  75661. getQuery(target: number, pname: number): any;
  75662. MAX_SAMPLES: number;
  75663. RGBA8: number;
  75664. READ_FRAMEBUFFER: number;
  75665. DRAW_FRAMEBUFFER: number;
  75666. UNIFORM_BUFFER: number;
  75667. HALF_FLOAT_OES: number;
  75668. RGBA16F: number;
  75669. RGBA32F: number;
  75670. R32F: number;
  75671. RG32F: number;
  75672. RGB32F: number;
  75673. R16F: number;
  75674. RG16F: number;
  75675. RGB16F: number;
  75676. RED: number;
  75677. RG: number;
  75678. R8: number;
  75679. RG8: number;
  75680. UNSIGNED_INT_24_8: number;
  75681. DEPTH24_STENCIL8: number;
  75682. MIN: number;
  75683. MAX: number;
  75684. /* Multiple Render Targets */
  75685. drawBuffers(buffers: number[]): void;
  75686. readBuffer(src: number): void;
  75687. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75688. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75689. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75690. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75691. // Occlusion Query
  75692. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75693. ANY_SAMPLES_PASSED: number;
  75694. QUERY_RESULT_AVAILABLE: number;
  75695. QUERY_RESULT: number;
  75696. }
  75697. interface WebGLProgram {
  75698. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75699. }
  75700. interface EXT_disjoint_timer_query {
  75701. QUERY_COUNTER_BITS_EXT: number;
  75702. TIME_ELAPSED_EXT: number;
  75703. TIMESTAMP_EXT: number;
  75704. GPU_DISJOINT_EXT: number;
  75705. QUERY_RESULT_EXT: number;
  75706. QUERY_RESULT_AVAILABLE_EXT: number;
  75707. queryCounterEXT(query: WebGLQuery, target: number): void;
  75708. createQueryEXT(): WebGLQuery;
  75709. beginQueryEXT(target: number, query: WebGLQuery): void;
  75710. endQueryEXT(target: number): void;
  75711. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75712. deleteQueryEXT(query: WebGLQuery): void;
  75713. }
  75714. interface WebGLUniformLocation {
  75715. _currentState: any;
  75716. }
  75717. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75718. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75719. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75720. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75721. interface WebGLRenderingContext {
  75722. readonly RASTERIZER_DISCARD: number;
  75723. readonly DEPTH_COMPONENT24: number;
  75724. readonly TEXTURE_3D: number;
  75725. readonly TEXTURE_2D_ARRAY: number;
  75726. readonly TEXTURE_COMPARE_FUNC: number;
  75727. readonly TEXTURE_COMPARE_MODE: number;
  75728. readonly COMPARE_REF_TO_TEXTURE: number;
  75729. readonly TEXTURE_WRAP_R: number;
  75730. readonly HALF_FLOAT: number;
  75731. readonly RGB8: number;
  75732. readonly RED_INTEGER: number;
  75733. readonly RG_INTEGER: number;
  75734. readonly RGB_INTEGER: number;
  75735. readonly RGBA_INTEGER: number;
  75736. readonly R8_SNORM: number;
  75737. readonly RG8_SNORM: number;
  75738. readonly RGB8_SNORM: number;
  75739. readonly RGBA8_SNORM: number;
  75740. readonly R8I: number;
  75741. readonly RG8I: number;
  75742. readonly RGB8I: number;
  75743. readonly RGBA8I: number;
  75744. readonly R8UI: number;
  75745. readonly RG8UI: number;
  75746. readonly RGB8UI: number;
  75747. readonly RGBA8UI: number;
  75748. readonly R16I: number;
  75749. readonly RG16I: number;
  75750. readonly RGB16I: number;
  75751. readonly RGBA16I: number;
  75752. readonly R16UI: number;
  75753. readonly RG16UI: number;
  75754. readonly RGB16UI: number;
  75755. readonly RGBA16UI: number;
  75756. readonly R32I: number;
  75757. readonly RG32I: number;
  75758. readonly RGB32I: number;
  75759. readonly RGBA32I: number;
  75760. readonly R32UI: number;
  75761. readonly RG32UI: number;
  75762. readonly RGB32UI: number;
  75763. readonly RGBA32UI: number;
  75764. readonly RGB10_A2UI: number;
  75765. readonly R11F_G11F_B10F: number;
  75766. readonly RGB9_E5: number;
  75767. readonly RGB10_A2: number;
  75768. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75769. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75770. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75771. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75772. readonly DEPTH_COMPONENT32F: number;
  75773. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75774. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75775. 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;
  75776. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75777. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75778. readonly TRANSFORM_FEEDBACK: number;
  75779. readonly INTERLEAVED_ATTRIBS: number;
  75780. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75781. createTransformFeedback(): WebGLTransformFeedback;
  75782. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75783. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75784. beginTransformFeedback(primitiveMode: number): void;
  75785. endTransformFeedback(): void;
  75786. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75787. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75788. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75789. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75790. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75791. }
  75792. interface ImageBitmap {
  75793. readonly width: number;
  75794. readonly height: number;
  75795. close(): void;
  75796. }
  75797. interface WebGLQuery extends WebGLObject {
  75798. }
  75799. declare var WebGLQuery: {
  75800. prototype: WebGLQuery;
  75801. new(): WebGLQuery;
  75802. };
  75803. interface WebGLSampler extends WebGLObject {
  75804. }
  75805. declare var WebGLSampler: {
  75806. prototype: WebGLSampler;
  75807. new(): WebGLSampler;
  75808. };
  75809. interface WebGLSync extends WebGLObject {
  75810. }
  75811. declare var WebGLSync: {
  75812. prototype: WebGLSync;
  75813. new(): WebGLSync;
  75814. };
  75815. interface WebGLTransformFeedback extends WebGLObject {
  75816. }
  75817. declare var WebGLTransformFeedback: {
  75818. prototype: WebGLTransformFeedback;
  75819. new(): WebGLTransformFeedback;
  75820. };
  75821. interface WebGLVertexArrayObject extends WebGLObject {
  75822. }
  75823. declare var WebGLVertexArrayObject: {
  75824. prototype: WebGLVertexArrayObject;
  75825. new(): WebGLVertexArrayObject;
  75826. };
  75827. // Type definitions for WebVR API
  75828. // Project: https://w3c.github.io/webvr/
  75829. // Definitions by: six a <https://github.com/lostfictions>
  75830. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75831. interface VRDisplay extends EventTarget {
  75832. /**
  75833. * Dictionary of capabilities describing the VRDisplay.
  75834. */
  75835. readonly capabilities: VRDisplayCapabilities;
  75836. /**
  75837. * z-depth defining the far plane of the eye view frustum
  75838. * enables mapping of values in the render target depth
  75839. * attachment to scene coordinates. Initially set to 10000.0.
  75840. */
  75841. depthFar: number;
  75842. /**
  75843. * z-depth defining the near plane of the eye view frustum
  75844. * enables mapping of values in the render target depth
  75845. * attachment to scene coordinates. Initially set to 0.01.
  75846. */
  75847. depthNear: number;
  75848. /**
  75849. * An identifier for this distinct VRDisplay. Used as an
  75850. * association point in the Gamepad API.
  75851. */
  75852. readonly displayId: number;
  75853. /**
  75854. * A display name, a user-readable name identifying it.
  75855. */
  75856. readonly displayName: string;
  75857. readonly isConnected: boolean;
  75858. readonly isPresenting: boolean;
  75859. /**
  75860. * If this VRDisplay supports room-scale experiences, the optional
  75861. * stage attribute contains details on the room-scale parameters.
  75862. */
  75863. readonly stageParameters: VRStageParameters | null;
  75864. /**
  75865. * Passing the value returned by `requestAnimationFrame` to
  75866. * `cancelAnimationFrame` will unregister the callback.
  75867. * @param handle Define the hanle of the request to cancel
  75868. */
  75869. cancelAnimationFrame(handle: number): void;
  75870. /**
  75871. * Stops presenting to the VRDisplay.
  75872. * @returns a promise to know when it stopped
  75873. */
  75874. exitPresent(): Promise<void>;
  75875. /**
  75876. * Return the current VREyeParameters for the given eye.
  75877. * @param whichEye Define the eye we want the parameter for
  75878. * @returns the eye parameters
  75879. */
  75880. getEyeParameters(whichEye: string): VREyeParameters;
  75881. /**
  75882. * Populates the passed VRFrameData with the information required to render
  75883. * the current frame.
  75884. * @param frameData Define the data structure to populate
  75885. * @returns true if ok otherwise false
  75886. */
  75887. getFrameData(frameData: VRFrameData): boolean;
  75888. /**
  75889. * Get the layers currently being presented.
  75890. * @returns the list of VR layers
  75891. */
  75892. getLayers(): VRLayer[];
  75893. /**
  75894. * Return a VRPose containing the future predicted pose of the VRDisplay
  75895. * when the current frame will be presented. The value returned will not
  75896. * change until JavaScript has returned control to the browser.
  75897. *
  75898. * The VRPose will contain the position, orientation, velocity,
  75899. * and acceleration of each of these properties.
  75900. * @returns the pose object
  75901. */
  75902. getPose(): VRPose;
  75903. /**
  75904. * Return the current instantaneous pose of the VRDisplay, with no
  75905. * prediction applied.
  75906. * @returns the current instantaneous pose
  75907. */
  75908. getImmediatePose(): VRPose;
  75909. /**
  75910. * The callback passed to `requestAnimationFrame` will be called
  75911. * any time a new frame should be rendered. When the VRDisplay is
  75912. * presenting the callback will be called at the native refresh
  75913. * rate of the HMD. When not presenting this function acts
  75914. * identically to how window.requestAnimationFrame acts. Content should
  75915. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75916. * asynchronously from other displays and at differing refresh rates.
  75917. * @param callback Define the eaction to run next frame
  75918. * @returns the request handle it
  75919. */
  75920. requestAnimationFrame(callback: FrameRequestCallback): number;
  75921. /**
  75922. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75923. * Repeat calls while already presenting will update the VRLayers being displayed.
  75924. * @param layers Define the list of layer to present
  75925. * @returns a promise to know when the request has been fulfilled
  75926. */
  75927. requestPresent(layers: VRLayer[]): Promise<void>;
  75928. /**
  75929. * Reset the pose for this display, treating its current position and
  75930. * orientation as the "origin/zero" values. VRPose.position,
  75931. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75932. * updated when calling resetPose(). This should be called in only
  75933. * sitting-space experiences.
  75934. */
  75935. resetPose(): void;
  75936. /**
  75937. * The VRLayer provided to the VRDisplay will be captured and presented
  75938. * in the HMD. Calling this function has the same effect on the source
  75939. * canvas as any other operation that uses its source image, and canvases
  75940. * created without preserveDrawingBuffer set to true will be cleared.
  75941. * @param pose Define the pose to submit
  75942. */
  75943. submitFrame(pose?: VRPose): void;
  75944. }
  75945. declare var VRDisplay: {
  75946. prototype: VRDisplay;
  75947. new(): VRDisplay;
  75948. };
  75949. interface VRLayer {
  75950. leftBounds?: number[] | Float32Array | null;
  75951. rightBounds?: number[] | Float32Array | null;
  75952. source?: HTMLCanvasElement | null;
  75953. }
  75954. interface VRDisplayCapabilities {
  75955. readonly canPresent: boolean;
  75956. readonly hasExternalDisplay: boolean;
  75957. readonly hasOrientation: boolean;
  75958. readonly hasPosition: boolean;
  75959. readonly maxLayers: number;
  75960. }
  75961. interface VREyeParameters {
  75962. /** @deprecated */
  75963. readonly fieldOfView: VRFieldOfView;
  75964. readonly offset: Float32Array;
  75965. readonly renderHeight: number;
  75966. readonly renderWidth: number;
  75967. }
  75968. interface VRFieldOfView {
  75969. readonly downDegrees: number;
  75970. readonly leftDegrees: number;
  75971. readonly rightDegrees: number;
  75972. readonly upDegrees: number;
  75973. }
  75974. interface VRFrameData {
  75975. readonly leftProjectionMatrix: Float32Array;
  75976. readonly leftViewMatrix: Float32Array;
  75977. readonly pose: VRPose;
  75978. readonly rightProjectionMatrix: Float32Array;
  75979. readonly rightViewMatrix: Float32Array;
  75980. readonly timestamp: number;
  75981. }
  75982. interface VRPose {
  75983. readonly angularAcceleration: Float32Array | null;
  75984. readonly angularVelocity: Float32Array | null;
  75985. readonly linearAcceleration: Float32Array | null;
  75986. readonly linearVelocity: Float32Array | null;
  75987. readonly orientation: Float32Array | null;
  75988. readonly position: Float32Array | null;
  75989. readonly timestamp: number;
  75990. }
  75991. interface VRStageParameters {
  75992. sittingToStandingTransform?: Float32Array;
  75993. sizeX?: number;
  75994. sizeY?: number;
  75995. }
  75996. interface Navigator {
  75997. getVRDisplays(): Promise<VRDisplay[]>;
  75998. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75999. }
  76000. interface Window {
  76001. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76002. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76003. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76004. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76005. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76006. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76007. }
  76008. interface Gamepad {
  76009. readonly displayId: number;
  76010. }
  76011. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76012. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76013. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76014. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76015. type XRHandedness = "none" | "left" | "right";
  76016. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76017. type XREye = "none" | "left" | "right";
  76018. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76019. interface XRSpace extends EventTarget {}
  76020. interface XRRenderState {
  76021. depthNear?: number;
  76022. depthFar?: number;
  76023. inlineVerticalFieldOfView?: number;
  76024. baseLayer?: XRWebGLLayer;
  76025. }
  76026. interface XRInputSource {
  76027. handedness: XRHandedness;
  76028. targetRayMode: XRTargetRayMode;
  76029. targetRaySpace: XRSpace;
  76030. gripSpace: XRSpace | undefined;
  76031. gamepad: Gamepad | undefined;
  76032. profiles: Array<string>;
  76033. hand: XRHand | undefined;
  76034. }
  76035. interface XRSessionInit {
  76036. optionalFeatures?: string[];
  76037. requiredFeatures?: string[];
  76038. }
  76039. interface XRSession {
  76040. addEventListener: Function;
  76041. removeEventListener: Function;
  76042. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76043. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76044. requestAnimationFrame: Function;
  76045. end(): Promise<void>;
  76046. renderState: XRRenderState;
  76047. inputSources: Array<XRInputSource>;
  76048. // hit test
  76049. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76050. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76051. // legacy AR hit test
  76052. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76053. // legacy plane detection
  76054. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76055. }
  76056. interface XRReferenceSpace extends XRSpace {
  76057. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76058. onreset: any;
  76059. }
  76060. type XRPlaneSet = Set<XRPlane>;
  76061. type XRAnchorSet = Set<XRAnchor>;
  76062. interface XRFrame {
  76063. session: XRSession;
  76064. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76065. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76066. // AR
  76067. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76068. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76069. // Anchors
  76070. trackedAnchors?: XRAnchorSet;
  76071. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76072. // Planes
  76073. worldInformation: {
  76074. detectedPlanes?: XRPlaneSet;
  76075. };
  76076. // Hand tracking
  76077. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76078. }
  76079. interface XRViewerPose extends XRPose {
  76080. views: Array<XRView>;
  76081. }
  76082. interface XRPose {
  76083. transform: XRRigidTransform;
  76084. emulatedPosition: boolean;
  76085. }
  76086. interface XRWebGLLayerOptions {
  76087. antialias?: boolean;
  76088. depth?: boolean;
  76089. stencil?: boolean;
  76090. alpha?: boolean;
  76091. multiview?: boolean;
  76092. framebufferScaleFactor?: number;
  76093. }
  76094. declare var XRWebGLLayer: {
  76095. prototype: XRWebGLLayer;
  76096. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76097. };
  76098. interface XRWebGLLayer {
  76099. framebuffer: WebGLFramebuffer;
  76100. framebufferWidth: number;
  76101. framebufferHeight: number;
  76102. getViewport: Function;
  76103. }
  76104. declare class XRRigidTransform {
  76105. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76106. position: DOMPointReadOnly;
  76107. orientation: DOMPointReadOnly;
  76108. matrix: Float32Array;
  76109. inverse: XRRigidTransform;
  76110. }
  76111. interface XRView {
  76112. eye: XREye;
  76113. projectionMatrix: Float32Array;
  76114. transform: XRRigidTransform;
  76115. }
  76116. interface XRInputSourceChangeEvent {
  76117. session: XRSession;
  76118. removed: Array<XRInputSource>;
  76119. added: Array<XRInputSource>;
  76120. }
  76121. interface XRInputSourceEvent extends Event {
  76122. readonly frame: XRFrame;
  76123. readonly inputSource: XRInputSource;
  76124. }
  76125. // Experimental(er) features
  76126. declare class XRRay {
  76127. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76128. origin: DOMPointReadOnly;
  76129. direction: DOMPointReadOnly;
  76130. matrix: Float32Array;
  76131. }
  76132. declare enum XRHitTestTrackableType {
  76133. "point",
  76134. "plane",
  76135. "mesh",
  76136. }
  76137. interface XRHitResult {
  76138. hitMatrix: Float32Array;
  76139. }
  76140. interface XRTransientInputHitTestResult {
  76141. readonly inputSource: XRInputSource;
  76142. readonly results: Array<XRHitTestResult>;
  76143. }
  76144. interface XRHitTestResult {
  76145. getPose(baseSpace: XRSpace): XRPose | undefined;
  76146. // When anchor system is enabled
  76147. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76148. }
  76149. interface XRHitTestSource {
  76150. cancel(): void;
  76151. }
  76152. interface XRTransientInputHitTestSource {
  76153. cancel(): void;
  76154. }
  76155. interface XRHitTestOptionsInit {
  76156. space: XRSpace;
  76157. entityTypes?: Array<XRHitTestTrackableType>;
  76158. offsetRay?: XRRay;
  76159. }
  76160. interface XRTransientInputHitTestOptionsInit {
  76161. profile: string;
  76162. entityTypes?: Array<XRHitTestTrackableType>;
  76163. offsetRay?: XRRay;
  76164. }
  76165. interface XRAnchor {
  76166. anchorSpace: XRSpace;
  76167. delete(): void;
  76168. }
  76169. interface XRPlane {
  76170. orientation: "Horizontal" | "Vertical";
  76171. planeSpace: XRSpace;
  76172. polygon: Array<DOMPointReadOnly>;
  76173. lastChangedTime: number;
  76174. }
  76175. interface XRJointSpace extends XRSpace {}
  76176. interface XRJointPose extends XRPose {
  76177. radius: number | undefined;
  76178. }
  76179. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76180. readonly length: number;
  76181. [index: number]: XRJointSpace;
  76182. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76183. readonly WRIST: number;
  76184. readonly THUMB_METACARPAL: number;
  76185. readonly THUMB_PHALANX_PROXIMAL: number;
  76186. readonly THUMB_PHALANX_DISTAL: number;
  76187. readonly THUMB_PHALANX_TIP: number;
  76188. readonly INDEX_METACARPAL: number;
  76189. readonly INDEX_PHALANX_PROXIMAL: number;
  76190. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76191. readonly INDEX_PHALANX_DISTAL: number;
  76192. readonly INDEX_PHALANX_TIP: number;
  76193. readonly MIDDLE_METACARPAL: number;
  76194. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76195. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76196. readonly MIDDLE_PHALANX_DISTAL: number;
  76197. readonly MIDDLE_PHALANX_TIP: number;
  76198. readonly RING_METACARPAL: number;
  76199. readonly RING_PHALANX_PROXIMAL: number;
  76200. readonly RING_PHALANX_INTERMEDIATE: number;
  76201. readonly RING_PHALANX_DISTAL: number;
  76202. readonly RING_PHALANX_TIP: number;
  76203. readonly LITTLE_METACARPAL: number;
  76204. readonly LITTLE_PHALANX_PROXIMAL: number;
  76205. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76206. readonly LITTLE_PHALANX_DISTAL: number;
  76207. readonly LITTLE_PHALANX_TIP: number;
  76208. }
  76209. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76210. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76211. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76212. interface XRSession {
  76213. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76214. }
  76215. interface XRFrame {
  76216. featurePointCloud? : Array<number>;
  76217. }
  76218. /**
  76219. * @ignore
  76220. */
  76221. declare module BABYLON.GLTF2.Exporter {
  76222. }
  76223. /**
  76224. * @ignore
  76225. */
  76226. declare module BABYLON.GLTF1 {
  76227. }
  76228. declare module BABYLON.GUI {
  76229. /**
  76230. * Class used to specific a value and its associated unit
  76231. */
  76232. export class ValueAndUnit {
  76233. /** defines the unit to store */
  76234. unit: number;
  76235. /** defines a boolean indicating if the value can be negative */
  76236. negativeValueAllowed: boolean;
  76237. private _value;
  76238. private _originalUnit;
  76239. /**
  76240. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76241. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76242. */
  76243. ignoreAdaptiveScaling: boolean;
  76244. /**
  76245. * Creates a new ValueAndUnit
  76246. * @param value defines the value to store
  76247. * @param unit defines the unit to store
  76248. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76249. */
  76250. constructor(value: number,
  76251. /** defines the unit to store */
  76252. unit?: number,
  76253. /** defines a boolean indicating if the value can be negative */
  76254. negativeValueAllowed?: boolean);
  76255. /** Gets a boolean indicating if the value is a percentage */
  76256. get isPercentage(): boolean;
  76257. /** Gets a boolean indicating if the value is store as pixel */
  76258. get isPixel(): boolean;
  76259. /** Gets direct internal value */
  76260. get internalValue(): number;
  76261. /**
  76262. * Gets value as pixel
  76263. * @param host defines the root host
  76264. * @param refValue defines the reference value for percentages
  76265. * @returns the value as pixel
  76266. */
  76267. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76268. /**
  76269. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76270. * @param value defines the value to store
  76271. * @param unit defines the unit to store
  76272. * @returns the current ValueAndUnit
  76273. */
  76274. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76275. /**
  76276. * Gets the value accordingly to its unit
  76277. * @param host defines the root host
  76278. * @returns the value
  76279. */
  76280. getValue(host: AdvancedDynamicTexture): number;
  76281. /**
  76282. * Gets a string representation of the value
  76283. * @param host defines the root host
  76284. * @param decimals defines an optional number of decimals to display
  76285. * @returns a string
  76286. */
  76287. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76288. /**
  76289. * Store a value parsed from a string
  76290. * @param source defines the source string
  76291. * @returns true if the value was successfully parsed
  76292. */
  76293. fromString(source: string | number): boolean;
  76294. private static _Regex;
  76295. private static _UNITMODE_PERCENTAGE;
  76296. private static _UNITMODE_PIXEL;
  76297. /** UNITMODE_PERCENTAGE */
  76298. static get UNITMODE_PERCENTAGE(): number;
  76299. /** UNITMODE_PIXEL */
  76300. static get UNITMODE_PIXEL(): number;
  76301. }
  76302. }
  76303. declare module BABYLON.GUI {
  76304. /**
  76305. * Define a style used by control to automatically setup properties based on a template.
  76306. * Only support font related properties so far
  76307. */
  76308. export class Style implements BABYLON.IDisposable {
  76309. private _fontFamily;
  76310. private _fontStyle;
  76311. private _fontWeight;
  76312. /** @hidden */
  76313. _host: AdvancedDynamicTexture;
  76314. /** @hidden */
  76315. _fontSize: ValueAndUnit;
  76316. /**
  76317. * BABYLON.Observable raised when the style values are changed
  76318. */
  76319. onChangedObservable: BABYLON.Observable<Style>;
  76320. /**
  76321. * Creates a new style object
  76322. * @param host defines the AdvancedDynamicTexture which hosts this style
  76323. */
  76324. constructor(host: AdvancedDynamicTexture);
  76325. /**
  76326. * Gets or sets the font size
  76327. */
  76328. get fontSize(): string | number;
  76329. set fontSize(value: string | number);
  76330. /**
  76331. * Gets or sets the font family
  76332. */
  76333. get fontFamily(): string;
  76334. set fontFamily(value: string);
  76335. /**
  76336. * Gets or sets the font style
  76337. */
  76338. get fontStyle(): string;
  76339. set fontStyle(value: string);
  76340. /** Gets or sets font weight */
  76341. get fontWeight(): string;
  76342. set fontWeight(value: string);
  76343. /** Dispose all associated resources */
  76344. dispose(): void;
  76345. }
  76346. }
  76347. declare module BABYLON.GUI {
  76348. /**
  76349. * Class used to transport BABYLON.Vector2 information for pointer events
  76350. */
  76351. export class Vector2WithInfo extends BABYLON.Vector2 {
  76352. /** defines the current mouse button index */
  76353. buttonIndex: number;
  76354. /**
  76355. * Creates a new Vector2WithInfo
  76356. * @param source defines the vector2 data to transport
  76357. * @param buttonIndex defines the current mouse button index
  76358. */
  76359. constructor(source: BABYLON.Vector2,
  76360. /** defines the current mouse button index */
  76361. buttonIndex?: number);
  76362. }
  76363. /** Class used to provide 2D matrix features */
  76364. export class Matrix2D {
  76365. /** Gets the internal array of 6 floats used to store matrix data */
  76366. m: Float32Array;
  76367. /**
  76368. * Creates a new matrix
  76369. * @param m00 defines value for (0, 0)
  76370. * @param m01 defines value for (0, 1)
  76371. * @param m10 defines value for (1, 0)
  76372. * @param m11 defines value for (1, 1)
  76373. * @param m20 defines value for (2, 0)
  76374. * @param m21 defines value for (2, 1)
  76375. */
  76376. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76377. /**
  76378. * Fills the matrix from direct values
  76379. * @param m00 defines value for (0, 0)
  76380. * @param m01 defines value for (0, 1)
  76381. * @param m10 defines value for (1, 0)
  76382. * @param m11 defines value for (1, 1)
  76383. * @param m20 defines value for (2, 0)
  76384. * @param m21 defines value for (2, 1)
  76385. * @returns the current modified matrix
  76386. */
  76387. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76388. /**
  76389. * Gets matrix determinant
  76390. * @returns the determinant
  76391. */
  76392. determinant(): number;
  76393. /**
  76394. * Inverses the matrix and stores it in a target matrix
  76395. * @param result defines the target matrix
  76396. * @returns the current matrix
  76397. */
  76398. invertToRef(result: Matrix2D): Matrix2D;
  76399. /**
  76400. * Multiplies the current matrix with another one
  76401. * @param other defines the second operand
  76402. * @param result defines the target matrix
  76403. * @returns the current matrix
  76404. */
  76405. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76406. /**
  76407. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76408. * @param x defines the x coordinate to transform
  76409. * @param y defines the x coordinate to transform
  76410. * @param result defines the target vector2
  76411. * @returns the current matrix
  76412. */
  76413. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76414. /**
  76415. * Creates an identity matrix
  76416. * @returns a new matrix
  76417. */
  76418. static Identity(): Matrix2D;
  76419. /**
  76420. * Creates a translation matrix and stores it in a target matrix
  76421. * @param x defines the x coordinate of the translation
  76422. * @param y defines the y coordinate of the translation
  76423. * @param result defines the target matrix
  76424. */
  76425. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76426. /**
  76427. * Creates a scaling matrix and stores it in a target matrix
  76428. * @param x defines the x coordinate of the scaling
  76429. * @param y defines the y coordinate of the scaling
  76430. * @param result defines the target matrix
  76431. */
  76432. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76433. /**
  76434. * Creates a rotation matrix and stores it in a target matrix
  76435. * @param angle defines the rotation angle
  76436. * @param result defines the target matrix
  76437. */
  76438. static RotationToRef(angle: number, result: Matrix2D): void;
  76439. private static _TempPreTranslationMatrix;
  76440. private static _TempPostTranslationMatrix;
  76441. private static _TempRotationMatrix;
  76442. private static _TempScalingMatrix;
  76443. private static _TempCompose0;
  76444. private static _TempCompose1;
  76445. private static _TempCompose2;
  76446. /**
  76447. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76448. * @param tx defines the x coordinate of the translation
  76449. * @param ty defines the y coordinate of the translation
  76450. * @param angle defines the rotation angle
  76451. * @param scaleX defines the x coordinate of the scaling
  76452. * @param scaleY defines the y coordinate of the scaling
  76453. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76454. * @param result defines the target matrix
  76455. */
  76456. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76457. }
  76458. }
  76459. declare module BABYLON.GUI {
  76460. /**
  76461. * Class used to store 2D control sizes
  76462. */
  76463. export class Measure {
  76464. /** defines left coordinate */
  76465. left: number;
  76466. /** defines top coordinate */
  76467. top: number;
  76468. /** defines width dimension */
  76469. width: number;
  76470. /** defines height dimension */
  76471. height: number;
  76472. /**
  76473. * Creates a new measure
  76474. * @param left defines left coordinate
  76475. * @param top defines top coordinate
  76476. * @param width defines width dimension
  76477. * @param height defines height dimension
  76478. */
  76479. constructor(
  76480. /** defines left coordinate */
  76481. left: number,
  76482. /** defines top coordinate */
  76483. top: number,
  76484. /** defines width dimension */
  76485. width: number,
  76486. /** defines height dimension */
  76487. height: number);
  76488. /**
  76489. * Copy from another measure
  76490. * @param other defines the other measure to copy from
  76491. */
  76492. copyFrom(other: Measure): void;
  76493. /**
  76494. * Copy from a group of 4 floats
  76495. * @param left defines left coordinate
  76496. * @param top defines top coordinate
  76497. * @param width defines width dimension
  76498. * @param height defines height dimension
  76499. */
  76500. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76501. /**
  76502. * Computes the axis aligned bounding box measure for two given measures
  76503. * @param a Input measure
  76504. * @param b Input measure
  76505. * @param result the resulting bounding measure
  76506. */
  76507. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76508. /**
  76509. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76510. * @param transform the matrix to transform the measure before computing the AABB
  76511. * @param addX number to add to left
  76512. * @param addY number to add to top
  76513. * @param addWidth number to add to width
  76514. * @param addHeight number to add to height
  76515. * @param result the resulting AABB
  76516. */
  76517. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76518. /**
  76519. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76520. * @param transform the matrix to transform the measure before computing the AABB
  76521. * @param result the resulting AABB
  76522. */
  76523. transformToRef(transform: Matrix2D, result: Measure): void;
  76524. /**
  76525. * Check equality between this measure and another one
  76526. * @param other defines the other measures
  76527. * @returns true if both measures are equals
  76528. */
  76529. isEqualsTo(other: Measure): boolean;
  76530. /**
  76531. * Creates an empty measure
  76532. * @returns a new measure
  76533. */
  76534. static Empty(): Measure;
  76535. }
  76536. }
  76537. declare module BABYLON.GUI {
  76538. /**
  76539. * Interface used to define a control that can receive focus
  76540. */
  76541. export interface IFocusableControl {
  76542. /**
  76543. * Function called when the control receives the focus
  76544. */
  76545. onFocus(): void;
  76546. /**
  76547. * Function called when the control loses the focus
  76548. */
  76549. onBlur(): void;
  76550. /**
  76551. * Function called to let the control handle keyboard events
  76552. * @param evt defines the current keyboard event
  76553. */
  76554. processKeyboard(evt: KeyboardEvent): void;
  76555. /**
  76556. * Function called to get the list of controls that should not steal the focus from this control
  76557. * @returns an array of controls
  76558. */
  76559. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76560. }
  76561. /**
  76562. * Class used to create texture to support 2D GUI elements
  76563. * @see https://doc.babylonjs.com/how_to/gui
  76564. */
  76565. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76566. private _isDirty;
  76567. private _renderObserver;
  76568. private _resizeObserver;
  76569. private _preKeyboardObserver;
  76570. private _pointerMoveObserver;
  76571. private _pointerObserver;
  76572. private _canvasPointerOutObserver;
  76573. private _canvasBlurObserver;
  76574. private _background;
  76575. /** @hidden */
  76576. _rootContainer: Container;
  76577. /** @hidden */
  76578. _lastPickedControl: Control;
  76579. /** @hidden */
  76580. _lastControlOver: {
  76581. [pointerId: number]: Control;
  76582. };
  76583. /** @hidden */
  76584. _lastControlDown: {
  76585. [pointerId: number]: Control;
  76586. };
  76587. /** @hidden */
  76588. _capturingControl: {
  76589. [pointerId: number]: Control;
  76590. };
  76591. /** @hidden */
  76592. _shouldBlockPointer: boolean;
  76593. /** @hidden */
  76594. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76595. /** @hidden */
  76596. _linkedControls: Control[];
  76597. private _isFullscreen;
  76598. private _fullscreenViewport;
  76599. private _idealWidth;
  76600. private _idealHeight;
  76601. private _useSmallestIdeal;
  76602. private _renderAtIdealSize;
  76603. private _focusedControl;
  76604. private _blockNextFocusCheck;
  76605. private _renderScale;
  76606. private _rootElement;
  76607. private _cursorChanged;
  76608. private _defaultMousePointerId;
  76609. /** @hidden */
  76610. _numLayoutCalls: number;
  76611. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76612. get numLayoutCalls(): number;
  76613. /** @hidden */
  76614. _numRenderCalls: number;
  76615. /** Gets the number of render calls made the last time the ADT has been rendered */
  76616. get numRenderCalls(): number;
  76617. /**
  76618. * Define type to string to ensure compatibility across browsers
  76619. * Safari doesn't support DataTransfer constructor
  76620. */
  76621. private _clipboardData;
  76622. /**
  76623. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76624. */
  76625. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76626. /**
  76627. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76628. */
  76629. onControlPickedObservable: BABYLON.Observable<Control>;
  76630. /**
  76631. * BABYLON.Observable event triggered before layout is evaluated
  76632. */
  76633. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76634. /**
  76635. * BABYLON.Observable event triggered after the layout was evaluated
  76636. */
  76637. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76638. /**
  76639. * BABYLON.Observable event triggered before the texture is rendered
  76640. */
  76641. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76642. /**
  76643. * BABYLON.Observable event triggered after the texture was rendered
  76644. */
  76645. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76646. /**
  76647. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76648. */
  76649. premulAlpha: boolean;
  76650. /**
  76651. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76652. * Useful when you want more antialiasing
  76653. */
  76654. get renderScale(): number;
  76655. set renderScale(value: number);
  76656. /** Gets or sets the background color */
  76657. get background(): string;
  76658. set background(value: string);
  76659. /**
  76660. * Gets or sets the ideal width used to design controls.
  76661. * The GUI will then rescale everything accordingly
  76662. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76663. */
  76664. get idealWidth(): number;
  76665. set idealWidth(value: number);
  76666. /**
  76667. * Gets or sets the ideal height used to design controls.
  76668. * The GUI will then rescale everything accordingly
  76669. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76670. */
  76671. get idealHeight(): number;
  76672. set idealHeight(value: number);
  76673. /**
  76674. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76675. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76676. */
  76677. get useSmallestIdeal(): boolean;
  76678. set useSmallestIdeal(value: boolean);
  76679. /**
  76680. * Gets or sets a boolean indicating if adaptive scaling must be used
  76681. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76682. */
  76683. get renderAtIdealSize(): boolean;
  76684. set renderAtIdealSize(value: boolean);
  76685. /**
  76686. * Gets the ratio used when in "ideal mode"
  76687. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76688. * */
  76689. get idealRatio(): number;
  76690. /**
  76691. * Gets the underlying layer used to render the texture when in fullscreen mode
  76692. */
  76693. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76694. /**
  76695. * Gets the root container control
  76696. */
  76697. get rootContainer(): Container;
  76698. /**
  76699. * Returns an array containing the root container.
  76700. * This is mostly used to let the Inspector introspects the ADT
  76701. * @returns an array containing the rootContainer
  76702. */
  76703. getChildren(): Array<Container>;
  76704. /**
  76705. * Will return all controls that are inside this texture
  76706. * @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
  76707. * @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
  76708. * @return all child controls
  76709. */
  76710. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76711. /**
  76712. * Gets or sets the current focused control
  76713. */
  76714. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76715. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76716. /**
  76717. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76718. */
  76719. get isForeground(): boolean;
  76720. set isForeground(value: boolean);
  76721. /**
  76722. * Gets or set information about clipboardData
  76723. */
  76724. get clipboardData(): string;
  76725. set clipboardData(value: string);
  76726. /**
  76727. * Creates a new AdvancedDynamicTexture
  76728. * @param name defines the name of the texture
  76729. * @param width defines the width of the texture
  76730. * @param height defines the height of the texture
  76731. * @param scene defines the hosting scene
  76732. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76733. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76734. */
  76735. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76736. /**
  76737. * Get the current class name of the texture useful for serialization or dynamic coding.
  76738. * @returns "AdvancedDynamicTexture"
  76739. */
  76740. getClassName(): string;
  76741. /**
  76742. * Function used to execute a function on all controls
  76743. * @param func defines the function to execute
  76744. * @param container defines the container where controls belong. If null the root container will be used
  76745. */
  76746. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76747. private _useInvalidateRectOptimization;
  76748. /**
  76749. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76750. */
  76751. get useInvalidateRectOptimization(): boolean;
  76752. set useInvalidateRectOptimization(value: boolean);
  76753. private _invalidatedRectangle;
  76754. /**
  76755. * Invalidates a rectangle area on the gui texture
  76756. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76757. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76758. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76759. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76760. */
  76761. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76762. /**
  76763. * Marks the texture as dirty forcing a complete update
  76764. */
  76765. markAsDirty(): void;
  76766. /**
  76767. * Helper function used to create a new style
  76768. * @returns a new style
  76769. * @see https://doc.babylonjs.com/how_to/gui#styles
  76770. */
  76771. createStyle(): Style;
  76772. /**
  76773. * Adds a new control to the root container
  76774. * @param control defines the control to add
  76775. * @returns the current texture
  76776. */
  76777. addControl(control: Control): AdvancedDynamicTexture;
  76778. /**
  76779. * Removes a control from the root container
  76780. * @param control defines the control to remove
  76781. * @returns the current texture
  76782. */
  76783. removeControl(control: Control): AdvancedDynamicTexture;
  76784. /**
  76785. * Release all resources
  76786. */
  76787. dispose(): void;
  76788. private _onResize;
  76789. /** @hidden */
  76790. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76791. /**
  76792. * Get screen coordinates for a vector3
  76793. * @param position defines the position to project
  76794. * @param worldMatrix defines the world matrix to use
  76795. * @returns the projected position
  76796. */
  76797. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76798. private _checkUpdate;
  76799. private _clearMeasure;
  76800. private _render;
  76801. /** @hidden */
  76802. _changeCursor(cursor: string): void;
  76803. /** @hidden */
  76804. _registerLastControlDown(control: Control, pointerId: number): void;
  76805. private _doPicking;
  76806. /** @hidden */
  76807. _cleanControlAfterRemovalFromList(list: {
  76808. [pointerId: number]: Control;
  76809. }, control: Control): void;
  76810. /** @hidden */
  76811. _cleanControlAfterRemoval(control: Control): void;
  76812. /** Attach to all scene events required to support pointer events */
  76813. attach(): void;
  76814. /** @hidden */
  76815. private onClipboardCopy;
  76816. /** @hidden */
  76817. private onClipboardCut;
  76818. /** @hidden */
  76819. private onClipboardPaste;
  76820. /**
  76821. * Register the clipboard Events onto the canvas
  76822. */
  76823. registerClipboardEvents(): void;
  76824. /**
  76825. * Unregister the clipboard Events from the canvas
  76826. */
  76827. unRegisterClipboardEvents(): void;
  76828. /**
  76829. * Connect the texture to a hosting mesh to enable interactions
  76830. * @param mesh defines the mesh to attach to
  76831. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76832. */
  76833. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76834. /**
  76835. * Move the focus to a specific control
  76836. * @param control defines the control which will receive the focus
  76837. */
  76838. moveFocusToControl(control: IFocusableControl): void;
  76839. private _manageFocus;
  76840. private _attachToOnPointerOut;
  76841. private _attachToOnBlur;
  76842. /**
  76843. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76844. * @param mesh defines the mesh which will receive the texture
  76845. * @param width defines the texture width (1024 by default)
  76846. * @param height defines the texture height (1024 by default)
  76847. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76848. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76849. * @returns a new AdvancedDynamicTexture
  76850. */
  76851. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76852. /**
  76853. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76854. * In this mode the texture will rely on a layer for its rendering.
  76855. * This allows it to be treated like any other layer.
  76856. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76857. * LayerMask is set through advancedTexture.layer.layerMask
  76858. * @param name defines name for the texture
  76859. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76860. * @param scene defines the hsoting scene
  76861. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76862. * @returns a new AdvancedDynamicTexture
  76863. */
  76864. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76865. }
  76866. }
  76867. declare module BABYLON.GUI {
  76868. /**
  76869. * Root class used for all 2D controls
  76870. * @see https://doc.babylonjs.com/how_to/gui#controls
  76871. */
  76872. export class Control {
  76873. /** defines the name of the control */
  76874. name?: string | undefined;
  76875. /**
  76876. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76877. */
  76878. static AllowAlphaInheritance: boolean;
  76879. private _alpha;
  76880. private _alphaSet;
  76881. private _zIndex;
  76882. /** @hidden */
  76883. _host: AdvancedDynamicTexture;
  76884. /** Gets or sets the control parent */
  76885. parent: BABYLON.Nullable<Container>;
  76886. /** @hidden */
  76887. _currentMeasure: Measure;
  76888. private _fontFamily;
  76889. private _fontStyle;
  76890. private _fontWeight;
  76891. private _fontSize;
  76892. private _font;
  76893. /** @hidden */
  76894. _width: ValueAndUnit;
  76895. /** @hidden */
  76896. _height: ValueAndUnit;
  76897. /** @hidden */
  76898. protected _fontOffset: {
  76899. ascent: number;
  76900. height: number;
  76901. descent: number;
  76902. };
  76903. private _color;
  76904. private _style;
  76905. private _styleObserver;
  76906. /** @hidden */
  76907. protected _horizontalAlignment: number;
  76908. /** @hidden */
  76909. protected _verticalAlignment: number;
  76910. /** @hidden */
  76911. protected _isDirty: boolean;
  76912. /** @hidden */
  76913. protected _wasDirty: boolean;
  76914. /** @hidden */
  76915. _tempParentMeasure: Measure;
  76916. /** @hidden */
  76917. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76918. /** @hidden */
  76919. protected _cachedParentMeasure: Measure;
  76920. private _paddingLeft;
  76921. private _paddingRight;
  76922. private _paddingTop;
  76923. private _paddingBottom;
  76924. /** @hidden */
  76925. _left: ValueAndUnit;
  76926. /** @hidden */
  76927. _top: ValueAndUnit;
  76928. private _scaleX;
  76929. private _scaleY;
  76930. private _rotation;
  76931. private _transformCenterX;
  76932. private _transformCenterY;
  76933. /** @hidden */
  76934. _transformMatrix: Matrix2D;
  76935. /** @hidden */
  76936. protected _invertTransformMatrix: Matrix2D;
  76937. /** @hidden */
  76938. protected _transformedPosition: BABYLON.Vector2;
  76939. private _isMatrixDirty;
  76940. private _cachedOffsetX;
  76941. private _cachedOffsetY;
  76942. private _isVisible;
  76943. private _isHighlighted;
  76944. /** @hidden */
  76945. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76946. private _fontSet;
  76947. private _dummyVector2;
  76948. private _downCount;
  76949. private _enterCount;
  76950. private _doNotRender;
  76951. private _downPointerIds;
  76952. protected _isEnabled: boolean;
  76953. protected _disabledColor: string;
  76954. protected _disabledColorItem: string;
  76955. /** @hidden */
  76956. protected _rebuildLayout: boolean;
  76957. /** @hidden */
  76958. _customData: any;
  76959. /** @hidden */
  76960. _isClipped: boolean;
  76961. /** @hidden */
  76962. _automaticSize: boolean;
  76963. /** @hidden */
  76964. _tag: any;
  76965. /**
  76966. * 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
  76967. */
  76968. uniqueId: number;
  76969. /**
  76970. * Gets or sets an object used to store user defined information for the node
  76971. */
  76972. metadata: any;
  76973. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76974. isHitTestVisible: boolean;
  76975. /** Gets or sets a boolean indicating if the control can block pointer events */
  76976. isPointerBlocker: boolean;
  76977. /** Gets or sets a boolean indicating if the control can be focusable */
  76978. isFocusInvisible: boolean;
  76979. /**
  76980. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76981. * 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
  76982. */
  76983. clipChildren: boolean;
  76984. /**
  76985. * Gets or sets a boolean indicating that control content must be clipped
  76986. * 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
  76987. */
  76988. clipContent: boolean;
  76989. /**
  76990. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76991. */
  76992. useBitmapCache: boolean;
  76993. private _cacheData;
  76994. private _shadowOffsetX;
  76995. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76996. get shadowOffsetX(): number;
  76997. set shadowOffsetX(value: number);
  76998. private _shadowOffsetY;
  76999. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77000. get shadowOffsetY(): number;
  77001. set shadowOffsetY(value: number);
  77002. private _shadowBlur;
  77003. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77004. get shadowBlur(): number;
  77005. set shadowBlur(value: number);
  77006. private _shadowColor;
  77007. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77008. get shadowColor(): string;
  77009. set shadowColor(value: string);
  77010. /** Gets or sets the cursor to use when the control is hovered */
  77011. hoverCursor: string;
  77012. /** @hidden */
  77013. protected _linkOffsetX: ValueAndUnit;
  77014. /** @hidden */
  77015. protected _linkOffsetY: ValueAndUnit;
  77016. /** Gets the control type name */
  77017. get typeName(): string;
  77018. /**
  77019. * Get the current class name of the control.
  77020. * @returns current class name
  77021. */
  77022. getClassName(): string;
  77023. /**
  77024. * An event triggered when pointer wheel is scrolled
  77025. */
  77026. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77027. /**
  77028. * An event triggered when the pointer move over the control.
  77029. */
  77030. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77031. /**
  77032. * An event triggered when the pointer move out of the control.
  77033. */
  77034. onPointerOutObservable: BABYLON.Observable<Control>;
  77035. /**
  77036. * An event triggered when the pointer taps the control
  77037. */
  77038. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77039. /**
  77040. * An event triggered when pointer up
  77041. */
  77042. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77043. /**
  77044. * An event triggered when a control is clicked on
  77045. */
  77046. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77047. /**
  77048. * An event triggered when pointer enters the control
  77049. */
  77050. onPointerEnterObservable: BABYLON.Observable<Control>;
  77051. /**
  77052. * An event triggered when the control is marked as dirty
  77053. */
  77054. onDirtyObservable: BABYLON.Observable<Control>;
  77055. /**
  77056. * An event triggered before drawing the control
  77057. */
  77058. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77059. /**
  77060. * An event triggered after the control was drawn
  77061. */
  77062. onAfterDrawObservable: BABYLON.Observable<Control>;
  77063. /**
  77064. * An event triggered when the control has been disposed
  77065. */
  77066. onDisposeObservable: BABYLON.Observable<Control>;
  77067. /**
  77068. * Get the hosting AdvancedDynamicTexture
  77069. */
  77070. get host(): AdvancedDynamicTexture;
  77071. /** Gets or set information about font offsets (used to render and align text) */
  77072. get fontOffset(): {
  77073. ascent: number;
  77074. height: number;
  77075. descent: number;
  77076. };
  77077. set fontOffset(offset: {
  77078. ascent: number;
  77079. height: number;
  77080. descent: number;
  77081. });
  77082. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77083. get alpha(): number;
  77084. set alpha(value: number);
  77085. /**
  77086. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77087. */
  77088. get isHighlighted(): boolean;
  77089. set isHighlighted(value: boolean);
  77090. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77091. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77092. */
  77093. get scaleX(): number;
  77094. set scaleX(value: number);
  77095. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77096. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77097. */
  77098. get scaleY(): number;
  77099. set scaleY(value: number);
  77100. /** Gets or sets the rotation angle (0 by default)
  77101. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77102. */
  77103. get rotation(): number;
  77104. set rotation(value: number);
  77105. /** Gets or sets the transformation center on Y axis (0 by default)
  77106. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77107. */
  77108. get transformCenterY(): number;
  77109. set transformCenterY(value: number);
  77110. /** Gets or sets the transformation center on X axis (0 by default)
  77111. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77112. */
  77113. get transformCenterX(): number;
  77114. set transformCenterX(value: number);
  77115. /**
  77116. * Gets or sets the horizontal alignment
  77117. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77118. */
  77119. get horizontalAlignment(): number;
  77120. set horizontalAlignment(value: number);
  77121. /**
  77122. * Gets or sets the vertical alignment
  77123. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77124. */
  77125. get verticalAlignment(): number;
  77126. set verticalAlignment(value: number);
  77127. /**
  77128. * Gets or sets a fixed ratio for this control.
  77129. * When different from 0, the ratio is used to compute the "second" dimension.
  77130. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77131. * second dimension is computed as first dimension * fixedRatio
  77132. */
  77133. fixedRatio: number;
  77134. private _fixedRatioMasterIsWidth;
  77135. /**
  77136. * Gets or sets control width
  77137. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77138. */
  77139. get width(): string | number;
  77140. set width(value: string | number);
  77141. /**
  77142. * Gets or sets the control width in pixel
  77143. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77144. */
  77145. get widthInPixels(): number;
  77146. set widthInPixels(value: number);
  77147. /**
  77148. * Gets or sets control height
  77149. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77150. */
  77151. get height(): string | number;
  77152. set height(value: string | number);
  77153. /**
  77154. * Gets or sets control height in pixel
  77155. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77156. */
  77157. get heightInPixels(): number;
  77158. set heightInPixels(value: number);
  77159. /** Gets or set font family */
  77160. get fontFamily(): string;
  77161. set fontFamily(value: string);
  77162. /** Gets or sets font style */
  77163. get fontStyle(): string;
  77164. set fontStyle(value: string);
  77165. /** Gets or sets font weight */
  77166. get fontWeight(): string;
  77167. set fontWeight(value: string);
  77168. /**
  77169. * Gets or sets style
  77170. * @see https://doc.babylonjs.com/how_to/gui#styles
  77171. */
  77172. get style(): BABYLON.Nullable<Style>;
  77173. set style(value: BABYLON.Nullable<Style>);
  77174. /** @hidden */
  77175. get _isFontSizeInPercentage(): boolean;
  77176. /** Gets or sets font size in pixels */
  77177. get fontSizeInPixels(): number;
  77178. set fontSizeInPixels(value: number);
  77179. /** Gets or sets font size */
  77180. get fontSize(): string | number;
  77181. set fontSize(value: string | number);
  77182. /** Gets or sets foreground color */
  77183. get color(): string;
  77184. set color(value: string);
  77185. /** Gets or sets z index which is used to reorder controls on the z axis */
  77186. get zIndex(): number;
  77187. set zIndex(value: number);
  77188. /** Gets or sets a boolean indicating if the control can be rendered */
  77189. get notRenderable(): boolean;
  77190. set notRenderable(value: boolean);
  77191. /** Gets or sets a boolean indicating if the control is visible */
  77192. get isVisible(): boolean;
  77193. set isVisible(value: boolean);
  77194. /** Gets a boolean indicating that the control needs to update its rendering */
  77195. get isDirty(): boolean;
  77196. /**
  77197. * Gets the current linked mesh (or null if none)
  77198. */
  77199. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77200. /**
  77201. * Gets or sets a value indicating the padding to use on the left of the control
  77202. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77203. */
  77204. get paddingLeft(): string | number;
  77205. set paddingLeft(value: string | number);
  77206. /**
  77207. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77208. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77209. */
  77210. get paddingLeftInPixels(): number;
  77211. set paddingLeftInPixels(value: number);
  77212. /**
  77213. * Gets or sets a value indicating the padding to use on the right of the control
  77214. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77215. */
  77216. get paddingRight(): string | number;
  77217. set paddingRight(value: string | number);
  77218. /**
  77219. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77220. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77221. */
  77222. get paddingRightInPixels(): number;
  77223. set paddingRightInPixels(value: number);
  77224. /**
  77225. * Gets or sets a value indicating the padding to use on the top of the control
  77226. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77227. */
  77228. get paddingTop(): string | number;
  77229. set paddingTop(value: string | number);
  77230. /**
  77231. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77232. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77233. */
  77234. get paddingTopInPixels(): number;
  77235. set paddingTopInPixels(value: number);
  77236. /**
  77237. * Gets or sets a value indicating the padding to use on the bottom of the control
  77238. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77239. */
  77240. get paddingBottom(): string | number;
  77241. set paddingBottom(value: string | number);
  77242. /**
  77243. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77244. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77245. */
  77246. get paddingBottomInPixels(): number;
  77247. set paddingBottomInPixels(value: number);
  77248. /**
  77249. * Gets or sets a value indicating the left coordinate of the control
  77250. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77251. */
  77252. get left(): string | number;
  77253. set left(value: string | number);
  77254. /**
  77255. * Gets or sets a value indicating the left coordinate in pixels of the control
  77256. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77257. */
  77258. get leftInPixels(): number;
  77259. set leftInPixels(value: number);
  77260. /**
  77261. * Gets or sets a value indicating the top coordinate of the control
  77262. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77263. */
  77264. get top(): string | number;
  77265. set top(value: string | number);
  77266. /**
  77267. * Gets or sets a value indicating the top coordinate in pixels of the control
  77268. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77269. */
  77270. get topInPixels(): number;
  77271. set topInPixels(value: number);
  77272. /**
  77273. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77274. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77275. */
  77276. get linkOffsetX(): string | number;
  77277. set linkOffsetX(value: string | number);
  77278. /**
  77279. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77280. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77281. */
  77282. get linkOffsetXInPixels(): number;
  77283. set linkOffsetXInPixels(value: number);
  77284. /**
  77285. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77286. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77287. */
  77288. get linkOffsetY(): string | number;
  77289. set linkOffsetY(value: string | number);
  77290. /**
  77291. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77292. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77293. */
  77294. get linkOffsetYInPixels(): number;
  77295. set linkOffsetYInPixels(value: number);
  77296. /** Gets the center coordinate on X axis */
  77297. get centerX(): number;
  77298. /** Gets the center coordinate on Y axis */
  77299. get centerY(): number;
  77300. /** Gets or sets if control is Enabled*/
  77301. get isEnabled(): boolean;
  77302. set isEnabled(value: boolean);
  77303. /** Gets or sets background color of control if it's disabled*/
  77304. get disabledColor(): string;
  77305. set disabledColor(value: string);
  77306. /** Gets or sets front color of control if it's disabled*/
  77307. get disabledColorItem(): string;
  77308. set disabledColorItem(value: string);
  77309. /**
  77310. * Creates a new control
  77311. * @param name defines the name of the control
  77312. */
  77313. constructor(
  77314. /** defines the name of the control */
  77315. name?: string | undefined);
  77316. /** @hidden */
  77317. protected _getTypeName(): string;
  77318. /**
  77319. * Gets the first ascendant in the hierarchy of the given type
  77320. * @param className defines the required type
  77321. * @returns the ascendant or null if not found
  77322. */
  77323. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77324. /** @hidden */
  77325. _resetFontCache(): void;
  77326. /**
  77327. * Determines if a container is an ascendant of the current control
  77328. * @param container defines the container to look for
  77329. * @returns true if the container is one of the ascendant of the control
  77330. */
  77331. isAscendant(container: Control): boolean;
  77332. /**
  77333. * Gets coordinates in local control space
  77334. * @param globalCoordinates defines the coordinates to transform
  77335. * @returns the new coordinates in local space
  77336. */
  77337. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77338. /**
  77339. * Gets coordinates in local control space
  77340. * @param globalCoordinates defines the coordinates to transform
  77341. * @param result defines the target vector2 where to store the result
  77342. * @returns the current control
  77343. */
  77344. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77345. /**
  77346. * Gets coordinates in parent local control space
  77347. * @param globalCoordinates defines the coordinates to transform
  77348. * @returns the new coordinates in parent local space
  77349. */
  77350. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77351. /**
  77352. * Move the current control to a vector3 position projected onto the screen.
  77353. * @param position defines the target position
  77354. * @param scene defines the hosting scene
  77355. */
  77356. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77357. /**
  77358. * Will store all controls that have this control as ascendant in a given array
  77359. * @param results defines the array where to store the descendants
  77360. * @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
  77361. * @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
  77362. */
  77363. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77364. /**
  77365. * Will return all controls that have this control as ascendant
  77366. * @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
  77367. * @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
  77368. * @return all child controls
  77369. */
  77370. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77371. /**
  77372. * Link current control with a target mesh
  77373. * @param mesh defines the mesh to link with
  77374. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77375. */
  77376. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77377. /** @hidden */
  77378. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77379. /** @hidden */
  77380. _offsetLeft(offset: number): void;
  77381. /** @hidden */
  77382. _offsetTop(offset: number): void;
  77383. /** @hidden */
  77384. _markMatrixAsDirty(): void;
  77385. /** @hidden */
  77386. _flagDescendantsAsMatrixDirty(): void;
  77387. /** @hidden */
  77388. _intersectsRect(rect: Measure): boolean;
  77389. /** @hidden */
  77390. protected invalidateRect(): void;
  77391. /** @hidden */
  77392. _markAsDirty(force?: boolean): void;
  77393. /** @hidden */
  77394. _markAllAsDirty(): void;
  77395. /** @hidden */
  77396. _link(host: AdvancedDynamicTexture): void;
  77397. /** @hidden */
  77398. protected _transform(context?: CanvasRenderingContext2D): void;
  77399. /** @hidden */
  77400. _renderHighlight(context: CanvasRenderingContext2D): void;
  77401. /** @hidden */
  77402. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77403. /** @hidden */
  77404. protected _applyStates(context: CanvasRenderingContext2D): void;
  77405. /** @hidden */
  77406. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77407. /** @hidden */
  77408. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77409. protected _evaluateClippingState(parentMeasure: Measure): void;
  77410. /** @hidden */
  77411. _measure(): void;
  77412. /** @hidden */
  77413. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77414. /** @hidden */
  77415. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77416. /** @hidden */
  77417. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77418. /** @hidden */
  77419. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77420. private static _ClipMeasure;
  77421. private _tmpMeasureA;
  77422. private _clip;
  77423. /** @hidden */
  77424. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77425. /** @hidden */
  77426. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77427. /**
  77428. * Tests if a given coordinates belong to the current control
  77429. * @param x defines x coordinate to test
  77430. * @param y defines y coordinate to test
  77431. * @returns true if the coordinates are inside the control
  77432. */
  77433. contains(x: number, y: number): boolean;
  77434. /** @hidden */
  77435. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77436. /** @hidden */
  77437. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77438. /** @hidden */
  77439. _onPointerEnter(target: Control): boolean;
  77440. /** @hidden */
  77441. _onPointerOut(target: Control, force?: boolean): void;
  77442. /** @hidden */
  77443. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77444. /** @hidden */
  77445. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77446. /** @hidden */
  77447. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77448. /** @hidden */
  77449. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77450. /** @hidden */
  77451. _onCanvasBlur(): void;
  77452. /** @hidden */
  77453. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77454. private _prepareFont;
  77455. /** Releases associated resources */
  77456. dispose(): void;
  77457. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77458. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77459. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77460. private static _VERTICAL_ALIGNMENT_TOP;
  77461. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77462. private static _VERTICAL_ALIGNMENT_CENTER;
  77463. /** HORIZONTAL_ALIGNMENT_LEFT */
  77464. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77465. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77466. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77467. /** HORIZONTAL_ALIGNMENT_CENTER */
  77468. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77469. /** VERTICAL_ALIGNMENT_TOP */
  77470. static get VERTICAL_ALIGNMENT_TOP(): number;
  77471. /** VERTICAL_ALIGNMENT_BOTTOM */
  77472. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77473. /** VERTICAL_ALIGNMENT_CENTER */
  77474. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77475. private static _FontHeightSizes;
  77476. /** @hidden */
  77477. static _GetFontOffset(font: string): {
  77478. ascent: number;
  77479. height: number;
  77480. descent: number;
  77481. };
  77482. /**
  77483. * Creates a stack panel that can be used to render headers
  77484. * @param control defines the control to associate with the header
  77485. * @param text defines the text of the header
  77486. * @param size defines the size of the header
  77487. * @param options defines options used to configure the header
  77488. * @returns a new StackPanel
  77489. * @ignore
  77490. * @hidden
  77491. */
  77492. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77493. isHorizontal: boolean;
  77494. controlFirst: boolean;
  77495. }) => any;
  77496. /** @hidden */
  77497. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77498. }
  77499. }
  77500. declare module BABYLON.GUI {
  77501. /**
  77502. * Root class for 2D containers
  77503. * @see https://doc.babylonjs.com/how_to/gui#containers
  77504. */
  77505. export class Container extends Control {
  77506. name?: string | undefined;
  77507. /** @hidden */
  77508. _children: Control[];
  77509. /** @hidden */
  77510. protected _measureForChildren: Measure;
  77511. /** @hidden */
  77512. protected _background: string;
  77513. /** @hidden */
  77514. protected _adaptWidthToChildren: boolean;
  77515. /** @hidden */
  77516. protected _adaptHeightToChildren: boolean;
  77517. /**
  77518. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77519. */
  77520. logLayoutCycleErrors: boolean;
  77521. /**
  77522. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77523. */
  77524. maxLayoutCycle: number;
  77525. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77526. get adaptHeightToChildren(): boolean;
  77527. set adaptHeightToChildren(value: boolean);
  77528. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77529. get adaptWidthToChildren(): boolean;
  77530. set adaptWidthToChildren(value: boolean);
  77531. /** Gets or sets background color */
  77532. get background(): string;
  77533. set background(value: string);
  77534. /** Gets the list of children */
  77535. get children(): Control[];
  77536. /**
  77537. * Creates a new Container
  77538. * @param name defines the name of the container
  77539. */
  77540. constructor(name?: string | undefined);
  77541. protected _getTypeName(): string;
  77542. _flagDescendantsAsMatrixDirty(): void;
  77543. /**
  77544. * Gets a child using its name
  77545. * @param name defines the child name to look for
  77546. * @returns the child control if found
  77547. */
  77548. getChildByName(name: string): BABYLON.Nullable<Control>;
  77549. /**
  77550. * Gets a child using its type and its name
  77551. * @param name defines the child name to look for
  77552. * @param type defines the child type to look for
  77553. * @returns the child control if found
  77554. */
  77555. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77556. /**
  77557. * Search for a specific control in children
  77558. * @param control defines the control to look for
  77559. * @returns true if the control is in child list
  77560. */
  77561. containsControl(control: Control): boolean;
  77562. /**
  77563. * Adds a new control to the current container
  77564. * @param control defines the control to add
  77565. * @returns the current container
  77566. */
  77567. addControl(control: BABYLON.Nullable<Control>): Container;
  77568. /**
  77569. * Removes all controls from the current container
  77570. * @returns the current container
  77571. */
  77572. clearControls(): Container;
  77573. /**
  77574. * Removes a control from the current container
  77575. * @param control defines the control to remove
  77576. * @returns the current container
  77577. */
  77578. removeControl(control: Control): Container;
  77579. /** @hidden */
  77580. _reOrderControl(control: Control): void;
  77581. /** @hidden */
  77582. _offsetLeft(offset: number): void;
  77583. /** @hidden */
  77584. _offsetTop(offset: number): void;
  77585. /** @hidden */
  77586. _markAllAsDirty(): void;
  77587. /** @hidden */
  77588. protected _localDraw(context: CanvasRenderingContext2D): void;
  77589. /** @hidden */
  77590. _link(host: AdvancedDynamicTexture): void;
  77591. /** @hidden */
  77592. protected _beforeLayout(): void;
  77593. /** @hidden */
  77594. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77595. /** @hidden */
  77596. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77597. protected _postMeasure(): void;
  77598. /** @hidden */
  77599. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77600. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77601. /** @hidden */
  77602. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77603. /** @hidden */
  77604. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77605. /** Releases associated resources */
  77606. dispose(): void;
  77607. }
  77608. }
  77609. declare module BABYLON.GUI {
  77610. /** Class used to create rectangle container */
  77611. export class Rectangle extends Container {
  77612. name?: string | undefined;
  77613. private _thickness;
  77614. private _cornerRadius;
  77615. /** Gets or sets border thickness */
  77616. get thickness(): number;
  77617. set thickness(value: number);
  77618. /** Gets or sets the corner radius angle */
  77619. get cornerRadius(): number;
  77620. set cornerRadius(value: number);
  77621. /**
  77622. * Creates a new Rectangle
  77623. * @param name defines the control name
  77624. */
  77625. constructor(name?: string | undefined);
  77626. protected _getTypeName(): string;
  77627. protected _localDraw(context: CanvasRenderingContext2D): void;
  77628. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77629. private _drawRoundedRect;
  77630. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77631. }
  77632. }
  77633. declare module BABYLON.GUI {
  77634. /**
  77635. * Enum that determines the text-wrapping mode to use.
  77636. */
  77637. export enum TextWrapping {
  77638. /**
  77639. * Clip the text when it's larger than Control.width; this is the default mode.
  77640. */
  77641. Clip = 0,
  77642. /**
  77643. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77644. */
  77645. WordWrap = 1,
  77646. /**
  77647. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77648. */
  77649. Ellipsis = 2
  77650. }
  77651. /**
  77652. * Class used to create text block control
  77653. */
  77654. export class TextBlock extends Control {
  77655. /**
  77656. * Defines the name of the control
  77657. */
  77658. name?: string | undefined;
  77659. private _text;
  77660. private _textWrapping;
  77661. private _textHorizontalAlignment;
  77662. private _textVerticalAlignment;
  77663. private _lines;
  77664. private _resizeToFit;
  77665. private _lineSpacing;
  77666. private _outlineWidth;
  77667. private _outlineColor;
  77668. private _underline;
  77669. private _lineThrough;
  77670. /**
  77671. * An event triggered after the text is changed
  77672. */
  77673. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77674. /**
  77675. * An event triggered after the text was broken up into lines
  77676. */
  77677. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77678. /**
  77679. * Function used to split a string into words. By default, a string is split at each space character found
  77680. */
  77681. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77682. /**
  77683. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77684. */
  77685. get lines(): any[];
  77686. /**
  77687. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77688. */
  77689. get resizeToFit(): boolean;
  77690. /**
  77691. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77692. */
  77693. set resizeToFit(value: boolean);
  77694. /**
  77695. * Gets or sets a boolean indicating if text must be wrapped
  77696. */
  77697. get textWrapping(): TextWrapping | boolean;
  77698. /**
  77699. * Gets or sets a boolean indicating if text must be wrapped
  77700. */
  77701. set textWrapping(value: TextWrapping | boolean);
  77702. /**
  77703. * Gets or sets text to display
  77704. */
  77705. get text(): string;
  77706. /**
  77707. * Gets or sets text to display
  77708. */
  77709. set text(value: string);
  77710. /**
  77711. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77712. */
  77713. get textHorizontalAlignment(): number;
  77714. /**
  77715. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77716. */
  77717. set textHorizontalAlignment(value: number);
  77718. /**
  77719. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77720. */
  77721. get textVerticalAlignment(): number;
  77722. /**
  77723. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77724. */
  77725. set textVerticalAlignment(value: number);
  77726. /**
  77727. * Gets or sets line spacing value
  77728. */
  77729. set lineSpacing(value: string | number);
  77730. /**
  77731. * Gets or sets line spacing value
  77732. */
  77733. get lineSpacing(): string | number;
  77734. /**
  77735. * Gets or sets outlineWidth of the text to display
  77736. */
  77737. get outlineWidth(): number;
  77738. /**
  77739. * Gets or sets outlineWidth of the text to display
  77740. */
  77741. set outlineWidth(value: number);
  77742. /**
  77743. * Gets or sets a boolean indicating that text must have underline
  77744. */
  77745. get underline(): boolean;
  77746. /**
  77747. * Gets or sets a boolean indicating that text must have underline
  77748. */
  77749. set underline(value: boolean);
  77750. /**
  77751. * Gets or sets an boolean indicating that text must be crossed out
  77752. */
  77753. get lineThrough(): boolean;
  77754. /**
  77755. * Gets or sets an boolean indicating that text must be crossed out
  77756. */
  77757. set lineThrough(value: boolean);
  77758. /**
  77759. * Gets or sets outlineColor of the text to display
  77760. */
  77761. get outlineColor(): string;
  77762. /**
  77763. * Gets or sets outlineColor of the text to display
  77764. */
  77765. set outlineColor(value: string);
  77766. /**
  77767. * Creates a new TextBlock object
  77768. * @param name defines the name of the control
  77769. * @param text defines the text to display (emptry string by default)
  77770. */
  77771. constructor(
  77772. /**
  77773. * Defines the name of the control
  77774. */
  77775. name?: string | undefined, text?: string);
  77776. protected _getTypeName(): string;
  77777. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77778. private _drawText;
  77779. /** @hidden */
  77780. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77781. protected _applyStates(context: CanvasRenderingContext2D): void;
  77782. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77783. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77784. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77785. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77786. protected _renderLines(context: CanvasRenderingContext2D): void;
  77787. /**
  77788. * Given a width constraint applied on the text block, find the expected height
  77789. * @returns expected height
  77790. */
  77791. computeExpectedHeight(): number;
  77792. dispose(): void;
  77793. }
  77794. }
  77795. declare module BABYLON.GUI {
  77796. /**
  77797. * Class used to create 2D images
  77798. */
  77799. export class Image extends Control {
  77800. name?: string | undefined;
  77801. private _workingCanvas;
  77802. private _domImage;
  77803. private _imageWidth;
  77804. private _imageHeight;
  77805. private _loaded;
  77806. private _stretch;
  77807. private _source;
  77808. private _autoScale;
  77809. private _sourceLeft;
  77810. private _sourceTop;
  77811. private _sourceWidth;
  77812. private _sourceHeight;
  77813. private _svgAttributesComputationCompleted;
  77814. private _isSVG;
  77815. private _cellWidth;
  77816. private _cellHeight;
  77817. private _cellId;
  77818. private _populateNinePatchSlicesFromImage;
  77819. private _sliceLeft;
  77820. private _sliceRight;
  77821. private _sliceTop;
  77822. private _sliceBottom;
  77823. private _detectPointerOnOpaqueOnly;
  77824. private _imageDataCache;
  77825. /**
  77826. * BABYLON.Observable notified when the content is loaded
  77827. */
  77828. onImageLoadedObservable: BABYLON.Observable<Image>;
  77829. /**
  77830. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77831. */
  77832. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77833. /**
  77834. * Gets a boolean indicating that the content is loaded
  77835. */
  77836. get isLoaded(): boolean;
  77837. /**
  77838. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77839. */
  77840. get populateNinePatchSlicesFromImage(): boolean;
  77841. set populateNinePatchSlicesFromImage(value: boolean);
  77842. /**
  77843. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77844. * Beware using this as this will comsume more memory as the image has to be stored twice
  77845. */
  77846. get detectPointerOnOpaqueOnly(): boolean;
  77847. set detectPointerOnOpaqueOnly(value: boolean);
  77848. /**
  77849. * Gets or sets the left value for slicing (9-patch)
  77850. */
  77851. get sliceLeft(): number;
  77852. set sliceLeft(value: number);
  77853. /**
  77854. * Gets or sets the right value for slicing (9-patch)
  77855. */
  77856. get sliceRight(): number;
  77857. set sliceRight(value: number);
  77858. /**
  77859. * Gets or sets the top value for slicing (9-patch)
  77860. */
  77861. get sliceTop(): number;
  77862. set sliceTop(value: number);
  77863. /**
  77864. * Gets or sets the bottom value for slicing (9-patch)
  77865. */
  77866. get sliceBottom(): number;
  77867. set sliceBottom(value: number);
  77868. /**
  77869. * Gets or sets the left coordinate in the source image
  77870. */
  77871. get sourceLeft(): number;
  77872. set sourceLeft(value: number);
  77873. /**
  77874. * Gets or sets the top coordinate in the source image
  77875. */
  77876. get sourceTop(): number;
  77877. set sourceTop(value: number);
  77878. /**
  77879. * Gets or sets the width to capture in the source image
  77880. */
  77881. get sourceWidth(): number;
  77882. set sourceWidth(value: number);
  77883. /**
  77884. * Gets or sets the height to capture in the source image
  77885. */
  77886. get sourceHeight(): number;
  77887. set sourceHeight(value: number);
  77888. /** Indicates if the format of the image is SVG */
  77889. get isSVG(): boolean;
  77890. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77891. get svgAttributesComputationCompleted(): boolean;
  77892. /**
  77893. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77894. * @see https://doc.babylonjs.com/how_to/gui#image
  77895. */
  77896. get autoScale(): boolean;
  77897. set autoScale(value: boolean);
  77898. /** Gets or sets the streching mode used by the image */
  77899. get stretch(): number;
  77900. set stretch(value: number);
  77901. /** @hidden */
  77902. _rotate90(n: number, preserveProperties?: boolean): Image;
  77903. private _handleRotationForSVGImage;
  77904. private _rotate90SourceProperties;
  77905. /**
  77906. * Gets or sets the internal DOM image used to render the control
  77907. */
  77908. set domImage(value: HTMLImageElement);
  77909. get domImage(): HTMLImageElement;
  77910. private _onImageLoaded;
  77911. private _extractNinePatchSliceDataFromImage;
  77912. /**
  77913. * Gets or sets image source url
  77914. */
  77915. set source(value: BABYLON.Nullable<string>);
  77916. /**
  77917. * Checks for svg document with icon id present
  77918. */
  77919. private _svgCheck;
  77920. /**
  77921. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77922. * given external svg file and icon id
  77923. */
  77924. private _getSVGAttribs;
  77925. /**
  77926. * Gets or sets the cell width to use when animation sheet is enabled
  77927. * @see https://doc.babylonjs.com/how_to/gui#image
  77928. */
  77929. get cellWidth(): number;
  77930. set cellWidth(value: number);
  77931. /**
  77932. * Gets or sets the cell height to use when animation sheet is enabled
  77933. * @see https://doc.babylonjs.com/how_to/gui#image
  77934. */
  77935. get cellHeight(): number;
  77936. set cellHeight(value: number);
  77937. /**
  77938. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77939. * @see https://doc.babylonjs.com/how_to/gui#image
  77940. */
  77941. get cellId(): number;
  77942. set cellId(value: number);
  77943. /**
  77944. * Creates a new Image
  77945. * @param name defines the control name
  77946. * @param url defines the image url
  77947. */
  77948. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77949. /**
  77950. * Tests if a given coordinates belong to the current control
  77951. * @param x defines x coordinate to test
  77952. * @param y defines y coordinate to test
  77953. * @returns true if the coordinates are inside the control
  77954. */
  77955. contains(x: number, y: number): boolean;
  77956. protected _getTypeName(): string;
  77957. /** Force the control to synchronize with its content */
  77958. synchronizeSizeWithContent(): void;
  77959. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77960. private _prepareWorkingCanvasForOpaqueDetection;
  77961. private _drawImage;
  77962. _draw(context: CanvasRenderingContext2D): void;
  77963. private _renderCornerPatch;
  77964. private _renderNinePatch;
  77965. dispose(): void;
  77966. /** STRETCH_NONE */
  77967. static readonly STRETCH_NONE: number;
  77968. /** STRETCH_FILL */
  77969. static readonly STRETCH_FILL: number;
  77970. /** STRETCH_UNIFORM */
  77971. static readonly STRETCH_UNIFORM: number;
  77972. /** STRETCH_EXTEND */
  77973. static readonly STRETCH_EXTEND: number;
  77974. /** NINE_PATCH */
  77975. static readonly STRETCH_NINE_PATCH: number;
  77976. }
  77977. }
  77978. declare module BABYLON.GUI {
  77979. /**
  77980. * Class used to create 2D buttons
  77981. */
  77982. export class Button extends Rectangle {
  77983. name?: string | undefined;
  77984. /**
  77985. * Function called to generate a pointer enter animation
  77986. */
  77987. pointerEnterAnimation: () => void;
  77988. /**
  77989. * Function called to generate a pointer out animation
  77990. */
  77991. pointerOutAnimation: () => void;
  77992. /**
  77993. * Function called to generate a pointer down animation
  77994. */
  77995. pointerDownAnimation: () => void;
  77996. /**
  77997. * Function called to generate a pointer up animation
  77998. */
  77999. pointerUpAnimation: () => void;
  78000. /**
  78001. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78002. */
  78003. delegatePickingToChildren: boolean;
  78004. private _image;
  78005. /**
  78006. * Returns the image part of the button (if any)
  78007. */
  78008. get image(): BABYLON.Nullable<Image>;
  78009. private _textBlock;
  78010. /**
  78011. * Returns the image part of the button (if any)
  78012. */
  78013. get textBlock(): BABYLON.Nullable<TextBlock>;
  78014. /**
  78015. * Creates a new Button
  78016. * @param name defines the name of the button
  78017. */
  78018. constructor(name?: string | undefined);
  78019. protected _getTypeName(): string;
  78020. /** @hidden */
  78021. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78022. /** @hidden */
  78023. _onPointerEnter(target: Control): boolean;
  78024. /** @hidden */
  78025. _onPointerOut(target: Control, force?: boolean): void;
  78026. /** @hidden */
  78027. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78028. /** @hidden */
  78029. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78030. /**
  78031. * Creates a new button made with an image and a text
  78032. * @param name defines the name of the button
  78033. * @param text defines the text of the button
  78034. * @param imageUrl defines the url of the image
  78035. * @returns a new Button
  78036. */
  78037. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78038. /**
  78039. * Creates a new button made with an image
  78040. * @param name defines the name of the button
  78041. * @param imageUrl defines the url of the image
  78042. * @returns a new Button
  78043. */
  78044. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78045. /**
  78046. * Creates a new button made with a text
  78047. * @param name defines the name of the button
  78048. * @param text defines the text of the button
  78049. * @returns a new Button
  78050. */
  78051. static CreateSimpleButton(name: string, text: string): Button;
  78052. /**
  78053. * Creates a new button made with an image and a centered text
  78054. * @param name defines the name of the button
  78055. * @param text defines the text of the button
  78056. * @param imageUrl defines the url of the image
  78057. * @returns a new Button
  78058. */
  78059. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78060. }
  78061. }
  78062. declare module BABYLON.GUI {
  78063. /**
  78064. * Class used to create a 2D stack panel container
  78065. */
  78066. export class StackPanel extends Container {
  78067. name?: string | undefined;
  78068. private _isVertical;
  78069. private _manualWidth;
  78070. private _manualHeight;
  78071. private _doNotTrackManualChanges;
  78072. /**
  78073. * Gets or sets a boolean indicating that layou warnings should be ignored
  78074. */
  78075. ignoreLayoutWarnings: boolean;
  78076. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78077. get isVertical(): boolean;
  78078. set isVertical(value: boolean);
  78079. /**
  78080. * Gets or sets panel width.
  78081. * This value should not be set when in horizontal mode as it will be computed automatically
  78082. */
  78083. set width(value: string | number);
  78084. get width(): string | number;
  78085. /**
  78086. * Gets or sets panel height.
  78087. * This value should not be set when in vertical mode as it will be computed automatically
  78088. */
  78089. set height(value: string | number);
  78090. get height(): string | number;
  78091. /**
  78092. * Creates a new StackPanel
  78093. * @param name defines control name
  78094. */
  78095. constructor(name?: string | undefined);
  78096. protected _getTypeName(): string;
  78097. /** @hidden */
  78098. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78099. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78100. protected _postMeasure(): void;
  78101. }
  78102. }
  78103. declare module BABYLON.GUI {
  78104. /**
  78105. * Class used to represent a 2D checkbox
  78106. */
  78107. export class Checkbox extends Control {
  78108. name?: string | undefined;
  78109. private _isChecked;
  78110. private _background;
  78111. private _checkSizeRatio;
  78112. private _thickness;
  78113. /** Gets or sets border thickness */
  78114. get thickness(): number;
  78115. set thickness(value: number);
  78116. /**
  78117. * BABYLON.Observable raised when isChecked property changes
  78118. */
  78119. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78120. /** Gets or sets a value indicating the ratio between overall size and check size */
  78121. get checkSizeRatio(): number;
  78122. set checkSizeRatio(value: number);
  78123. /** Gets or sets background color */
  78124. get background(): string;
  78125. set background(value: string);
  78126. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78127. get isChecked(): boolean;
  78128. set isChecked(value: boolean);
  78129. /**
  78130. * Creates a new CheckBox
  78131. * @param name defines the control name
  78132. */
  78133. constructor(name?: string | undefined);
  78134. protected _getTypeName(): string;
  78135. /** @hidden */
  78136. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78137. /** @hidden */
  78138. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78139. /**
  78140. * Utility function to easily create a checkbox with a header
  78141. * @param title defines the label to use for the header
  78142. * @param onValueChanged defines the callback to call when value changes
  78143. * @returns a StackPanel containing the checkbox and a textBlock
  78144. */
  78145. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78146. }
  78147. }
  78148. declare module BABYLON.GUI {
  78149. /**
  78150. * Class used to store key control properties
  78151. */
  78152. export class KeyPropertySet {
  78153. /** Width */
  78154. width?: string;
  78155. /** Height */
  78156. height?: string;
  78157. /** Left padding */
  78158. paddingLeft?: string;
  78159. /** Right padding */
  78160. paddingRight?: string;
  78161. /** Top padding */
  78162. paddingTop?: string;
  78163. /** Bottom padding */
  78164. paddingBottom?: string;
  78165. /** Foreground color */
  78166. color?: string;
  78167. /** Background color */
  78168. background?: string;
  78169. }
  78170. /**
  78171. * Class used to create virtual keyboard
  78172. */
  78173. export class VirtualKeyboard extends StackPanel {
  78174. /** BABYLON.Observable raised when a key is pressed */
  78175. onKeyPressObservable: BABYLON.Observable<string>;
  78176. /** Gets or sets default key button width */
  78177. defaultButtonWidth: string;
  78178. /** Gets or sets default key button height */
  78179. defaultButtonHeight: string;
  78180. /** Gets or sets default key button left padding */
  78181. defaultButtonPaddingLeft: string;
  78182. /** Gets or sets default key button right padding */
  78183. defaultButtonPaddingRight: string;
  78184. /** Gets or sets default key button top padding */
  78185. defaultButtonPaddingTop: string;
  78186. /** Gets or sets default key button bottom padding */
  78187. defaultButtonPaddingBottom: string;
  78188. /** Gets or sets default key button foreground color */
  78189. defaultButtonColor: string;
  78190. /** Gets or sets default key button background color */
  78191. defaultButtonBackground: string;
  78192. /** Gets or sets shift button foreground color */
  78193. shiftButtonColor: string;
  78194. /** Gets or sets shift button thickness*/
  78195. selectedShiftThickness: number;
  78196. /** Gets shift key state */
  78197. shiftState: number;
  78198. protected _getTypeName(): string;
  78199. private _createKey;
  78200. /**
  78201. * Adds a new row of keys
  78202. * @param keys defines the list of keys to add
  78203. * @param propertySets defines the associated property sets
  78204. */
  78205. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78206. /**
  78207. * Set the shift key to a specific state
  78208. * @param shiftState defines the new shift state
  78209. */
  78210. applyShiftState(shiftState: number): void;
  78211. private _currentlyConnectedInputText;
  78212. private _connectedInputTexts;
  78213. private _onKeyPressObserver;
  78214. /** Gets the input text control currently attached to the keyboard */
  78215. get connectedInputText(): BABYLON.Nullable<InputText>;
  78216. /**
  78217. * Connects the keyboard with an input text control
  78218. *
  78219. * @param input defines the target control
  78220. */
  78221. connect(input: InputText): void;
  78222. /**
  78223. * Disconnects the keyboard from connected InputText controls
  78224. *
  78225. * @param input optionally defines a target control, otherwise all are disconnected
  78226. */
  78227. disconnect(input?: InputText): void;
  78228. private _removeConnectedInputObservables;
  78229. /**
  78230. * Release all resources
  78231. */
  78232. dispose(): void;
  78233. /**
  78234. * Creates a new keyboard using a default layout
  78235. *
  78236. * @param name defines control name
  78237. * @returns a new VirtualKeyboard
  78238. */
  78239. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78240. }
  78241. }
  78242. declare module BABYLON.GUI {
  78243. /**
  78244. * Class used to create input text control
  78245. */
  78246. export class InputText extends Control implements IFocusableControl {
  78247. name?: string | undefined;
  78248. private _text;
  78249. private _placeholderText;
  78250. private _background;
  78251. private _focusedBackground;
  78252. private _focusedColor;
  78253. private _placeholderColor;
  78254. private _thickness;
  78255. private _margin;
  78256. private _autoStretchWidth;
  78257. private _maxWidth;
  78258. private _isFocused;
  78259. private _blinkTimeout;
  78260. private _blinkIsEven;
  78261. private _cursorOffset;
  78262. private _scrollLeft;
  78263. private _textWidth;
  78264. private _clickedCoordinate;
  78265. private _deadKey;
  78266. private _addKey;
  78267. private _currentKey;
  78268. private _isTextHighlightOn;
  78269. private _textHighlightColor;
  78270. private _highligherOpacity;
  78271. private _highlightedText;
  78272. private _startHighlightIndex;
  78273. private _endHighlightIndex;
  78274. private _cursorIndex;
  78275. private _onFocusSelectAll;
  78276. private _isPointerDown;
  78277. private _onClipboardObserver;
  78278. private _onPointerDblTapObserver;
  78279. /** @hidden */
  78280. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78281. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78282. promptMessage: string;
  78283. /** Force disable prompt on mobile device */
  78284. disableMobilePrompt: boolean;
  78285. /** BABYLON.Observable raised when the text changes */
  78286. onTextChangedObservable: BABYLON.Observable<InputText>;
  78287. /** BABYLON.Observable raised just before an entered character is to be added */
  78288. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78289. /** BABYLON.Observable raised when the control gets the focus */
  78290. onFocusObservable: BABYLON.Observable<InputText>;
  78291. /** BABYLON.Observable raised when the control loses the focus */
  78292. onBlurObservable: BABYLON.Observable<InputText>;
  78293. /**Observable raised when the text is highlighted */
  78294. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78295. /**Observable raised when copy event is triggered */
  78296. onTextCopyObservable: BABYLON.Observable<InputText>;
  78297. /** BABYLON.Observable raised when cut event is triggered */
  78298. onTextCutObservable: BABYLON.Observable<InputText>;
  78299. /** BABYLON.Observable raised when paste event is triggered */
  78300. onTextPasteObservable: BABYLON.Observable<InputText>;
  78301. /** BABYLON.Observable raised when a key event was processed */
  78302. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78303. /** Gets or sets the maximum width allowed by the control */
  78304. get maxWidth(): string | number;
  78305. /** Gets the maximum width allowed by the control in pixels */
  78306. get maxWidthInPixels(): number;
  78307. set maxWidth(value: string | number);
  78308. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78309. get highligherOpacity(): number;
  78310. set highligherOpacity(value: number);
  78311. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78312. get onFocusSelectAll(): boolean;
  78313. set onFocusSelectAll(value: boolean);
  78314. /** Gets or sets the text hightlight color */
  78315. get textHighlightColor(): string;
  78316. set textHighlightColor(value: string);
  78317. /** Gets or sets control margin */
  78318. get margin(): string;
  78319. /** Gets control margin in pixels */
  78320. get marginInPixels(): number;
  78321. set margin(value: string);
  78322. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78323. get autoStretchWidth(): boolean;
  78324. set autoStretchWidth(value: boolean);
  78325. /** Gets or sets border thickness */
  78326. get thickness(): number;
  78327. set thickness(value: number);
  78328. /** Gets or sets the background color when focused */
  78329. get focusedBackground(): string;
  78330. set focusedBackground(value: string);
  78331. /** Gets or sets the background color when focused */
  78332. get focusedColor(): string;
  78333. set focusedColor(value: string);
  78334. /** Gets or sets the background color */
  78335. get background(): string;
  78336. set background(value: string);
  78337. /** Gets or sets the placeholder color */
  78338. get placeholderColor(): string;
  78339. set placeholderColor(value: string);
  78340. /** Gets or sets the text displayed when the control is empty */
  78341. get placeholderText(): string;
  78342. set placeholderText(value: string);
  78343. /** Gets or sets the dead key flag */
  78344. get deadKey(): boolean;
  78345. set deadKey(flag: boolean);
  78346. /** Gets or sets the highlight text */
  78347. get highlightedText(): string;
  78348. set highlightedText(text: string);
  78349. /** Gets or sets if the current key should be added */
  78350. get addKey(): boolean;
  78351. set addKey(flag: boolean);
  78352. /** Gets or sets the value of the current key being entered */
  78353. get currentKey(): string;
  78354. set currentKey(key: string);
  78355. /** Gets or sets the text displayed in the control */
  78356. get text(): string;
  78357. set text(value: string);
  78358. /** Gets or sets control width */
  78359. get width(): string | number;
  78360. set width(value: string | number);
  78361. /**
  78362. * Creates a new InputText
  78363. * @param name defines the control name
  78364. * @param text defines the text of the control
  78365. */
  78366. constructor(name?: string | undefined, text?: string);
  78367. /** @hidden */
  78368. onBlur(): void;
  78369. /** @hidden */
  78370. onFocus(): void;
  78371. protected _getTypeName(): string;
  78372. /**
  78373. * Function called to get the list of controls that should not steal the focus from this control
  78374. * @returns an array of controls
  78375. */
  78376. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78377. /** @hidden */
  78378. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78379. /** @hidden */
  78380. private _updateValueFromCursorIndex;
  78381. /** @hidden */
  78382. private _processDblClick;
  78383. /** @hidden */
  78384. private _selectAllText;
  78385. /**
  78386. * Handles the keyboard event
  78387. * @param evt Defines the KeyboardEvent
  78388. */
  78389. processKeyboard(evt: KeyboardEvent): void;
  78390. /** @hidden */
  78391. private _onCopyText;
  78392. /** @hidden */
  78393. private _onCutText;
  78394. /** @hidden */
  78395. private _onPasteText;
  78396. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78397. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78398. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78399. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78400. protected _beforeRenderText(text: string): string;
  78401. dispose(): void;
  78402. }
  78403. }
  78404. declare module BABYLON.GUI {
  78405. /**
  78406. * Class used to create a 2D grid container
  78407. */
  78408. export class Grid extends Container {
  78409. name?: string | undefined;
  78410. private _rowDefinitions;
  78411. private _columnDefinitions;
  78412. private _cells;
  78413. private _childControls;
  78414. /**
  78415. * Gets the number of columns
  78416. */
  78417. get columnCount(): number;
  78418. /**
  78419. * Gets the number of rows
  78420. */
  78421. get rowCount(): number;
  78422. /** Gets the list of children */
  78423. get children(): Control[];
  78424. /** Gets the list of cells (e.g. the containers) */
  78425. get cells(): {
  78426. [key: string]: Container;
  78427. };
  78428. /**
  78429. * Gets the definition of a specific row
  78430. * @param index defines the index of the row
  78431. * @returns the row definition
  78432. */
  78433. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78434. /**
  78435. * Gets the definition of a specific column
  78436. * @param index defines the index of the column
  78437. * @returns the column definition
  78438. */
  78439. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78440. /**
  78441. * Adds a new row to the grid
  78442. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78443. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78444. * @returns the current grid
  78445. */
  78446. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78447. /**
  78448. * Adds a new column to the grid
  78449. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78450. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78451. * @returns the current grid
  78452. */
  78453. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78454. /**
  78455. * Update a row definition
  78456. * @param index defines the index of the row to update
  78457. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78458. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78459. * @returns the current grid
  78460. */
  78461. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78462. /**
  78463. * Update a column definition
  78464. * @param index defines the index of the column to update
  78465. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78466. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78467. * @returns the current grid
  78468. */
  78469. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78470. /**
  78471. * Gets the list of children stored in a specific cell
  78472. * @param row defines the row to check
  78473. * @param column defines the column to check
  78474. * @returns the list of controls
  78475. */
  78476. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78477. /**
  78478. * Gets a string representing the child cell info (row x column)
  78479. * @param child defines the control to get info from
  78480. * @returns a string containing the child cell info (row x column)
  78481. */
  78482. getChildCellInfo(child: Control): string;
  78483. private _removeCell;
  78484. private _offsetCell;
  78485. /**
  78486. * Remove a column definition at specified index
  78487. * @param index defines the index of the column to remove
  78488. * @returns the current grid
  78489. */
  78490. removeColumnDefinition(index: number): Grid;
  78491. /**
  78492. * Remove a row definition at specified index
  78493. * @param index defines the index of the row to remove
  78494. * @returns the current grid
  78495. */
  78496. removeRowDefinition(index: number): Grid;
  78497. /**
  78498. * Adds a new control to the current grid
  78499. * @param control defines the control to add
  78500. * @param row defines the row where to add the control (0 by default)
  78501. * @param column defines the column where to add the control (0 by default)
  78502. * @returns the current grid
  78503. */
  78504. addControl(control: Control, row?: number, column?: number): Grid;
  78505. /**
  78506. * Removes a control from the current container
  78507. * @param control defines the control to remove
  78508. * @returns the current container
  78509. */
  78510. removeControl(control: Control): Container;
  78511. /**
  78512. * Creates a new Grid
  78513. * @param name defines control name
  78514. */
  78515. constructor(name?: string | undefined);
  78516. protected _getTypeName(): string;
  78517. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78518. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78519. _flagDescendantsAsMatrixDirty(): void;
  78520. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78521. /** Releases associated resources */
  78522. dispose(): void;
  78523. }
  78524. }
  78525. declare module BABYLON.GUI {
  78526. /** Class used to create color pickers */
  78527. export class ColorPicker extends Control {
  78528. name?: string | undefined;
  78529. private static _Epsilon;
  78530. private _colorWheelCanvas;
  78531. private _value;
  78532. private _tmpColor;
  78533. private _pointerStartedOnSquare;
  78534. private _pointerStartedOnWheel;
  78535. private _squareLeft;
  78536. private _squareTop;
  78537. private _squareSize;
  78538. private _h;
  78539. private _s;
  78540. private _v;
  78541. private _lastPointerDownID;
  78542. /**
  78543. * BABYLON.Observable raised when the value changes
  78544. */
  78545. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78546. /** Gets or sets the color of the color picker */
  78547. get value(): BABYLON.Color3;
  78548. set value(value: BABYLON.Color3);
  78549. /**
  78550. * Gets or sets control width
  78551. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78552. */
  78553. get width(): string | number;
  78554. set width(value: string | number);
  78555. /**
  78556. * Gets or sets control height
  78557. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78558. */
  78559. get height(): string | number;
  78560. /** Gets or sets control height */
  78561. set height(value: string | number);
  78562. /** Gets or sets control size */
  78563. get size(): string | number;
  78564. set size(value: string | number);
  78565. /**
  78566. * Creates a new ColorPicker
  78567. * @param name defines the control name
  78568. */
  78569. constructor(name?: string | undefined);
  78570. protected _getTypeName(): string;
  78571. /** @hidden */
  78572. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78573. private _updateSquareProps;
  78574. private _drawGradientSquare;
  78575. private _drawCircle;
  78576. private _createColorWheelCanvas;
  78577. /** @hidden */
  78578. _draw(context: CanvasRenderingContext2D): void;
  78579. private _pointerIsDown;
  78580. private _updateValueFromPointer;
  78581. private _isPointOnSquare;
  78582. private _isPointOnWheel;
  78583. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78584. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78585. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78586. _onCanvasBlur(): void;
  78587. /**
  78588. * This function expands the color picker by creating a color picker dialog with manual
  78589. * color value input and the ability to save colors into an array to be used later in
  78590. * subsequent launches of the dialogue.
  78591. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78592. * @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.
  78593. * @returns picked color as a hex string and the saved colors array as hex strings.
  78594. */
  78595. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78596. pickerWidth?: string;
  78597. pickerHeight?: string;
  78598. headerHeight?: string;
  78599. lastColor?: string;
  78600. swatchLimit?: number;
  78601. numSwatchesPerLine?: number;
  78602. savedColors?: Array<string>;
  78603. }): Promise<{
  78604. savedColors?: string[];
  78605. pickedColor: string;
  78606. }>;
  78607. }
  78608. }
  78609. declare module BABYLON.GUI {
  78610. /** Class used to create 2D ellipse containers */
  78611. export class Ellipse extends Container {
  78612. name?: string | undefined;
  78613. private _thickness;
  78614. /** Gets or sets border thickness */
  78615. get thickness(): number;
  78616. set thickness(value: number);
  78617. /**
  78618. * Creates a new Ellipse
  78619. * @param name defines the control name
  78620. */
  78621. constructor(name?: string | undefined);
  78622. protected _getTypeName(): string;
  78623. protected _localDraw(context: CanvasRenderingContext2D): void;
  78624. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78625. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78626. }
  78627. }
  78628. declare module BABYLON.GUI {
  78629. /**
  78630. * Class used to create a password control
  78631. */
  78632. export class InputPassword extends InputText {
  78633. protected _beforeRenderText(text: string): string;
  78634. }
  78635. }
  78636. declare module BABYLON.GUI {
  78637. /** Class used to render 2D lines */
  78638. export class Line extends Control {
  78639. name?: string | undefined;
  78640. private _lineWidth;
  78641. private _x1;
  78642. private _y1;
  78643. private _x2;
  78644. private _y2;
  78645. private _dash;
  78646. private _connectedControl;
  78647. private _connectedControlDirtyObserver;
  78648. /** Gets or sets the dash pattern */
  78649. get dash(): Array<number>;
  78650. set dash(value: Array<number>);
  78651. /** Gets or sets the control connected with the line end */
  78652. get connectedControl(): Control;
  78653. set connectedControl(value: Control);
  78654. /** Gets or sets start coordinates on X axis */
  78655. get x1(): string | number;
  78656. set x1(value: string | number);
  78657. /** Gets or sets start coordinates on Y axis */
  78658. get y1(): string | number;
  78659. set y1(value: string | number);
  78660. /** Gets or sets end coordinates on X axis */
  78661. get x2(): string | number;
  78662. set x2(value: string | number);
  78663. /** Gets or sets end coordinates on Y axis */
  78664. get y2(): string | number;
  78665. set y2(value: string | number);
  78666. /** Gets or sets line width */
  78667. get lineWidth(): number;
  78668. set lineWidth(value: number);
  78669. /** Gets or sets horizontal alignment */
  78670. set horizontalAlignment(value: number);
  78671. /** Gets or sets vertical alignment */
  78672. set verticalAlignment(value: number);
  78673. private get _effectiveX2();
  78674. private get _effectiveY2();
  78675. /**
  78676. * Creates a new Line
  78677. * @param name defines the control name
  78678. */
  78679. constructor(name?: string | undefined);
  78680. protected _getTypeName(): string;
  78681. _draw(context: CanvasRenderingContext2D): void;
  78682. _measure(): void;
  78683. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78684. /**
  78685. * Move one end of the line given 3D cartesian coordinates.
  78686. * @param position Targeted world position
  78687. * @param scene BABYLON.Scene
  78688. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78689. */
  78690. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78691. /**
  78692. * Move one end of the line to a position in screen absolute space.
  78693. * @param projectedPosition Position in screen absolute space (X, Y)
  78694. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78695. */
  78696. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78697. }
  78698. }
  78699. declare module BABYLON.GUI {
  78700. /**
  78701. * Class used to store a point for a MultiLine object.
  78702. * The point can be pure 2D coordinates, a mesh or a control
  78703. */
  78704. export class MultiLinePoint {
  78705. private _multiLine;
  78706. private _x;
  78707. private _y;
  78708. private _control;
  78709. private _mesh;
  78710. private _controlObserver;
  78711. private _meshObserver;
  78712. /** @hidden */
  78713. _point: BABYLON.Vector2;
  78714. /**
  78715. * Creates a new MultiLinePoint
  78716. * @param multiLine defines the source MultiLine object
  78717. */
  78718. constructor(multiLine: MultiLine);
  78719. /** Gets or sets x coordinate */
  78720. get x(): string | number;
  78721. set x(value: string | number);
  78722. /** Gets or sets y coordinate */
  78723. get y(): string | number;
  78724. set y(value: string | number);
  78725. /** Gets or sets the control associated with this point */
  78726. get control(): BABYLON.Nullable<Control>;
  78727. set control(value: BABYLON.Nullable<Control>);
  78728. /** Gets or sets the mesh associated with this point */
  78729. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78730. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78731. /** Resets links */
  78732. resetLinks(): void;
  78733. /**
  78734. * Gets a translation vector
  78735. * @returns the translation vector
  78736. */
  78737. translate(): BABYLON.Vector2;
  78738. private _translatePoint;
  78739. /** Release associated resources */
  78740. dispose(): void;
  78741. }
  78742. }
  78743. declare module BABYLON.GUI {
  78744. /**
  78745. * Class used to create multi line control
  78746. */
  78747. export class MultiLine extends Control {
  78748. name?: string | undefined;
  78749. private _lineWidth;
  78750. private _dash;
  78751. private _points;
  78752. private _minX;
  78753. private _minY;
  78754. private _maxX;
  78755. private _maxY;
  78756. /**
  78757. * Creates a new MultiLine
  78758. * @param name defines the control name
  78759. */
  78760. constructor(name?: string | undefined);
  78761. /** Gets or sets dash pattern */
  78762. get dash(): Array<number>;
  78763. set dash(value: Array<number>);
  78764. /**
  78765. * Gets point stored at specified index
  78766. * @param index defines the index to look for
  78767. * @returns the requested point if found
  78768. */
  78769. getAt(index: number): MultiLinePoint;
  78770. /** Function called when a point is updated */
  78771. onPointUpdate: () => void;
  78772. /**
  78773. * Adds new points to the point collection
  78774. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78775. * @returns the list of created MultiLinePoint
  78776. */
  78777. add(...items: (AbstractMesh | Control | {
  78778. x: string | number;
  78779. y: string | number;
  78780. })[]): MultiLinePoint[];
  78781. /**
  78782. * Adds a new point to the point collection
  78783. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78784. * @returns the created MultiLinePoint
  78785. */
  78786. push(item?: (AbstractMesh | Control | {
  78787. x: string | number;
  78788. y: string | number;
  78789. })): MultiLinePoint;
  78790. /**
  78791. * Remove a specific value or point from the active point collection
  78792. * @param value defines the value or point to remove
  78793. */
  78794. remove(value: number | MultiLinePoint): void;
  78795. /**
  78796. * Resets this object to initial state (no point)
  78797. */
  78798. reset(): void;
  78799. /**
  78800. * Resets all links
  78801. */
  78802. resetLinks(): void;
  78803. /** Gets or sets line width */
  78804. get lineWidth(): number;
  78805. set lineWidth(value: number);
  78806. set horizontalAlignment(value: number);
  78807. set verticalAlignment(value: number);
  78808. protected _getTypeName(): string;
  78809. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78810. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78811. _measure(): void;
  78812. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78813. dispose(): void;
  78814. }
  78815. }
  78816. declare module BABYLON.GUI {
  78817. /**
  78818. * Class used to create radio button controls
  78819. */
  78820. export class RadioButton extends Control {
  78821. name?: string | undefined;
  78822. private _isChecked;
  78823. private _background;
  78824. private _checkSizeRatio;
  78825. private _thickness;
  78826. /** Gets or sets border thickness */
  78827. get thickness(): number;
  78828. set thickness(value: number);
  78829. /** Gets or sets group name */
  78830. group: string;
  78831. /** BABYLON.Observable raised when isChecked is changed */
  78832. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78833. /** Gets or sets a value indicating the ratio between overall size and check size */
  78834. get checkSizeRatio(): number;
  78835. set checkSizeRatio(value: number);
  78836. /** Gets or sets background color */
  78837. get background(): string;
  78838. set background(value: string);
  78839. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78840. get isChecked(): boolean;
  78841. set isChecked(value: boolean);
  78842. /**
  78843. * Creates a new RadioButton
  78844. * @param name defines the control name
  78845. */
  78846. constructor(name?: string | undefined);
  78847. protected _getTypeName(): string;
  78848. _draw(context: CanvasRenderingContext2D): void;
  78849. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78850. /**
  78851. * Utility function to easily create a radio button with a header
  78852. * @param title defines the label to use for the header
  78853. * @param group defines the group to use for the radio button
  78854. * @param isChecked defines the initial state of the radio button
  78855. * @param onValueChanged defines the callback to call when value changes
  78856. * @returns a StackPanel containing the radio button and a textBlock
  78857. */
  78858. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78859. }
  78860. }
  78861. declare module BABYLON.GUI {
  78862. /**
  78863. * Class used to create slider controls
  78864. */
  78865. export class BaseSlider extends Control {
  78866. name?: string | undefined;
  78867. protected _thumbWidth: ValueAndUnit;
  78868. private _minimum;
  78869. private _maximum;
  78870. private _value;
  78871. private _isVertical;
  78872. protected _barOffset: ValueAndUnit;
  78873. private _isThumbClamped;
  78874. protected _displayThumb: boolean;
  78875. private _step;
  78876. private _lastPointerDownID;
  78877. protected _effectiveBarOffset: number;
  78878. protected _renderLeft: number;
  78879. protected _renderTop: number;
  78880. protected _renderWidth: number;
  78881. protected _renderHeight: number;
  78882. protected _backgroundBoxLength: number;
  78883. protected _backgroundBoxThickness: number;
  78884. protected _effectiveThumbThickness: number;
  78885. /** BABYLON.Observable raised when the sldier value changes */
  78886. onValueChangedObservable: BABYLON.Observable<number>;
  78887. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78888. get displayThumb(): boolean;
  78889. set displayThumb(value: boolean);
  78890. /** Gets or sets a step to apply to values (0 by default) */
  78891. get step(): number;
  78892. set step(value: number);
  78893. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78894. get barOffset(): string | number;
  78895. /** Gets main bar offset in pixels*/
  78896. get barOffsetInPixels(): number;
  78897. set barOffset(value: string | number);
  78898. /** Gets or sets thumb width */
  78899. get thumbWidth(): string | number;
  78900. /** Gets thumb width in pixels */
  78901. get thumbWidthInPixels(): number;
  78902. set thumbWidth(value: string | number);
  78903. /** Gets or sets minimum value */
  78904. get minimum(): number;
  78905. set minimum(value: number);
  78906. /** Gets or sets maximum value */
  78907. get maximum(): number;
  78908. set maximum(value: number);
  78909. /** Gets or sets current value */
  78910. get value(): number;
  78911. set value(value: number);
  78912. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78913. get isVertical(): boolean;
  78914. set isVertical(value: boolean);
  78915. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78916. get isThumbClamped(): boolean;
  78917. set isThumbClamped(value: boolean);
  78918. /**
  78919. * Creates a new BaseSlider
  78920. * @param name defines the control name
  78921. */
  78922. constructor(name?: string | undefined);
  78923. protected _getTypeName(): string;
  78924. protected _getThumbPosition(): number;
  78925. protected _getThumbThickness(type: string): number;
  78926. protected _prepareRenderingData(type: string): void;
  78927. private _pointerIsDown;
  78928. /** @hidden */
  78929. protected _updateValueFromPointer(x: number, y: number): void;
  78930. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78931. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78932. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78933. _onCanvasBlur(): void;
  78934. }
  78935. }
  78936. declare module BABYLON.GUI {
  78937. /**
  78938. * Class used to create slider controls
  78939. */
  78940. export class Slider extends BaseSlider {
  78941. name?: string | undefined;
  78942. private _background;
  78943. private _borderColor;
  78944. private _thumbColor;
  78945. private _isThumbCircle;
  78946. protected _displayValueBar: boolean;
  78947. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78948. get displayValueBar(): boolean;
  78949. set displayValueBar(value: boolean);
  78950. /** Gets or sets border color */
  78951. get borderColor(): string;
  78952. set borderColor(value: string);
  78953. /** Gets or sets background color */
  78954. get background(): string;
  78955. set background(value: string);
  78956. /** Gets or sets thumb's color */
  78957. get thumbColor(): string;
  78958. set thumbColor(value: string);
  78959. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78960. get isThumbCircle(): boolean;
  78961. set isThumbCircle(value: boolean);
  78962. /**
  78963. * Creates a new Slider
  78964. * @param name defines the control name
  78965. */
  78966. constructor(name?: string | undefined);
  78967. protected _getTypeName(): string;
  78968. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78969. }
  78970. }
  78971. declare module BABYLON.GUI {
  78972. /** Class used to create a RadioGroup
  78973. * which contains groups of radio buttons
  78974. */
  78975. export class SelectorGroup {
  78976. /** name of SelectorGroup */
  78977. name: string;
  78978. private _groupPanel;
  78979. private _selectors;
  78980. private _groupHeader;
  78981. /**
  78982. * Creates a new SelectorGroup
  78983. * @param name of group, used as a group heading
  78984. */
  78985. constructor(
  78986. /** name of SelectorGroup */
  78987. name: string);
  78988. /** Gets the groupPanel of the SelectorGroup */
  78989. get groupPanel(): StackPanel;
  78990. /** Gets the selectors array */
  78991. get selectors(): StackPanel[];
  78992. /** Gets and sets the group header */
  78993. get header(): string;
  78994. set header(label: string);
  78995. /** @hidden */
  78996. private _addGroupHeader;
  78997. /** @hidden*/
  78998. _getSelector(selectorNb: number): StackPanel | undefined;
  78999. /** Removes the selector at the given position
  79000. * @param selectorNb the position of the selector within the group
  79001. */
  79002. removeSelector(selectorNb: number): void;
  79003. }
  79004. /** Class used to create a CheckboxGroup
  79005. * which contains groups of checkbox buttons
  79006. */
  79007. export class CheckboxGroup extends SelectorGroup {
  79008. /** Adds a checkbox as a control
  79009. * @param text is the label for the selector
  79010. * @param func is the function called when the Selector is checked
  79011. * @param checked is true when Selector is checked
  79012. */
  79013. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79014. /** @hidden */
  79015. _setSelectorLabel(selectorNb: number, label: string): void;
  79016. /** @hidden */
  79017. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79018. /** @hidden */
  79019. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79020. /** @hidden */
  79021. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79022. }
  79023. /** Class used to create a RadioGroup
  79024. * which contains groups of radio buttons
  79025. */
  79026. export class RadioGroup extends SelectorGroup {
  79027. private _selectNb;
  79028. /** Adds a radio button as a control
  79029. * @param label is the label for the selector
  79030. * @param func is the function called when the Selector is checked
  79031. * @param checked is true when Selector is checked
  79032. */
  79033. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79034. /** @hidden */
  79035. _setSelectorLabel(selectorNb: number, label: string): void;
  79036. /** @hidden */
  79037. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79038. /** @hidden */
  79039. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79040. /** @hidden */
  79041. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79042. }
  79043. /** Class used to create a SliderGroup
  79044. * which contains groups of slider buttons
  79045. */
  79046. export class SliderGroup extends SelectorGroup {
  79047. /**
  79048. * Adds a slider to the SelectorGroup
  79049. * @param label is the label for the SliderBar
  79050. * @param func is the function called when the Slider moves
  79051. * @param unit is a string describing the units used, eg degrees or metres
  79052. * @param min is the minimum value for the Slider
  79053. * @param max is the maximum value for the Slider
  79054. * @param value is the start value for the Slider between min and max
  79055. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79056. */
  79057. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79058. /** @hidden */
  79059. _setSelectorLabel(selectorNb: number, label: string): void;
  79060. /** @hidden */
  79061. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79062. /** @hidden */
  79063. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79064. /** @hidden */
  79065. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79066. }
  79067. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79068. * @see https://doc.babylonjs.com/how_to/selector
  79069. */
  79070. export class SelectionPanel extends Rectangle {
  79071. /** name of SelectionPanel */
  79072. name: string;
  79073. /** an array of SelectionGroups */
  79074. groups: SelectorGroup[];
  79075. private _panel;
  79076. private _buttonColor;
  79077. private _buttonBackground;
  79078. private _headerColor;
  79079. private _barColor;
  79080. private _barHeight;
  79081. private _spacerHeight;
  79082. private _labelColor;
  79083. private _groups;
  79084. private _bars;
  79085. /**
  79086. * Creates a new SelectionPanel
  79087. * @param name of SelectionPanel
  79088. * @param groups is an array of SelectionGroups
  79089. */
  79090. constructor(
  79091. /** name of SelectionPanel */
  79092. name: string,
  79093. /** an array of SelectionGroups */
  79094. groups?: SelectorGroup[]);
  79095. protected _getTypeName(): string;
  79096. /** Gets or sets the headerColor */
  79097. get headerColor(): string;
  79098. set headerColor(color: string);
  79099. private _setHeaderColor;
  79100. /** Gets or sets the button color */
  79101. get buttonColor(): string;
  79102. set buttonColor(color: string);
  79103. private _setbuttonColor;
  79104. /** Gets or sets the label color */
  79105. get labelColor(): string;
  79106. set labelColor(color: string);
  79107. private _setLabelColor;
  79108. /** Gets or sets the button background */
  79109. get buttonBackground(): string;
  79110. set buttonBackground(color: string);
  79111. private _setButtonBackground;
  79112. /** Gets or sets the color of separator bar */
  79113. get barColor(): string;
  79114. set barColor(color: string);
  79115. private _setBarColor;
  79116. /** Gets or sets the height of separator bar */
  79117. get barHeight(): string;
  79118. set barHeight(value: string);
  79119. private _setBarHeight;
  79120. /** Gets or sets the height of spacers*/
  79121. get spacerHeight(): string;
  79122. set spacerHeight(value: string);
  79123. private _setSpacerHeight;
  79124. /** Adds a bar between groups */
  79125. private _addSpacer;
  79126. /** Add a group to the selection panel
  79127. * @param group is the selector group to add
  79128. */
  79129. addGroup(group: SelectorGroup): void;
  79130. /** Remove the group from the given position
  79131. * @param groupNb is the position of the group in the list
  79132. */
  79133. removeGroup(groupNb: number): void;
  79134. /** Change a group header label
  79135. * @param label is the new group header label
  79136. * @param groupNb is the number of the group to relabel
  79137. * */
  79138. setHeaderName(label: string, groupNb: number): void;
  79139. /** Change selector label to the one given
  79140. * @param label is the new selector label
  79141. * @param groupNb is the number of the groupcontaining the selector
  79142. * @param selectorNb is the number of the selector within a group to relabel
  79143. * */
  79144. relabel(label: string, groupNb: number, selectorNb: number): void;
  79145. /** For a given group position remove the selector at the given position
  79146. * @param groupNb is the number of the group to remove the selector from
  79147. * @param selectorNb is the number of the selector within the group
  79148. */
  79149. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79150. /** For a given group position of correct type add a checkbox button
  79151. * @param groupNb is the number of the group to remove the selector from
  79152. * @param label is the label for the selector
  79153. * @param func is the function called when the Selector is checked
  79154. * @param checked is true when Selector is checked
  79155. */
  79156. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79157. /** For a given group position of correct type add a radio button
  79158. * @param groupNb is the number of the group to remove the selector from
  79159. * @param label is the label for the selector
  79160. * @param func is the function called when the Selector is checked
  79161. * @param checked is true when Selector is checked
  79162. */
  79163. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79164. /**
  79165. * For a given slider group add a slider
  79166. * @param groupNb is the number of the group to add the slider to
  79167. * @param label is the label for the Slider
  79168. * @param func is the function called when the Slider moves
  79169. * @param unit is a string describing the units used, eg degrees or metres
  79170. * @param min is the minimum value for the Slider
  79171. * @param max is the maximum value for the Slider
  79172. * @param value is the start value for the Slider between min and max
  79173. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79174. */
  79175. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79176. }
  79177. }
  79178. declare module BABYLON.GUI {
  79179. /**
  79180. * Class used to hold a the container for ScrollViewer
  79181. * @hidden
  79182. */
  79183. export class _ScrollViewerWindow extends Container {
  79184. parentClientWidth: number;
  79185. parentClientHeight: number;
  79186. private _freezeControls;
  79187. private _parentMeasure;
  79188. private _oldLeft;
  79189. private _oldTop;
  79190. get freezeControls(): boolean;
  79191. set freezeControls(value: boolean);
  79192. private _bucketWidth;
  79193. private _bucketHeight;
  79194. private _buckets;
  79195. private _bucketLen;
  79196. get bucketWidth(): number;
  79197. get bucketHeight(): number;
  79198. setBucketSizes(width: number, height: number): void;
  79199. private _useBuckets;
  79200. private _makeBuckets;
  79201. private _dispatchInBuckets;
  79202. private _updateMeasures;
  79203. private _updateChildrenMeasures;
  79204. private _restoreMeasures;
  79205. /**
  79206. * Creates a new ScrollViewerWindow
  79207. * @param name of ScrollViewerWindow
  79208. */
  79209. constructor(name?: string);
  79210. protected _getTypeName(): string;
  79211. /** @hidden */
  79212. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79213. /** @hidden */
  79214. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79215. private _scrollChildren;
  79216. private _scrollChildrenWithBuckets;
  79217. /** @hidden */
  79218. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79219. protected _postMeasure(): void;
  79220. }
  79221. }
  79222. declare module BABYLON.GUI {
  79223. /**
  79224. * Class used to create slider controls
  79225. */
  79226. export class ScrollBar extends BaseSlider {
  79227. name?: string | undefined;
  79228. private _background;
  79229. private _borderColor;
  79230. private _tempMeasure;
  79231. /** Gets or sets border color */
  79232. get borderColor(): string;
  79233. set borderColor(value: string);
  79234. /** Gets or sets background color */
  79235. get background(): string;
  79236. set background(value: string);
  79237. /**
  79238. * Creates a new Slider
  79239. * @param name defines the control name
  79240. */
  79241. constructor(name?: string | undefined);
  79242. protected _getTypeName(): string;
  79243. protected _getThumbThickness(): number;
  79244. _draw(context: CanvasRenderingContext2D): void;
  79245. private _first;
  79246. private _originX;
  79247. private _originY;
  79248. /** @hidden */
  79249. protected _updateValueFromPointer(x: number, y: number): void;
  79250. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79251. }
  79252. }
  79253. declare module BABYLON.GUI {
  79254. /**
  79255. * Class used to create slider controls
  79256. */
  79257. export class ImageScrollBar extends BaseSlider {
  79258. name?: string | undefined;
  79259. private _backgroundBaseImage;
  79260. private _backgroundImage;
  79261. private _thumbImage;
  79262. private _thumbBaseImage;
  79263. private _thumbLength;
  79264. private _thumbHeight;
  79265. private _barImageHeight;
  79266. private _tempMeasure;
  79267. /** Number of 90° rotation to apply on the images when in vertical mode */
  79268. num90RotationInVerticalMode: number;
  79269. /**
  79270. * Gets or sets the image used to render the background for horizontal bar
  79271. */
  79272. get backgroundImage(): Image;
  79273. set backgroundImage(value: Image);
  79274. /**
  79275. * Gets or sets the image used to render the thumb
  79276. */
  79277. get thumbImage(): Image;
  79278. set thumbImage(value: Image);
  79279. /**
  79280. * Gets or sets the length of the thumb
  79281. */
  79282. get thumbLength(): number;
  79283. set thumbLength(value: number);
  79284. /**
  79285. * Gets or sets the height of the thumb
  79286. */
  79287. get thumbHeight(): number;
  79288. set thumbHeight(value: number);
  79289. /**
  79290. * Gets or sets the height of the bar image
  79291. */
  79292. get barImageHeight(): number;
  79293. set barImageHeight(value: number);
  79294. /**
  79295. * Creates a new ImageScrollBar
  79296. * @param name defines the control name
  79297. */
  79298. constructor(name?: string | undefined);
  79299. protected _getTypeName(): string;
  79300. protected _getThumbThickness(): number;
  79301. _draw(context: CanvasRenderingContext2D): void;
  79302. private _first;
  79303. private _originX;
  79304. private _originY;
  79305. /** @hidden */
  79306. protected _updateValueFromPointer(x: number, y: number): void;
  79307. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79308. }
  79309. }
  79310. declare module BABYLON.GUI {
  79311. /**
  79312. * Class used to hold a viewer window and sliders in a grid
  79313. */
  79314. export class ScrollViewer extends Rectangle {
  79315. private _grid;
  79316. private _horizontalBarSpace;
  79317. private _verticalBarSpace;
  79318. private _dragSpace;
  79319. private _horizontalBar;
  79320. private _verticalBar;
  79321. private _barColor;
  79322. private _barBackground;
  79323. private _barImage;
  79324. private _horizontalBarImage;
  79325. private _verticalBarImage;
  79326. private _barBackgroundImage;
  79327. private _horizontalBarBackgroundImage;
  79328. private _verticalBarBackgroundImage;
  79329. private _barSize;
  79330. private _window;
  79331. private _pointerIsOver;
  79332. private _wheelPrecision;
  79333. private _onWheelObserver;
  79334. private _clientWidth;
  79335. private _clientHeight;
  79336. private _useImageBar;
  79337. private _thumbLength;
  79338. private _thumbHeight;
  79339. private _barImageHeight;
  79340. private _horizontalBarImageHeight;
  79341. private _verticalBarImageHeight;
  79342. private _oldWindowContentsWidth;
  79343. private _oldWindowContentsHeight;
  79344. /**
  79345. * Gets the horizontal scrollbar
  79346. */
  79347. get horizontalBar(): ScrollBar | ImageScrollBar;
  79348. /**
  79349. * Gets the vertical scrollbar
  79350. */
  79351. get verticalBar(): ScrollBar | ImageScrollBar;
  79352. /**
  79353. * Adds a new control to the current container
  79354. * @param control defines the control to add
  79355. * @returns the current container
  79356. */
  79357. addControl(control: BABYLON.Nullable<Control>): Container;
  79358. /**
  79359. * Removes a control from the current container
  79360. * @param control defines the control to remove
  79361. * @returns the current container
  79362. */
  79363. removeControl(control: Control): Container;
  79364. /** Gets the list of children */
  79365. get children(): Control[];
  79366. _flagDescendantsAsMatrixDirty(): void;
  79367. /**
  79368. * Freezes or unfreezes the controls in the window.
  79369. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79370. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79371. */
  79372. get freezeControls(): boolean;
  79373. set freezeControls(value: boolean);
  79374. /** Gets the bucket width */
  79375. get bucketWidth(): number;
  79376. /** Gets the bucket height */
  79377. get bucketHeight(): number;
  79378. /**
  79379. * Sets the bucket sizes.
  79380. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79381. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79382. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79383. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79384. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79385. * used), that's why it is not enabled by default.
  79386. * @param width width of the bucket
  79387. * @param height height of the bucket
  79388. */
  79389. setBucketSizes(width: number, height: number): void;
  79390. private _forceHorizontalBar;
  79391. private _forceVerticalBar;
  79392. /**
  79393. * Forces the horizontal scroll bar to be displayed
  79394. */
  79395. get forceHorizontalBar(): boolean;
  79396. set forceHorizontalBar(value: boolean);
  79397. /**
  79398. * Forces the vertical scroll bar to be displayed
  79399. */
  79400. get forceVerticalBar(): boolean;
  79401. set forceVerticalBar(value: boolean);
  79402. /**
  79403. * Creates a new ScrollViewer
  79404. * @param name of ScrollViewer
  79405. */
  79406. constructor(name?: string, isImageBased?: boolean);
  79407. /** Reset the scroll viewer window to initial size */
  79408. resetWindow(): void;
  79409. protected _getTypeName(): string;
  79410. private _buildClientSizes;
  79411. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79412. protected _postMeasure(): void;
  79413. /**
  79414. * Gets or sets the mouse wheel precision
  79415. * from 0 to 1 with a default value of 0.05
  79416. * */
  79417. get wheelPrecision(): number;
  79418. set wheelPrecision(value: number);
  79419. /** Gets or sets the scroll bar container background color */
  79420. get scrollBackground(): string;
  79421. set scrollBackground(color: string);
  79422. /** Gets or sets the bar color */
  79423. get barColor(): string;
  79424. set barColor(color: string);
  79425. /** Gets or sets the bar image */
  79426. get thumbImage(): Image;
  79427. set thumbImage(value: Image);
  79428. /** Gets or sets the horizontal bar image */
  79429. get horizontalThumbImage(): Image;
  79430. set horizontalThumbImage(value: Image);
  79431. /** Gets or sets the vertical bar image */
  79432. get verticalThumbImage(): Image;
  79433. set verticalThumbImage(value: Image);
  79434. /** Gets or sets the size of the bar */
  79435. get barSize(): number;
  79436. set barSize(value: number);
  79437. /** Gets or sets the length of the thumb */
  79438. get thumbLength(): number;
  79439. set thumbLength(value: number);
  79440. /** Gets or sets the height of the thumb */
  79441. get thumbHeight(): number;
  79442. set thumbHeight(value: number);
  79443. /** Gets or sets the height of the bar image */
  79444. get barImageHeight(): number;
  79445. set barImageHeight(value: number);
  79446. /** Gets or sets the height of the horizontal bar image */
  79447. get horizontalBarImageHeight(): number;
  79448. set horizontalBarImageHeight(value: number);
  79449. /** Gets or sets the height of the vertical bar image */
  79450. get verticalBarImageHeight(): number;
  79451. set verticalBarImageHeight(value: number);
  79452. /** Gets or sets the bar background */
  79453. get barBackground(): string;
  79454. set barBackground(color: string);
  79455. /** Gets or sets the bar background image */
  79456. get barImage(): Image;
  79457. set barImage(value: Image);
  79458. /** Gets or sets the horizontal bar background image */
  79459. get horizontalBarImage(): Image;
  79460. set horizontalBarImage(value: Image);
  79461. /** Gets or sets the vertical bar background image */
  79462. get verticalBarImage(): Image;
  79463. set verticalBarImage(value: Image);
  79464. private _setWindowPosition;
  79465. /** @hidden */
  79466. private _updateScroller;
  79467. _link(host: AdvancedDynamicTexture): void;
  79468. /** @hidden */
  79469. private _addBar;
  79470. /** @hidden */
  79471. private _attachWheel;
  79472. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79473. /** Releases associated resources */
  79474. dispose(): void;
  79475. }
  79476. }
  79477. declare module BABYLON.GUI {
  79478. /** Class used to render a grid */
  79479. export class DisplayGrid extends Control {
  79480. name?: string | undefined;
  79481. private _cellWidth;
  79482. private _cellHeight;
  79483. private _minorLineTickness;
  79484. private _minorLineColor;
  79485. private _majorLineTickness;
  79486. private _majorLineColor;
  79487. private _majorLineFrequency;
  79488. private _background;
  79489. private _displayMajorLines;
  79490. private _displayMinorLines;
  79491. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79492. get displayMinorLines(): boolean;
  79493. set displayMinorLines(value: boolean);
  79494. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79495. get displayMajorLines(): boolean;
  79496. set displayMajorLines(value: boolean);
  79497. /** Gets or sets background color (Black by default) */
  79498. get background(): string;
  79499. set background(value: string);
  79500. /** Gets or sets the width of each cell (20 by default) */
  79501. get cellWidth(): number;
  79502. set cellWidth(value: number);
  79503. /** Gets or sets the height of each cell (20 by default) */
  79504. get cellHeight(): number;
  79505. set cellHeight(value: number);
  79506. /** Gets or sets the tickness of minor lines (1 by default) */
  79507. get minorLineTickness(): number;
  79508. set minorLineTickness(value: number);
  79509. /** Gets or sets the color of minor lines (DarkGray by default) */
  79510. get minorLineColor(): string;
  79511. set minorLineColor(value: string);
  79512. /** Gets or sets the tickness of major lines (2 by default) */
  79513. get majorLineTickness(): number;
  79514. set majorLineTickness(value: number);
  79515. /** Gets or sets the color of major lines (White by default) */
  79516. get majorLineColor(): string;
  79517. set majorLineColor(value: string);
  79518. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79519. get majorLineFrequency(): number;
  79520. set majorLineFrequency(value: number);
  79521. /**
  79522. * Creates a new GridDisplayRectangle
  79523. * @param name defines the control name
  79524. */
  79525. constructor(name?: string | undefined);
  79526. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79527. protected _getTypeName(): string;
  79528. }
  79529. }
  79530. declare module BABYLON.GUI {
  79531. /**
  79532. * Class used to create slider controls based on images
  79533. */
  79534. export class ImageBasedSlider extends BaseSlider {
  79535. name?: string | undefined;
  79536. private _backgroundImage;
  79537. private _thumbImage;
  79538. private _valueBarImage;
  79539. private _tempMeasure;
  79540. get displayThumb(): boolean;
  79541. set displayThumb(value: boolean);
  79542. /**
  79543. * Gets or sets the image used to render the background
  79544. */
  79545. get backgroundImage(): Image;
  79546. set backgroundImage(value: Image);
  79547. /**
  79548. * Gets or sets the image used to render the value bar
  79549. */
  79550. get valueBarImage(): Image;
  79551. set valueBarImage(value: Image);
  79552. /**
  79553. * Gets or sets the image used to render the thumb
  79554. */
  79555. get thumbImage(): Image;
  79556. set thumbImage(value: Image);
  79557. /**
  79558. * Creates a new ImageBasedSlider
  79559. * @param name defines the control name
  79560. */
  79561. constructor(name?: string | undefined);
  79562. protected _getTypeName(): string;
  79563. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79564. }
  79565. }
  79566. declare module BABYLON.GUI {
  79567. /**
  79568. * Forcing an export so that this code will execute
  79569. * @hidden
  79570. */
  79571. const name = "Statics";
  79572. }
  79573. declare module BABYLON.GUI {
  79574. /**
  79575. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79576. */
  79577. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79578. /**
  79579. * Define the instrumented AdvancedDynamicTexture.
  79580. */
  79581. texture: AdvancedDynamicTexture;
  79582. private _captureRenderTime;
  79583. private _renderTime;
  79584. private _captureLayoutTime;
  79585. private _layoutTime;
  79586. private _onBeginRenderObserver;
  79587. private _onEndRenderObserver;
  79588. private _onBeginLayoutObserver;
  79589. private _onEndLayoutObserver;
  79590. /**
  79591. * Gets the perf counter used to capture render time
  79592. */
  79593. get renderTimeCounter(): BABYLON.PerfCounter;
  79594. /**
  79595. * Gets the perf counter used to capture layout time
  79596. */
  79597. get layoutTimeCounter(): BABYLON.PerfCounter;
  79598. /**
  79599. * Enable or disable the render time capture
  79600. */
  79601. get captureRenderTime(): boolean;
  79602. set captureRenderTime(value: boolean);
  79603. /**
  79604. * Enable or disable the layout time capture
  79605. */
  79606. get captureLayoutTime(): boolean;
  79607. set captureLayoutTime(value: boolean);
  79608. /**
  79609. * Instantiates a new advanced dynamic texture instrumentation.
  79610. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79611. * @param texture Defines the AdvancedDynamicTexture to instrument
  79612. */
  79613. constructor(
  79614. /**
  79615. * Define the instrumented AdvancedDynamicTexture.
  79616. */
  79617. texture: AdvancedDynamicTexture);
  79618. /**
  79619. * Dispose and release associated resources.
  79620. */
  79621. dispose(): void;
  79622. }
  79623. }
  79624. declare module BABYLON.GUI {
  79625. /**
  79626. * Class used to load GUI via XML.
  79627. */
  79628. export class XmlLoader {
  79629. private _nodes;
  79630. private _nodeTypes;
  79631. private _isLoaded;
  79632. private _objectAttributes;
  79633. private _parentClass;
  79634. /**
  79635. * Create a new xml loader
  79636. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79637. */
  79638. constructor(parentClass?: null);
  79639. private _getChainElement;
  79640. private _getClassAttribute;
  79641. private _createGuiElement;
  79642. private _parseGrid;
  79643. private _parseElement;
  79644. private _prepareSourceElement;
  79645. private _parseElementsFromSource;
  79646. private _parseXml;
  79647. /**
  79648. * Gets if the loading has finished.
  79649. * @returns whether the loading has finished or not
  79650. */
  79651. isLoaded(): boolean;
  79652. /**
  79653. * Gets a loaded node / control by id.
  79654. * @param id the Controls id set in the xml
  79655. * @returns element of type Control
  79656. */
  79657. getNodeById(id: string): any;
  79658. /**
  79659. * Gets all loaded nodes / controls
  79660. * @returns Array of controls
  79661. */
  79662. getNodes(): any;
  79663. /**
  79664. * Initiates the xml layout loading
  79665. * @param xmlFile defines the xml layout to load
  79666. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79667. * @param callback defines the callback called on layout load.
  79668. */
  79669. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79670. }
  79671. }
  79672. declare module BABYLON.GUI {
  79673. /**
  79674. * Class used to create containers for controls
  79675. */
  79676. export class Container3D extends Control3D {
  79677. private _blockLayout;
  79678. /**
  79679. * Gets the list of child controls
  79680. */
  79681. protected _children: Control3D[];
  79682. /**
  79683. * Gets the list of child controls
  79684. */
  79685. get children(): Array<Control3D>;
  79686. /**
  79687. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79688. * This is helpful to optimize layout operation when adding multiple children in a row
  79689. */
  79690. get blockLayout(): boolean;
  79691. set blockLayout(value: boolean);
  79692. /**
  79693. * Creates a new container
  79694. * @param name defines the container name
  79695. */
  79696. constructor(name?: string);
  79697. /**
  79698. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79699. * @returns the current container
  79700. */
  79701. updateLayout(): Container3D;
  79702. /**
  79703. * Gets a boolean indicating if the given control is in the children of this control
  79704. * @param control defines the control to check
  79705. * @returns true if the control is in the child list
  79706. */
  79707. containsControl(control: Control3D): boolean;
  79708. /**
  79709. * Adds a control to the children of this control
  79710. * @param control defines the control to add
  79711. * @returns the current container
  79712. */
  79713. addControl(control: Control3D): Container3D;
  79714. /**
  79715. * This function will be called everytime a new control is added
  79716. */
  79717. protected _arrangeChildren(): void;
  79718. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79719. /**
  79720. * Removes a control from the children of this control
  79721. * @param control defines the control to remove
  79722. * @returns the current container
  79723. */
  79724. removeControl(control: Control3D): Container3D;
  79725. protected _getTypeName(): string;
  79726. /**
  79727. * Releases all associated resources
  79728. */
  79729. dispose(): void;
  79730. /** Control rotation will remain unchanged */
  79731. static readonly UNSET_ORIENTATION: number;
  79732. /** Control will rotate to make it look at sphere central axis */
  79733. static readonly FACEORIGIN_ORIENTATION: number;
  79734. /** Control will rotate to make it look back at sphere central axis */
  79735. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79736. /** Control will rotate to look at z axis (0, 0, 1) */
  79737. static readonly FACEFORWARD_ORIENTATION: number;
  79738. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79739. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79740. }
  79741. }
  79742. declare module BABYLON.GUI {
  79743. /**
  79744. * Class used to manage 3D user interface
  79745. * @see https://doc.babylonjs.com/how_to/gui3d
  79746. */
  79747. export class GUI3DManager implements BABYLON.IDisposable {
  79748. private _scene;
  79749. private _sceneDisposeObserver;
  79750. private _utilityLayer;
  79751. private _rootContainer;
  79752. private _pointerObserver;
  79753. private _pointerOutObserver;
  79754. /** @hidden */
  79755. _lastPickedControl: Control3D;
  79756. /** @hidden */
  79757. _lastControlOver: {
  79758. [pointerId: number]: Control3D;
  79759. };
  79760. /** @hidden */
  79761. _lastControlDown: {
  79762. [pointerId: number]: Control3D;
  79763. };
  79764. /**
  79765. * BABYLON.Observable raised when the point picked by the pointer events changed
  79766. */
  79767. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79768. /** @hidden */
  79769. _sharedMaterials: {
  79770. [key: string]: BABYLON.Material;
  79771. };
  79772. /** Gets the hosting scene */
  79773. get scene(): BABYLON.Scene;
  79774. /** Gets associated utility layer */
  79775. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79776. /**
  79777. * Creates a new GUI3DManager
  79778. * @param scene
  79779. */
  79780. constructor(scene?: BABYLON.Scene);
  79781. private _handlePointerOut;
  79782. private _doPicking;
  79783. /**
  79784. * Gets the root container
  79785. */
  79786. get rootContainer(): Container3D;
  79787. /**
  79788. * Gets a boolean indicating if the given control is in the root child list
  79789. * @param control defines the control to check
  79790. * @returns true if the control is in the root child list
  79791. */
  79792. containsControl(control: Control3D): boolean;
  79793. /**
  79794. * Adds a control to the root child list
  79795. * @param control defines the control to add
  79796. * @returns the current manager
  79797. */
  79798. addControl(control: Control3D): GUI3DManager;
  79799. /**
  79800. * Removes a control from the root child list
  79801. * @param control defines the control to remove
  79802. * @returns the current container
  79803. */
  79804. removeControl(control: Control3D): GUI3DManager;
  79805. /**
  79806. * Releases all associated resources
  79807. */
  79808. dispose(): void;
  79809. }
  79810. }
  79811. declare module BABYLON.GUI {
  79812. /**
  79813. * Class used to transport BABYLON.Vector3 information for pointer events
  79814. */
  79815. export class Vector3WithInfo extends BABYLON.Vector3 {
  79816. /** defines the current mouse button index */
  79817. buttonIndex: number;
  79818. /**
  79819. * Creates a new Vector3WithInfo
  79820. * @param source defines the vector3 data to transport
  79821. * @param buttonIndex defines the current mouse button index
  79822. */
  79823. constructor(source: BABYLON.Vector3,
  79824. /** defines the current mouse button index */
  79825. buttonIndex?: number);
  79826. }
  79827. }
  79828. declare module BABYLON.GUI {
  79829. /**
  79830. * Class used as base class for controls
  79831. */
  79832. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79833. /** Defines the control name */
  79834. name?: string | undefined;
  79835. /** @hidden */
  79836. _host: GUI3DManager;
  79837. private _node;
  79838. private _downCount;
  79839. private _enterCount;
  79840. private _downPointerIds;
  79841. private _isVisible;
  79842. /** Gets or sets the control position in world space */
  79843. get position(): BABYLON.Vector3;
  79844. set position(value: BABYLON.Vector3);
  79845. /** Gets or sets the control scaling in world space */
  79846. get scaling(): BABYLON.Vector3;
  79847. set scaling(value: BABYLON.Vector3);
  79848. /** Callback used to start pointer enter animation */
  79849. pointerEnterAnimation: () => void;
  79850. /** Callback used to start pointer out animation */
  79851. pointerOutAnimation: () => void;
  79852. /** Callback used to start pointer down animation */
  79853. pointerDownAnimation: () => void;
  79854. /** Callback used to start pointer up animation */
  79855. pointerUpAnimation: () => void;
  79856. /**
  79857. * An event triggered when the pointer move over the control
  79858. */
  79859. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79860. /**
  79861. * An event triggered when the pointer move out of the control
  79862. */
  79863. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79864. /**
  79865. * An event triggered when the pointer taps the control
  79866. */
  79867. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79868. /**
  79869. * An event triggered when pointer is up
  79870. */
  79871. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79872. /**
  79873. * An event triggered when a control is clicked on (with a mouse)
  79874. */
  79875. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79876. /**
  79877. * An event triggered when pointer enters the control
  79878. */
  79879. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79880. /**
  79881. * Gets or sets the parent container
  79882. */
  79883. parent: BABYLON.Nullable<Container3D>;
  79884. private _behaviors;
  79885. /**
  79886. * Gets the list of attached behaviors
  79887. * @see https://doc.babylonjs.com/features/behaviour
  79888. */
  79889. get behaviors(): BABYLON.Behavior<Control3D>[];
  79890. /**
  79891. * Attach a behavior to the control
  79892. * @see https://doc.babylonjs.com/features/behaviour
  79893. * @param behavior defines the behavior to attach
  79894. * @returns the current control
  79895. */
  79896. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79897. /**
  79898. * Remove an attached behavior
  79899. * @see https://doc.babylonjs.com/features/behaviour
  79900. * @param behavior defines the behavior to attach
  79901. * @returns the current control
  79902. */
  79903. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79904. /**
  79905. * Gets an attached behavior by name
  79906. * @param name defines the name of the behavior to look for
  79907. * @see https://doc.babylonjs.com/features/behaviour
  79908. * @returns null if behavior was not found else the requested behavior
  79909. */
  79910. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79911. /** Gets or sets a boolean indicating if the control is visible */
  79912. get isVisible(): boolean;
  79913. set isVisible(value: boolean);
  79914. /**
  79915. * Creates a new control
  79916. * @param name defines the control name
  79917. */
  79918. constructor(
  79919. /** Defines the control name */
  79920. name?: string | undefined);
  79921. /**
  79922. * Gets a string representing the class name
  79923. */
  79924. get typeName(): string;
  79925. /**
  79926. * Get the current class name of the control.
  79927. * @returns current class name
  79928. */
  79929. getClassName(): string;
  79930. protected _getTypeName(): string;
  79931. /**
  79932. * Gets the transform node used by this control
  79933. */
  79934. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79935. /**
  79936. * Gets the mesh used to render this control
  79937. */
  79938. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79939. /**
  79940. * Link the control as child of the given node
  79941. * @param node defines the node to link to. Use null to unlink the control
  79942. * @returns the current control
  79943. */
  79944. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79945. /** @hidden **/
  79946. _prepareNode(scene: BABYLON.Scene): void;
  79947. /**
  79948. * Node creation.
  79949. * Can be overriden by children
  79950. * @param scene defines the scene where the node must be attached
  79951. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79952. */
  79953. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79954. /**
  79955. * Affect a material to the given mesh
  79956. * @param mesh defines the mesh which will represent the control
  79957. */
  79958. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79959. /** @hidden */
  79960. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79961. /** @hidden */
  79962. _onPointerEnter(target: Control3D): boolean;
  79963. /** @hidden */
  79964. _onPointerOut(target: Control3D): void;
  79965. /** @hidden */
  79966. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79967. /** @hidden */
  79968. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79969. /** @hidden */
  79970. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79971. /** @hidden */
  79972. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79973. /** @hidden */
  79974. _disposeNode(): void;
  79975. /**
  79976. * Releases all associated resources
  79977. */
  79978. dispose(): void;
  79979. }
  79980. }
  79981. declare module BABYLON.GUI {
  79982. /**
  79983. * Class used as a root to all buttons
  79984. */
  79985. export class AbstractButton3D extends Control3D {
  79986. /**
  79987. * Creates a new button
  79988. * @param name defines the control name
  79989. */
  79990. constructor(name?: string);
  79991. protected _getTypeName(): string;
  79992. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79993. }
  79994. }
  79995. declare module BABYLON.GUI {
  79996. /**
  79997. * Class used to create a button in 3D
  79998. */
  79999. export class Button3D extends AbstractButton3D {
  80000. /** @hidden */
  80001. protected _currentMaterial: BABYLON.Material;
  80002. private _facadeTexture;
  80003. private _content;
  80004. private _contentResolution;
  80005. private _contentScaleRatio;
  80006. /**
  80007. * Gets or sets the texture resolution used to render content (512 by default)
  80008. */
  80009. get contentResolution(): BABYLON.int;
  80010. set contentResolution(value: BABYLON.int);
  80011. /**
  80012. * Gets or sets the texture scale ratio used to render content (2 by default)
  80013. */
  80014. get contentScaleRatio(): number;
  80015. set contentScaleRatio(value: number);
  80016. protected _disposeFacadeTexture(): void;
  80017. protected _resetContent(): void;
  80018. /**
  80019. * Creates a new button
  80020. * @param name defines the control name
  80021. */
  80022. constructor(name?: string);
  80023. /**
  80024. * Gets or sets the GUI 2D content used to display the button's facade
  80025. */
  80026. get content(): Control;
  80027. set content(value: Control);
  80028. /**
  80029. * Apply the facade texture (created from the content property).
  80030. * This function can be overloaded by child classes
  80031. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80032. */
  80033. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80034. protected _getTypeName(): string;
  80035. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80036. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80037. /**
  80038. * Releases all associated resources
  80039. */
  80040. dispose(): void;
  80041. }
  80042. }
  80043. declare module BABYLON.GUI {
  80044. /**
  80045. * Abstract class used to create a container panel deployed on the surface of a volume
  80046. */
  80047. export abstract class VolumeBasedPanel extends Container3D {
  80048. private _columns;
  80049. private _rows;
  80050. private _rowThenColum;
  80051. private _orientation;
  80052. protected _cellWidth: number;
  80053. protected _cellHeight: number;
  80054. /**
  80055. * Gets or sets the distance between elements
  80056. */
  80057. margin: number;
  80058. /**
  80059. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80060. * | Value | Type | Description |
  80061. * | ----- | ----------------------------------- | ----------- |
  80062. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80063. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80064. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80065. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80066. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80067. */
  80068. get orientation(): number;
  80069. set orientation(value: number);
  80070. /**
  80071. * Gets or sets the number of columns requested (10 by default).
  80072. * The panel will automatically compute the number of rows based on number of child controls.
  80073. */
  80074. get columns(): BABYLON.int;
  80075. set columns(value: BABYLON.int);
  80076. /**
  80077. * Gets or sets a the number of rows requested.
  80078. * The panel will automatically compute the number of columns based on number of child controls.
  80079. */
  80080. get rows(): BABYLON.int;
  80081. set rows(value: BABYLON.int);
  80082. /**
  80083. * Creates new VolumeBasedPanel
  80084. */
  80085. constructor();
  80086. protected _arrangeChildren(): void;
  80087. /** Child classes must implement this function to provide correct control positioning */
  80088. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80089. /** Child classes can implement this function to provide additional processing */
  80090. protected _finalProcessing(): void;
  80091. }
  80092. }
  80093. declare module BABYLON.GUI {
  80094. /**
  80095. * Class used to create a container panel deployed on the surface of a cylinder
  80096. */
  80097. export class CylinderPanel extends VolumeBasedPanel {
  80098. private _radius;
  80099. /**
  80100. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80101. */
  80102. get radius(): BABYLON.float;
  80103. set radius(value: BABYLON.float);
  80104. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80105. private _cylindricalMapping;
  80106. }
  80107. }
  80108. declare module BABYLON.GUI {
  80109. /** @hidden */
  80110. export var fluentVertexShader: {
  80111. name: string;
  80112. shader: string;
  80113. };
  80114. }
  80115. declare module BABYLON.GUI {
  80116. /** @hidden */
  80117. export var fluentPixelShader: {
  80118. name: string;
  80119. shader: string;
  80120. };
  80121. }
  80122. declare module BABYLON.GUI {
  80123. /** @hidden */
  80124. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80125. INNERGLOW: boolean;
  80126. BORDER: boolean;
  80127. HOVERLIGHT: boolean;
  80128. TEXTURE: boolean;
  80129. constructor();
  80130. }
  80131. /**
  80132. * Class used to render controls with fluent desgin
  80133. */
  80134. export class FluentMaterial extends BABYLON.PushMaterial {
  80135. /**
  80136. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80137. */
  80138. innerGlowColorIntensity: number;
  80139. /**
  80140. * Gets or sets the inner glow color (white by default)
  80141. */
  80142. innerGlowColor: BABYLON.Color3;
  80143. /**
  80144. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80145. */
  80146. albedoColor: BABYLON.Color3;
  80147. /**
  80148. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80149. */
  80150. renderBorders: boolean;
  80151. /**
  80152. * Gets or sets border width (default is 0.5)
  80153. */
  80154. borderWidth: number;
  80155. /**
  80156. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80157. */
  80158. edgeSmoothingValue: number;
  80159. /**
  80160. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80161. */
  80162. borderMinValue: number;
  80163. /**
  80164. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80165. */
  80166. renderHoverLight: boolean;
  80167. /**
  80168. * Gets or sets the radius used to render the hover light (default is 1.0)
  80169. */
  80170. hoverRadius: number;
  80171. /**
  80172. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80173. */
  80174. hoverColor: BABYLON.Color4;
  80175. /**
  80176. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80177. */
  80178. hoverPosition: BABYLON.Vector3;
  80179. private _albedoTexture;
  80180. /** Gets or sets the texture to use for albedo color */
  80181. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80182. /**
  80183. * Creates a new Fluent material
  80184. * @param name defines the name of the material
  80185. * @param scene defines the hosting scene
  80186. */
  80187. constructor(name: string, scene: BABYLON.Scene);
  80188. needAlphaBlending(): boolean;
  80189. needAlphaTesting(): boolean;
  80190. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80191. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80192. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80193. getActiveTextures(): BABYLON.BaseTexture[];
  80194. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80195. dispose(forceDisposeEffect?: boolean): void;
  80196. clone(name: string): FluentMaterial;
  80197. serialize(): any;
  80198. getClassName(): string;
  80199. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80200. }
  80201. }
  80202. declare module BABYLON.GUI {
  80203. /**
  80204. * Class used to create a holographic button in 3D
  80205. */
  80206. export class HolographicButton extends Button3D {
  80207. private _backPlate;
  80208. private _textPlate;
  80209. private _frontPlate;
  80210. private _text;
  80211. private _imageUrl;
  80212. private _shareMaterials;
  80213. private _frontMaterial;
  80214. private _backMaterial;
  80215. private _plateMaterial;
  80216. private _pickedPointObserver;
  80217. private _tooltipFade;
  80218. private _tooltipTextBlock;
  80219. private _tooltipTexture;
  80220. private _tooltipMesh;
  80221. private _tooltipHoverObserver;
  80222. private _tooltipOutObserver;
  80223. private _disposeTooltip;
  80224. /**
  80225. * Rendering ground id of all the mesh in the button
  80226. */
  80227. set renderingGroupId(id: number);
  80228. get renderingGroupId(): number;
  80229. /**
  80230. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80231. */
  80232. set tooltipText(text: BABYLON.Nullable<string>);
  80233. get tooltipText(): BABYLON.Nullable<string>;
  80234. /**
  80235. * Gets or sets text for the button
  80236. */
  80237. get text(): string;
  80238. set text(value: string);
  80239. /**
  80240. * Gets or sets the image url for the button
  80241. */
  80242. get imageUrl(): string;
  80243. set imageUrl(value: string);
  80244. /**
  80245. * Gets the back material used by this button
  80246. */
  80247. get backMaterial(): FluentMaterial;
  80248. /**
  80249. * Gets the front material used by this button
  80250. */
  80251. get frontMaterial(): FluentMaterial;
  80252. /**
  80253. * Gets the plate material used by this button
  80254. */
  80255. get plateMaterial(): BABYLON.StandardMaterial;
  80256. /**
  80257. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80258. */
  80259. get shareMaterials(): boolean;
  80260. /**
  80261. * Creates a new button
  80262. * @param name defines the control name
  80263. */
  80264. constructor(name?: string, shareMaterials?: boolean);
  80265. protected _getTypeName(): string;
  80266. private _rebuildContent;
  80267. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80268. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80269. private _createBackMaterial;
  80270. private _createFrontMaterial;
  80271. private _createPlateMaterial;
  80272. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80273. /**
  80274. * Releases all associated resources
  80275. */
  80276. dispose(): void;
  80277. }
  80278. }
  80279. declare module BABYLON.GUI {
  80280. /**
  80281. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80282. */
  80283. export class MeshButton3D extends Button3D {
  80284. /** @hidden */
  80285. protected _currentMesh: BABYLON.Mesh;
  80286. /**
  80287. * Creates a new 3D button based on a mesh
  80288. * @param mesh mesh to become a 3D button
  80289. * @param name defines the control name
  80290. */
  80291. constructor(mesh: BABYLON.Mesh, name?: string);
  80292. protected _getTypeName(): string;
  80293. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80294. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80295. }
  80296. }
  80297. declare module BABYLON.GUI {
  80298. /**
  80299. * Class used to create a container panel deployed on the surface of a plane
  80300. */
  80301. export class PlanePanel extends VolumeBasedPanel {
  80302. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80303. }
  80304. }
  80305. declare module BABYLON.GUI {
  80306. /**
  80307. * Class used to create a container panel where items get randomized planar mapping
  80308. */
  80309. export class ScatterPanel extends VolumeBasedPanel {
  80310. private _iteration;
  80311. /**
  80312. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80313. */
  80314. get iteration(): BABYLON.float;
  80315. set iteration(value: BABYLON.float);
  80316. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80317. private _scatterMapping;
  80318. protected _finalProcessing(): void;
  80319. }
  80320. }
  80321. declare module BABYLON.GUI {
  80322. /**
  80323. * Class used to create a container panel deployed on the surface of a sphere
  80324. */
  80325. export class SpherePanel extends VolumeBasedPanel {
  80326. private _radius;
  80327. /**
  80328. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80329. */
  80330. get radius(): BABYLON.float;
  80331. set radius(value: BABYLON.float);
  80332. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80333. private _sphericalMapping;
  80334. }
  80335. }
  80336. declare module BABYLON.GUI {
  80337. /**
  80338. * Class used to create a stack panel in 3D on XY plane
  80339. */
  80340. export class StackPanel3D extends Container3D {
  80341. private _isVertical;
  80342. /**
  80343. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80344. */
  80345. get isVertical(): boolean;
  80346. set isVertical(value: boolean);
  80347. /**
  80348. * Gets or sets the distance between elements
  80349. */
  80350. margin: number;
  80351. /**
  80352. * Creates new StackPanel
  80353. * @param isVertical
  80354. */
  80355. constructor(isVertical?: boolean);
  80356. protected _arrangeChildren(): void;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /**
  80361. * Configuration for glTF validation
  80362. */
  80363. export interface IGLTFValidationConfiguration {
  80364. /**
  80365. * The url of the glTF validator.
  80366. */
  80367. url: string;
  80368. }
  80369. /**
  80370. * glTF validation
  80371. */
  80372. export class GLTFValidation {
  80373. /**
  80374. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80375. */
  80376. static Configuration: IGLTFValidationConfiguration;
  80377. private static _LoadScriptPromise;
  80378. /**
  80379. * Validate a glTF asset using the glTF-Validator.
  80380. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80381. * @param rootUrl The root url for the glTF
  80382. * @param fileName The file name for the glTF
  80383. * @param getExternalResource The callback to get external resources for the glTF validator
  80384. * @returns A promise that resolves with the glTF validation results once complete
  80385. */
  80386. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80387. }
  80388. }
  80389. declare module BABYLON {
  80390. /**
  80391. * Mode that determines the coordinate system to use.
  80392. */
  80393. export enum GLTFLoaderCoordinateSystemMode {
  80394. /**
  80395. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80396. */
  80397. AUTO = 0,
  80398. /**
  80399. * Sets the useRightHandedSystem flag on the scene.
  80400. */
  80401. FORCE_RIGHT_HANDED = 1
  80402. }
  80403. /**
  80404. * Mode that determines what animations will start.
  80405. */
  80406. export enum GLTFLoaderAnimationStartMode {
  80407. /**
  80408. * No animation will start.
  80409. */
  80410. NONE = 0,
  80411. /**
  80412. * The first animation will start.
  80413. */
  80414. FIRST = 1,
  80415. /**
  80416. * All animations will start.
  80417. */
  80418. ALL = 2
  80419. }
  80420. /**
  80421. * Interface that contains the data for the glTF asset.
  80422. */
  80423. export interface IGLTFLoaderData {
  80424. /**
  80425. * The object that represents the glTF JSON.
  80426. */
  80427. json: Object;
  80428. /**
  80429. * The BIN chunk of a binary glTF.
  80430. */
  80431. bin: Nullable<IDataBuffer>;
  80432. }
  80433. /**
  80434. * Interface for extending the loader.
  80435. */
  80436. export interface IGLTFLoaderExtension {
  80437. /**
  80438. * The name of this extension.
  80439. */
  80440. readonly name: string;
  80441. /**
  80442. * Defines whether this extension is enabled.
  80443. */
  80444. enabled: boolean;
  80445. /**
  80446. * Defines the order of this extension.
  80447. * The loader sorts the extensions using these values when loading.
  80448. */
  80449. order?: number;
  80450. }
  80451. /**
  80452. * Loader state.
  80453. */
  80454. export enum GLTFLoaderState {
  80455. /**
  80456. * The asset is loading.
  80457. */
  80458. LOADING = 0,
  80459. /**
  80460. * The asset is ready for rendering.
  80461. */
  80462. READY = 1,
  80463. /**
  80464. * The asset is completely loaded.
  80465. */
  80466. COMPLETE = 2
  80467. }
  80468. /** @hidden */
  80469. export interface IImportMeshAsyncOutput {
  80470. meshes: AbstractMesh[];
  80471. particleSystems: IParticleSystem[];
  80472. skeletons: Skeleton[];
  80473. animationGroups: AnimationGroup[];
  80474. lights: Light[];
  80475. transformNodes: TransformNode[];
  80476. }
  80477. /** @hidden */
  80478. export interface IGLTFLoader extends IDisposable {
  80479. readonly state: Nullable<GLTFLoaderState>;
  80480. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80481. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80482. }
  80483. /**
  80484. * File loader for loading glTF files into a scene.
  80485. */
  80486. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80487. /** @hidden */
  80488. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80489. /** @hidden */
  80490. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80491. /**
  80492. * Raised when the asset has been parsed
  80493. */
  80494. onParsedObservable: Observable<IGLTFLoaderData>;
  80495. private _onParsedObserver;
  80496. /**
  80497. * Raised when the asset has been parsed
  80498. */
  80499. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80500. /**
  80501. * 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.
  80502. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80503. * Defaults to true.
  80504. * @hidden
  80505. */
  80506. static IncrementalLoading: boolean;
  80507. /**
  80508. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80509. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80510. * @hidden
  80511. */
  80512. static HomogeneousCoordinates: boolean;
  80513. /**
  80514. * The coordinate system mode. Defaults to AUTO.
  80515. */
  80516. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80517. /**
  80518. * The animation start mode. Defaults to FIRST.
  80519. */
  80520. animationStartMode: GLTFLoaderAnimationStartMode;
  80521. /**
  80522. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80523. */
  80524. compileMaterials: boolean;
  80525. /**
  80526. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80527. */
  80528. useClipPlane: boolean;
  80529. /**
  80530. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80531. */
  80532. compileShadowGenerators: boolean;
  80533. /**
  80534. * Defines if the Alpha blended materials are only applied as coverage.
  80535. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80536. * If true, no extra effects are applied to transparent pixels.
  80537. */
  80538. transparencyAsCoverage: boolean;
  80539. /**
  80540. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80541. * Enabling will disable offline support and glTF validator.
  80542. * Defaults to false.
  80543. */
  80544. useRangeRequests: boolean;
  80545. /**
  80546. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80547. */
  80548. createInstances: boolean;
  80549. /**
  80550. * 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.
  80551. */
  80552. alwaysComputeBoundingBox: boolean;
  80553. /**
  80554. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80555. */
  80556. loadAllMaterials: boolean;
  80557. /**
  80558. * Function called before loading a url referenced by the asset.
  80559. */
  80560. preprocessUrlAsync: (url: string) => Promise<string>;
  80561. /**
  80562. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80563. * 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, ...)
  80564. */
  80565. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80566. private _onMeshLoadedObserver;
  80567. /**
  80568. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80569. * 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, ...)
  80570. */
  80571. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80572. /**
  80573. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80574. */
  80575. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80576. private _onTextureLoadedObserver;
  80577. /**
  80578. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80579. */
  80580. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80581. /**
  80582. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80583. */
  80584. readonly onMaterialLoadedObservable: Observable<Material>;
  80585. private _onMaterialLoadedObserver;
  80586. /**
  80587. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80588. */
  80589. set onMaterialLoaded(callback: (material: Material) => void);
  80590. /**
  80591. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80592. */
  80593. readonly onCameraLoadedObservable: Observable<Camera>;
  80594. private _onCameraLoadedObserver;
  80595. /**
  80596. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80597. */
  80598. set onCameraLoaded(callback: (camera: Camera) => void);
  80599. /**
  80600. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80601. * For assets with LODs, raised when all of the LODs are complete.
  80602. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80603. */
  80604. readonly onCompleteObservable: Observable<void>;
  80605. private _onCompleteObserver;
  80606. /**
  80607. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80608. * For assets with LODs, raised when all of the LODs are complete.
  80609. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80610. */
  80611. set onComplete(callback: () => void);
  80612. /**
  80613. * Observable raised when an error occurs.
  80614. */
  80615. readonly onErrorObservable: Observable<any>;
  80616. private _onErrorObserver;
  80617. /**
  80618. * Callback raised when an error occurs.
  80619. */
  80620. set onError(callback: (reason: any) => void);
  80621. /**
  80622. * Observable raised after the loader is disposed.
  80623. */
  80624. readonly onDisposeObservable: Observable<void>;
  80625. private _onDisposeObserver;
  80626. /**
  80627. * Callback raised after the loader is disposed.
  80628. */
  80629. set onDispose(callback: () => void);
  80630. /**
  80631. * Observable raised after a loader extension is created.
  80632. * Set additional options for a loader extension in this event.
  80633. */
  80634. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80635. private _onExtensionLoadedObserver;
  80636. /**
  80637. * Callback raised after a loader extension is created.
  80638. */
  80639. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80640. /**
  80641. * Defines if the loader logging is enabled.
  80642. */
  80643. get loggingEnabled(): boolean;
  80644. set loggingEnabled(value: boolean);
  80645. /**
  80646. * Defines if the loader should capture performance counters.
  80647. */
  80648. get capturePerformanceCounters(): boolean;
  80649. set capturePerformanceCounters(value: boolean);
  80650. /**
  80651. * Defines if the loader should validate the asset.
  80652. */
  80653. validate: boolean;
  80654. /**
  80655. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80656. */
  80657. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80658. private _onValidatedObserver;
  80659. /**
  80660. * Callback raised after a loader extension is created.
  80661. */
  80662. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80663. private _loader;
  80664. private _progressCallback?;
  80665. private _requests;
  80666. private static magicBase64Encoded;
  80667. /**
  80668. * Name of the loader ("gltf")
  80669. */
  80670. name: string;
  80671. /** @hidden */
  80672. extensions: ISceneLoaderPluginExtensions;
  80673. /**
  80674. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80675. */
  80676. dispose(): void;
  80677. /** @hidden */
  80678. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80679. /** @hidden */
  80680. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80681. /** @hidden */
  80682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80683. meshes: AbstractMesh[];
  80684. particleSystems: IParticleSystem[];
  80685. skeletons: Skeleton[];
  80686. animationGroups: AnimationGroup[];
  80687. }>;
  80688. /** @hidden */
  80689. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80690. /** @hidden */
  80691. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80692. /** @hidden */
  80693. canDirectLoad(data: string): boolean;
  80694. /** @hidden */
  80695. directLoad(scene: Scene, data: string): Promise<any>;
  80696. /**
  80697. * The callback that allows custom handling of the root url based on the response url.
  80698. * @param rootUrl the original root url
  80699. * @param responseURL the response url if available
  80700. * @returns the new root url
  80701. */
  80702. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80703. /** @hidden */
  80704. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80705. /**
  80706. * The loader state or null if the loader is not active.
  80707. */
  80708. get loaderState(): Nullable<GLTFLoaderState>;
  80709. /**
  80710. * Returns a promise that resolves when the asset is completely loaded.
  80711. * @returns a promise that resolves when the asset is completely loaded.
  80712. */
  80713. whenCompleteAsync(): Promise<void>;
  80714. /** @hidden */
  80715. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80716. /** @hidden */
  80717. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80718. private _onProgress;
  80719. private _validate;
  80720. private _getLoader;
  80721. private _parseJson;
  80722. private _unpackBinaryAsync;
  80723. private _unpackBinaryV1Async;
  80724. private _unpackBinaryV2Async;
  80725. private static _parseVersion;
  80726. private static _compareVersion;
  80727. private static readonly _logSpaces;
  80728. private _logIndentLevel;
  80729. private _loggingEnabled;
  80730. /** @hidden */
  80731. _log: (message: string) => void;
  80732. /** @hidden */
  80733. _logOpen(message: string): void;
  80734. /** @hidden */
  80735. _logClose(): void;
  80736. private _logEnabled;
  80737. private _logDisabled;
  80738. private _capturePerformanceCounters;
  80739. /** @hidden */
  80740. _startPerformanceCounter: (counterName: string) => void;
  80741. /** @hidden */
  80742. _endPerformanceCounter: (counterName: string) => void;
  80743. private _startPerformanceCounterEnabled;
  80744. private _startPerformanceCounterDisabled;
  80745. private _endPerformanceCounterEnabled;
  80746. private _endPerformanceCounterDisabled;
  80747. }
  80748. }
  80749. declare module BABYLON.GLTF1 {
  80750. /**
  80751. * Enums
  80752. * @hidden
  80753. */
  80754. export enum EComponentType {
  80755. BYTE = 5120,
  80756. UNSIGNED_BYTE = 5121,
  80757. SHORT = 5122,
  80758. UNSIGNED_SHORT = 5123,
  80759. FLOAT = 5126
  80760. }
  80761. /** @hidden */
  80762. export enum EShaderType {
  80763. FRAGMENT = 35632,
  80764. VERTEX = 35633
  80765. }
  80766. /** @hidden */
  80767. export enum EParameterType {
  80768. BYTE = 5120,
  80769. UNSIGNED_BYTE = 5121,
  80770. SHORT = 5122,
  80771. UNSIGNED_SHORT = 5123,
  80772. INT = 5124,
  80773. UNSIGNED_INT = 5125,
  80774. FLOAT = 5126,
  80775. FLOAT_VEC2 = 35664,
  80776. FLOAT_VEC3 = 35665,
  80777. FLOAT_VEC4 = 35666,
  80778. INT_VEC2 = 35667,
  80779. INT_VEC3 = 35668,
  80780. INT_VEC4 = 35669,
  80781. BOOL = 35670,
  80782. BOOL_VEC2 = 35671,
  80783. BOOL_VEC3 = 35672,
  80784. BOOL_VEC4 = 35673,
  80785. FLOAT_MAT2 = 35674,
  80786. FLOAT_MAT3 = 35675,
  80787. FLOAT_MAT4 = 35676,
  80788. SAMPLER_2D = 35678
  80789. }
  80790. /** @hidden */
  80791. export enum ETextureWrapMode {
  80792. CLAMP_TO_EDGE = 33071,
  80793. MIRRORED_REPEAT = 33648,
  80794. REPEAT = 10497
  80795. }
  80796. /** @hidden */
  80797. export enum ETextureFilterType {
  80798. NEAREST = 9728,
  80799. LINEAR = 9728,
  80800. NEAREST_MIPMAP_NEAREST = 9984,
  80801. LINEAR_MIPMAP_NEAREST = 9985,
  80802. NEAREST_MIPMAP_LINEAR = 9986,
  80803. LINEAR_MIPMAP_LINEAR = 9987
  80804. }
  80805. /** @hidden */
  80806. export enum ETextureFormat {
  80807. ALPHA = 6406,
  80808. RGB = 6407,
  80809. RGBA = 6408,
  80810. LUMINANCE = 6409,
  80811. LUMINANCE_ALPHA = 6410
  80812. }
  80813. /** @hidden */
  80814. export enum ECullingType {
  80815. FRONT = 1028,
  80816. BACK = 1029,
  80817. FRONT_AND_BACK = 1032
  80818. }
  80819. /** @hidden */
  80820. export enum EBlendingFunction {
  80821. ZERO = 0,
  80822. ONE = 1,
  80823. SRC_COLOR = 768,
  80824. ONE_MINUS_SRC_COLOR = 769,
  80825. DST_COLOR = 774,
  80826. ONE_MINUS_DST_COLOR = 775,
  80827. SRC_ALPHA = 770,
  80828. ONE_MINUS_SRC_ALPHA = 771,
  80829. DST_ALPHA = 772,
  80830. ONE_MINUS_DST_ALPHA = 773,
  80831. CONSTANT_COLOR = 32769,
  80832. ONE_MINUS_CONSTANT_COLOR = 32770,
  80833. CONSTANT_ALPHA = 32771,
  80834. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80835. SRC_ALPHA_SATURATE = 776
  80836. }
  80837. /** @hidden */
  80838. export interface IGLTFProperty {
  80839. extensions?: {
  80840. [key: string]: any;
  80841. };
  80842. extras?: Object;
  80843. }
  80844. /** @hidden */
  80845. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80846. name?: string;
  80847. }
  80848. /** @hidden */
  80849. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80850. bufferView: string;
  80851. byteOffset: number;
  80852. byteStride: number;
  80853. count: number;
  80854. type: string;
  80855. componentType: EComponentType;
  80856. max?: number[];
  80857. min?: number[];
  80858. name?: string;
  80859. }
  80860. /** @hidden */
  80861. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80862. buffer: string;
  80863. byteOffset: number;
  80864. byteLength: number;
  80865. byteStride: number;
  80866. target?: number;
  80867. }
  80868. /** @hidden */
  80869. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80870. uri: string;
  80871. byteLength?: number;
  80872. type?: string;
  80873. }
  80874. /** @hidden */
  80875. export interface IGLTFShader extends IGLTFChildRootProperty {
  80876. uri: string;
  80877. type: EShaderType;
  80878. }
  80879. /** @hidden */
  80880. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80881. attributes: string[];
  80882. fragmentShader: string;
  80883. vertexShader: string;
  80884. }
  80885. /** @hidden */
  80886. export interface IGLTFTechniqueParameter {
  80887. type: number;
  80888. count?: number;
  80889. semantic?: string;
  80890. node?: string;
  80891. value?: number | boolean | string | Array<any>;
  80892. source?: string;
  80893. babylonValue?: any;
  80894. }
  80895. /** @hidden */
  80896. export interface IGLTFTechniqueCommonProfile {
  80897. lightingModel: string;
  80898. texcoordBindings: Object;
  80899. parameters?: Array<any>;
  80900. }
  80901. /** @hidden */
  80902. export interface IGLTFTechniqueStatesFunctions {
  80903. blendColor?: number[];
  80904. blendEquationSeparate?: number[];
  80905. blendFuncSeparate?: number[];
  80906. colorMask: boolean[];
  80907. cullFace: number[];
  80908. }
  80909. /** @hidden */
  80910. export interface IGLTFTechniqueStates {
  80911. enable: number[];
  80912. functions: IGLTFTechniqueStatesFunctions;
  80913. }
  80914. /** @hidden */
  80915. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80916. parameters: {
  80917. [key: string]: IGLTFTechniqueParameter;
  80918. };
  80919. program: string;
  80920. attributes: {
  80921. [key: string]: string;
  80922. };
  80923. uniforms: {
  80924. [key: string]: string;
  80925. };
  80926. states: IGLTFTechniqueStates;
  80927. }
  80928. /** @hidden */
  80929. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80930. technique?: string;
  80931. values: string[];
  80932. }
  80933. /** @hidden */
  80934. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80935. attributes: {
  80936. [key: string]: string;
  80937. };
  80938. indices: string;
  80939. material: string;
  80940. mode?: number;
  80941. }
  80942. /** @hidden */
  80943. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80944. primitives: IGLTFMeshPrimitive[];
  80945. }
  80946. /** @hidden */
  80947. export interface IGLTFImage extends IGLTFChildRootProperty {
  80948. uri: string;
  80949. }
  80950. /** @hidden */
  80951. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80952. magFilter?: number;
  80953. minFilter?: number;
  80954. wrapS?: number;
  80955. wrapT?: number;
  80956. }
  80957. /** @hidden */
  80958. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80959. sampler: string;
  80960. source: string;
  80961. format?: ETextureFormat;
  80962. internalFormat?: ETextureFormat;
  80963. target?: number;
  80964. type?: number;
  80965. babylonTexture?: Texture;
  80966. }
  80967. /** @hidden */
  80968. export interface IGLTFAmbienLight {
  80969. color?: number[];
  80970. }
  80971. /** @hidden */
  80972. export interface IGLTFDirectionalLight {
  80973. color?: number[];
  80974. }
  80975. /** @hidden */
  80976. export interface IGLTFPointLight {
  80977. color?: number[];
  80978. constantAttenuation?: number;
  80979. linearAttenuation?: number;
  80980. quadraticAttenuation?: number;
  80981. }
  80982. /** @hidden */
  80983. export interface IGLTFSpotLight {
  80984. color?: number[];
  80985. constantAttenuation?: number;
  80986. fallOfAngle?: number;
  80987. fallOffExponent?: number;
  80988. linearAttenuation?: number;
  80989. quadraticAttenuation?: number;
  80990. }
  80991. /** @hidden */
  80992. export interface IGLTFLight extends IGLTFChildRootProperty {
  80993. type: string;
  80994. }
  80995. /** @hidden */
  80996. export interface IGLTFCameraOrthographic {
  80997. xmag: number;
  80998. ymag: number;
  80999. zfar: number;
  81000. znear: number;
  81001. }
  81002. /** @hidden */
  81003. export interface IGLTFCameraPerspective {
  81004. aspectRatio: number;
  81005. yfov: number;
  81006. zfar: number;
  81007. znear: number;
  81008. }
  81009. /** @hidden */
  81010. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81011. type: string;
  81012. }
  81013. /** @hidden */
  81014. export interface IGLTFAnimationChannelTarget {
  81015. id: string;
  81016. path: string;
  81017. }
  81018. /** @hidden */
  81019. export interface IGLTFAnimationChannel {
  81020. sampler: string;
  81021. target: IGLTFAnimationChannelTarget;
  81022. }
  81023. /** @hidden */
  81024. export interface IGLTFAnimationSampler {
  81025. input: string;
  81026. output: string;
  81027. interpolation?: string;
  81028. }
  81029. /** @hidden */
  81030. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81031. channels?: IGLTFAnimationChannel[];
  81032. parameters?: {
  81033. [key: string]: string;
  81034. };
  81035. samplers?: {
  81036. [key: string]: IGLTFAnimationSampler;
  81037. };
  81038. }
  81039. /** @hidden */
  81040. export interface IGLTFNodeInstanceSkin {
  81041. skeletons: string[];
  81042. skin: string;
  81043. meshes: string[];
  81044. }
  81045. /** @hidden */
  81046. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81047. bindShapeMatrix: number[];
  81048. inverseBindMatrices: string;
  81049. jointNames: string[];
  81050. babylonSkeleton?: Skeleton;
  81051. }
  81052. /** @hidden */
  81053. export interface IGLTFNode extends IGLTFChildRootProperty {
  81054. camera?: string;
  81055. children: string[];
  81056. skin?: string;
  81057. jointName?: string;
  81058. light?: string;
  81059. matrix: number[];
  81060. mesh?: string;
  81061. meshes?: string[];
  81062. rotation?: number[];
  81063. scale?: number[];
  81064. translation?: number[];
  81065. babylonNode?: Node;
  81066. }
  81067. /** @hidden */
  81068. export interface IGLTFScene extends IGLTFChildRootProperty {
  81069. nodes: string[];
  81070. }
  81071. /** @hidden */
  81072. export interface IGLTFRuntime {
  81073. extensions: {
  81074. [key: string]: any;
  81075. };
  81076. accessors: {
  81077. [key: string]: IGLTFAccessor;
  81078. };
  81079. buffers: {
  81080. [key: string]: IGLTFBuffer;
  81081. };
  81082. bufferViews: {
  81083. [key: string]: IGLTFBufferView;
  81084. };
  81085. meshes: {
  81086. [key: string]: IGLTFMesh;
  81087. };
  81088. lights: {
  81089. [key: string]: IGLTFLight;
  81090. };
  81091. cameras: {
  81092. [key: string]: IGLTFCamera;
  81093. };
  81094. nodes: {
  81095. [key: string]: IGLTFNode;
  81096. };
  81097. images: {
  81098. [key: string]: IGLTFImage;
  81099. };
  81100. textures: {
  81101. [key: string]: IGLTFTexture;
  81102. };
  81103. shaders: {
  81104. [key: string]: IGLTFShader;
  81105. };
  81106. programs: {
  81107. [key: string]: IGLTFProgram;
  81108. };
  81109. samplers: {
  81110. [key: string]: IGLTFSampler;
  81111. };
  81112. techniques: {
  81113. [key: string]: IGLTFTechnique;
  81114. };
  81115. materials: {
  81116. [key: string]: IGLTFMaterial;
  81117. };
  81118. animations: {
  81119. [key: string]: IGLTFAnimation;
  81120. };
  81121. skins: {
  81122. [key: string]: IGLTFSkins;
  81123. };
  81124. currentScene?: Object;
  81125. scenes: {
  81126. [key: string]: IGLTFScene;
  81127. };
  81128. extensionsUsed: string[];
  81129. extensionsRequired?: string[];
  81130. buffersCount: number;
  81131. shaderscount: number;
  81132. scene: Scene;
  81133. rootUrl: string;
  81134. loadedBufferCount: number;
  81135. loadedBufferViews: {
  81136. [name: string]: ArrayBufferView;
  81137. };
  81138. loadedShaderCount: number;
  81139. importOnlyMeshes: boolean;
  81140. importMeshesNames?: string[];
  81141. dummyNodes: Node[];
  81142. forAssetContainer: boolean;
  81143. }
  81144. /** @hidden */
  81145. export interface INodeToRoot {
  81146. bone: Bone;
  81147. node: IGLTFNode;
  81148. id: string;
  81149. }
  81150. /** @hidden */
  81151. export interface IJointNode {
  81152. node: IGLTFNode;
  81153. id: string;
  81154. }
  81155. }
  81156. declare module BABYLON.GLTF1 {
  81157. /**
  81158. * Utils functions for GLTF
  81159. * @hidden
  81160. */
  81161. export class GLTFUtils {
  81162. /**
  81163. * Sets the given "parameter" matrix
  81164. * @param scene: the Scene object
  81165. * @param source: the source node where to pick the matrix
  81166. * @param parameter: the GLTF technique parameter
  81167. * @param uniformName: the name of the shader's uniform
  81168. * @param shaderMaterial: the shader material
  81169. */
  81170. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81171. /**
  81172. * Sets the given "parameter" matrix
  81173. * @param shaderMaterial: the shader material
  81174. * @param uniform: the name of the shader's uniform
  81175. * @param value: the value of the uniform
  81176. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81177. */
  81178. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81179. /**
  81180. * Returns the wrap mode of the texture
  81181. * @param mode: the mode value
  81182. */
  81183. static GetWrapMode(mode: number): number;
  81184. /**
  81185. * Returns the byte stride giving an accessor
  81186. * @param accessor: the GLTF accessor objet
  81187. */
  81188. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81189. /**
  81190. * Returns the texture filter mode giving a mode value
  81191. * @param mode: the filter mode value
  81192. */
  81193. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81194. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81195. /**
  81196. * Returns a buffer from its accessor
  81197. * @param gltfRuntime: the GLTF runtime
  81198. * @param accessor: the GLTF accessor
  81199. */
  81200. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81201. /**
  81202. * Decodes a buffer view into a string
  81203. * @param view: the buffer view
  81204. */
  81205. static DecodeBufferToText(view: ArrayBufferView): string;
  81206. /**
  81207. * Returns the default material of gltf. Related to
  81208. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81209. * @param scene: the Babylon.js scene
  81210. */
  81211. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81212. private static _DefaultMaterial;
  81213. }
  81214. }
  81215. declare module BABYLON.GLTF1 {
  81216. /**
  81217. * Implementation of the base glTF spec
  81218. * @hidden
  81219. */
  81220. export class GLTFLoaderBase {
  81221. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81222. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81223. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81224. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81225. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81226. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81227. }
  81228. /**
  81229. * glTF V1 Loader
  81230. * @hidden
  81231. */
  81232. export class GLTFLoader implements IGLTFLoader {
  81233. static Extensions: {
  81234. [name: string]: GLTFLoaderExtension;
  81235. };
  81236. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81237. state: Nullable<GLTFLoaderState>;
  81238. dispose(): void;
  81239. private _importMeshAsync;
  81240. /**
  81241. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81242. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81243. * @param scene the scene the meshes should be added to
  81244. * @param forAssetContainer defines if the entities must be stored in the scene
  81245. * @param data gltf data containing information of the meshes in a loaded file
  81246. * @param rootUrl root url to load from
  81247. * @param onProgress event that fires when loading progress has occured
  81248. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81249. */
  81250. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81251. private _loadAsync;
  81252. /**
  81253. * Imports all objects from a loaded gltf file and adds them to the scene
  81254. * @param scene the scene the objects should be added to
  81255. * @param data gltf data containing information of the meshes in a loaded file
  81256. * @param rootUrl root url to load from
  81257. * @param onProgress event that fires when loading progress has occured
  81258. * @returns a promise which completes when objects have been loaded to the scene
  81259. */
  81260. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81261. private _loadShadersAsync;
  81262. private _loadBuffersAsync;
  81263. private _createNodes;
  81264. }
  81265. /** @hidden */
  81266. export abstract class GLTFLoaderExtension {
  81267. private _name;
  81268. constructor(name: string);
  81269. get name(): string;
  81270. /**
  81271. * Defines an override for loading the runtime
  81272. * Return true to stop further extensions from loading the runtime
  81273. */
  81274. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81275. /**
  81276. * Defines an onverride for creating gltf runtime
  81277. * Return true to stop further extensions from creating the runtime
  81278. */
  81279. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81280. /**
  81281. * Defines an override for loading buffers
  81282. * Return true to stop further extensions from loading this buffer
  81283. */
  81284. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81285. /**
  81286. * Defines an override for loading texture buffers
  81287. * Return true to stop further extensions from loading this texture data
  81288. */
  81289. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81290. /**
  81291. * Defines an override for creating textures
  81292. * Return true to stop further extensions from loading this texture
  81293. */
  81294. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81295. /**
  81296. * Defines an override for loading shader strings
  81297. * Return true to stop further extensions from loading this shader data
  81298. */
  81299. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81300. /**
  81301. * Defines an override for loading materials
  81302. * Return true to stop further extensions from loading this material
  81303. */
  81304. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81305. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81306. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81307. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81308. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81309. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81310. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81311. private static LoadTextureBufferAsync;
  81312. private static CreateTextureAsync;
  81313. private static ApplyExtensions;
  81314. }
  81315. }
  81316. declare module BABYLON.GLTF1 {
  81317. /** @hidden */
  81318. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81319. private _bin;
  81320. constructor();
  81321. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81322. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81323. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81324. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81325. }
  81326. }
  81327. declare module BABYLON.GLTF1 {
  81328. /** @hidden */
  81329. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81330. constructor();
  81331. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81332. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81333. private _loadTexture;
  81334. }
  81335. }
  81336. declare module BABYLON.GLTF2.Loader {
  81337. /**
  81338. * Loader interface with an index field.
  81339. */
  81340. export interface IArrayItem {
  81341. /**
  81342. * The index of this item in the array.
  81343. */
  81344. index: number;
  81345. }
  81346. /**
  81347. * Loader interface with additional members.
  81348. */
  81349. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81350. /** @hidden */
  81351. _data?: Promise<ArrayBufferView>;
  81352. /** @hidden */
  81353. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81354. }
  81355. /**
  81356. * Loader interface with additional members.
  81357. */
  81358. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81359. }
  81360. /** @hidden */
  81361. export interface _IAnimationSamplerData {
  81362. input: Float32Array;
  81363. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81364. output: Float32Array;
  81365. }
  81366. /**
  81367. * Loader interface with additional members.
  81368. */
  81369. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81370. /** @hidden */
  81371. _data?: Promise<_IAnimationSamplerData>;
  81372. }
  81373. /**
  81374. * Loader interface with additional members.
  81375. */
  81376. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81377. channels: IAnimationChannel[];
  81378. samplers: IAnimationSampler[];
  81379. /** @hidden */
  81380. _babylonAnimationGroup?: AnimationGroup;
  81381. }
  81382. /**
  81383. * Loader interface with additional members.
  81384. */
  81385. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81386. /** @hidden */
  81387. _data?: Promise<ArrayBufferView>;
  81388. }
  81389. /**
  81390. * Loader interface with additional members.
  81391. */
  81392. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81393. /** @hidden */
  81394. _data?: Promise<ArrayBufferView>;
  81395. /** @hidden */
  81396. _babylonBuffer?: Promise<Buffer>;
  81397. }
  81398. /**
  81399. * Loader interface with additional members.
  81400. */
  81401. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81402. }
  81403. /**
  81404. * Loader interface with additional members.
  81405. */
  81406. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81407. /** @hidden */
  81408. _data?: Promise<ArrayBufferView>;
  81409. }
  81410. /**
  81411. * Loader interface with additional members.
  81412. */
  81413. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81414. }
  81415. /**
  81416. * Loader interface with additional members.
  81417. */
  81418. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81419. }
  81420. /**
  81421. * Loader interface with additional members.
  81422. */
  81423. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81424. baseColorTexture?: ITextureInfo;
  81425. metallicRoughnessTexture?: ITextureInfo;
  81426. }
  81427. /**
  81428. * Loader interface with additional members.
  81429. */
  81430. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81431. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81432. normalTexture?: IMaterialNormalTextureInfo;
  81433. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81434. emissiveTexture?: ITextureInfo;
  81435. /** @hidden */
  81436. _data?: {
  81437. [babylonDrawMode: number]: {
  81438. babylonMaterial: Material;
  81439. babylonMeshes: AbstractMesh[];
  81440. promise: Promise<void>;
  81441. };
  81442. };
  81443. }
  81444. /**
  81445. * Loader interface with additional members.
  81446. */
  81447. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81448. primitives: IMeshPrimitive[];
  81449. }
  81450. /**
  81451. * Loader interface with additional members.
  81452. */
  81453. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81454. /** @hidden */
  81455. _instanceData?: {
  81456. babylonSourceMesh: Mesh;
  81457. promise: Promise<any>;
  81458. };
  81459. }
  81460. /**
  81461. * Loader interface with additional members.
  81462. */
  81463. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81464. /**
  81465. * The parent glTF node.
  81466. */
  81467. parent?: INode;
  81468. /** @hidden */
  81469. _babylonTransformNode?: TransformNode;
  81470. /** @hidden */
  81471. _primitiveBabylonMeshes?: AbstractMesh[];
  81472. /** @hidden */
  81473. _babylonBones?: Bone[];
  81474. /** @hidden */
  81475. _numMorphTargets?: number;
  81476. }
  81477. /** @hidden */
  81478. export interface _ISamplerData {
  81479. noMipMaps: boolean;
  81480. samplingMode: number;
  81481. wrapU: number;
  81482. wrapV: number;
  81483. }
  81484. /**
  81485. * Loader interface with additional members.
  81486. */
  81487. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81488. /** @hidden */
  81489. _data?: _ISamplerData;
  81490. }
  81491. /**
  81492. * Loader interface with additional members.
  81493. */
  81494. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81495. }
  81496. /**
  81497. * Loader interface with additional members.
  81498. */
  81499. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81500. /** @hidden */
  81501. _data?: {
  81502. babylonSkeleton: Skeleton;
  81503. promise: Promise<void>;
  81504. };
  81505. }
  81506. /**
  81507. * Loader interface with additional members.
  81508. */
  81509. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81510. }
  81511. /**
  81512. * Loader interface with additional members.
  81513. */
  81514. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81515. }
  81516. /**
  81517. * Loader interface with additional members.
  81518. */
  81519. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81520. accessors?: IAccessor[];
  81521. animations?: IAnimation[];
  81522. buffers?: IBuffer[];
  81523. bufferViews?: IBufferView[];
  81524. cameras?: ICamera[];
  81525. images?: IImage[];
  81526. materials?: IMaterial[];
  81527. meshes?: IMesh[];
  81528. nodes?: INode[];
  81529. samplers?: ISampler[];
  81530. scenes?: IScene[];
  81531. skins?: ISkin[];
  81532. textures?: ITexture[];
  81533. }
  81534. }
  81535. declare module BABYLON.GLTF2 {
  81536. /**
  81537. * Interface for a glTF loader extension.
  81538. */
  81539. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81540. /**
  81541. * Called after the loader state changes to LOADING.
  81542. */
  81543. onLoading?(): void;
  81544. /**
  81545. * Called after the loader state changes to READY.
  81546. */
  81547. onReady?(): void;
  81548. /**
  81549. * Define this method to modify the default behavior when loading scenes.
  81550. * @param context The context when loading the asset
  81551. * @param scene The glTF scene property
  81552. * @returns A promise that resolves when the load is complete or null if not handled
  81553. */
  81554. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81555. /**
  81556. * Define this method to modify the default behavior when loading nodes.
  81557. * @param context The context when loading the asset
  81558. * @param node The glTF node property
  81559. * @param assign A function called synchronously after parsing the glTF properties
  81560. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81561. */
  81562. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81563. /**
  81564. * Define this method to modify the default behavior when loading cameras.
  81565. * @param context The context when loading the asset
  81566. * @param camera The glTF camera property
  81567. * @param assign A function called synchronously after parsing the glTF properties
  81568. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81569. */
  81570. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81571. /**
  81572. * @hidden
  81573. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81574. * @param context The context when loading the asset
  81575. * @param primitive The glTF mesh primitive property
  81576. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81577. */
  81578. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81579. /**
  81580. * @hidden
  81581. * Define this method to modify the default behavior when loading data for mesh primitives.
  81582. * @param context The context when loading the asset
  81583. * @param name The mesh name when loading the asset
  81584. * @param node The glTF node when loading the asset
  81585. * @param mesh The glTF mesh when loading the asset
  81586. * @param primitive The glTF mesh primitive property
  81587. * @param assign A function called synchronously after parsing the glTF properties
  81588. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81589. */
  81590. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81591. /**
  81592. * @hidden
  81593. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81594. * @param context The context when loading the asset
  81595. * @param material The glTF material property
  81596. * @param assign A function called synchronously after parsing the glTF properties
  81597. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81598. */
  81599. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81600. /**
  81601. * Define this method to modify the default behavior when creating materials.
  81602. * @param context The context when loading the asset
  81603. * @param material The glTF material property
  81604. * @param babylonDrawMode The draw mode for the Babylon material
  81605. * @returns The Babylon material or null if not handled
  81606. */
  81607. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81608. /**
  81609. * Define this method to modify the default behavior when loading material properties.
  81610. * @param context The context when loading the asset
  81611. * @param material The glTF material property
  81612. * @param babylonMaterial The Babylon material
  81613. * @returns A promise that resolves when the load is complete or null if not handled
  81614. */
  81615. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81616. /**
  81617. * Define this method to modify the default behavior when loading texture infos.
  81618. * @param context The context when loading the asset
  81619. * @param textureInfo The glTF texture info property
  81620. * @param assign A function called synchronously after parsing the glTF properties
  81621. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81622. */
  81623. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81624. /**
  81625. * @hidden
  81626. * Define this method to modify the default behavior when loading textures.
  81627. * @param context The context when loading the asset
  81628. * @param texture The glTF texture property
  81629. * @param assign A function called synchronously after parsing the glTF properties
  81630. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81631. */
  81632. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81633. /**
  81634. * Define this method to modify the default behavior when loading animations.
  81635. * @param context The context when loading the asset
  81636. * @param animation The glTF animation property
  81637. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81638. */
  81639. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81640. /**
  81641. * @hidden
  81642. * Define this method to modify the default behavior when loading skins.
  81643. * @param context The context when loading the asset
  81644. * @param node The glTF node property
  81645. * @param skin The glTF skin property
  81646. * @returns A promise that resolves when the load is complete or null if not handled
  81647. */
  81648. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81649. /**
  81650. * @hidden
  81651. * Define this method to modify the default behavior when loading uris.
  81652. * @param context The context when loading the asset
  81653. * @param property The glTF property associated with the uri
  81654. * @param uri The uri to load
  81655. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81656. */
  81657. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81658. /**
  81659. * Define this method to modify the default behavior when loading buffer views.
  81660. * @param context The context when loading the asset
  81661. * @param bufferView The glTF buffer view property
  81662. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81663. */
  81664. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81665. /**
  81666. * Define this method to modify the default behavior when loading buffers.
  81667. * @param context The context when loading the asset
  81668. * @param buffer The glTF buffer property
  81669. * @param byteOffset The byte offset to load
  81670. * @param byteLength The byte length to load
  81671. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81672. */
  81673. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81674. }
  81675. }
  81676. declare module BABYLON.GLTF2 {
  81677. /**
  81678. * Helper class for working with arrays when loading the glTF asset
  81679. */
  81680. export class ArrayItem {
  81681. /**
  81682. * Gets an item from the given array.
  81683. * @param context The context when loading the asset
  81684. * @param array The array to get the item from
  81685. * @param index The index to the array
  81686. * @returns The array item
  81687. */
  81688. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81689. /**
  81690. * Assign an `index` field to each item of the given array.
  81691. * @param array The array of items
  81692. */
  81693. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81694. }
  81695. /**
  81696. * The glTF 2.0 loader
  81697. */
  81698. export class GLTFLoader implements IGLTFLoader {
  81699. /** @hidden */
  81700. _completePromises: Promise<any>[];
  81701. /** @hidden */
  81702. _forAssetContainer: boolean;
  81703. /** Storage */
  81704. _babylonLights: Light[];
  81705. /** @hidden */
  81706. _disableInstancedMesh: number;
  81707. private _disposed;
  81708. private _parent;
  81709. private _state;
  81710. private _extensions;
  81711. private _rootUrl;
  81712. private _fileName;
  81713. private _uniqueRootUrl;
  81714. private _gltf;
  81715. private _bin;
  81716. private _babylonScene;
  81717. private _rootBabylonMesh;
  81718. private _defaultBabylonMaterialData;
  81719. private static _RegisteredExtensions;
  81720. /**
  81721. * The default glTF sampler.
  81722. */
  81723. static readonly DefaultSampler: ISampler;
  81724. /**
  81725. * Registers a loader extension.
  81726. * @param name The name of the loader extension.
  81727. * @param factory The factory function that creates the loader extension.
  81728. */
  81729. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81730. /**
  81731. * Unregisters a loader extension.
  81732. * @param name The name of the loader extension.
  81733. * @returns A boolean indicating whether the extension has been unregistered
  81734. */
  81735. static UnregisterExtension(name: string): boolean;
  81736. /**
  81737. * The loader state.
  81738. */
  81739. get state(): Nullable<GLTFLoaderState>;
  81740. /**
  81741. * The object that represents the glTF JSON.
  81742. */
  81743. get gltf(): IGLTF;
  81744. /**
  81745. * The BIN chunk of a binary glTF.
  81746. */
  81747. get bin(): Nullable<IDataBuffer>;
  81748. /**
  81749. * The parent file loader.
  81750. */
  81751. get parent(): GLTFFileLoader;
  81752. /**
  81753. * The Babylon scene when loading the asset.
  81754. */
  81755. get babylonScene(): Scene;
  81756. /**
  81757. * The root Babylon mesh when loading the asset.
  81758. */
  81759. get rootBabylonMesh(): Mesh;
  81760. /** @hidden */
  81761. constructor(parent: GLTFFileLoader);
  81762. /** @hidden */
  81763. dispose(): void;
  81764. /** @hidden */
  81765. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81766. /** @hidden */
  81767. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81768. private _loadAsync;
  81769. private _loadData;
  81770. private _setupData;
  81771. private _loadExtensions;
  81772. private _checkExtensions;
  81773. private _setState;
  81774. private _createRootNode;
  81775. /**
  81776. * Loads a glTF scene.
  81777. * @param context The context when loading the asset
  81778. * @param scene The glTF scene property
  81779. * @returns A promise that resolves when the load is complete
  81780. */
  81781. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81782. private _forEachPrimitive;
  81783. private _getMeshes;
  81784. private _getTransformNodes;
  81785. private _getSkeletons;
  81786. private _getAnimationGroups;
  81787. private _startAnimations;
  81788. /**
  81789. * Loads a glTF node.
  81790. * @param context The context when loading the asset
  81791. * @param node The glTF node property
  81792. * @param assign A function called synchronously after parsing the glTF properties
  81793. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81794. */
  81795. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81796. private _loadMeshAsync;
  81797. /**
  81798. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81799. * @param context The context when loading the asset
  81800. * @param name The mesh name when loading the asset
  81801. * @param node The glTF node when loading the asset
  81802. * @param mesh The glTF mesh when loading the asset
  81803. * @param primitive The glTF mesh primitive property
  81804. * @param assign A function called synchronously after parsing the glTF properties
  81805. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81806. */
  81807. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81808. private _loadVertexDataAsync;
  81809. private _createMorphTargets;
  81810. private _loadMorphTargetsAsync;
  81811. private _loadMorphTargetVertexDataAsync;
  81812. private static _LoadTransform;
  81813. private _loadSkinAsync;
  81814. private _loadBones;
  81815. private _loadBone;
  81816. private _loadSkinInverseBindMatricesDataAsync;
  81817. private _updateBoneMatrices;
  81818. private _getNodeMatrix;
  81819. /**
  81820. * Loads a glTF camera.
  81821. * @param context The context when loading the asset
  81822. * @param camera The glTF camera property
  81823. * @param assign A function called synchronously after parsing the glTF properties
  81824. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81825. */
  81826. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81827. private _loadAnimationsAsync;
  81828. /**
  81829. * Loads a glTF animation.
  81830. * @param context The context when loading the asset
  81831. * @param animation The glTF animation property
  81832. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81833. */
  81834. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81835. /**
  81836. * @hidden Loads a glTF animation channel.
  81837. * @param context The context when loading the asset
  81838. * @param animationContext The context of the animation when loading the asset
  81839. * @param animation The glTF animation property
  81840. * @param channel The glTF animation channel property
  81841. * @param babylonAnimationGroup The babylon animation group property
  81842. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81843. * @returns A void promise when the channel load is complete
  81844. */
  81845. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81846. private _loadAnimationSamplerAsync;
  81847. private _loadBufferAsync;
  81848. /**
  81849. * Loads a glTF buffer view.
  81850. * @param context The context when loading the asset
  81851. * @param bufferView The glTF buffer view property
  81852. * @returns A promise that resolves with the loaded data when the load is complete
  81853. */
  81854. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81855. private _loadAccessorAsync;
  81856. /** @hidden */
  81857. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81858. private _loadIndicesAccessorAsync;
  81859. private _loadVertexBufferViewAsync;
  81860. private _loadVertexAccessorAsync;
  81861. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81862. /** @hidden */
  81863. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81864. private _createDefaultMaterial;
  81865. /**
  81866. * Creates a Babylon material from a glTF material.
  81867. * @param context The context when loading the asset
  81868. * @param material The glTF material property
  81869. * @param babylonDrawMode The draw mode for the Babylon material
  81870. * @returns The Babylon material
  81871. */
  81872. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81873. /**
  81874. * Loads properties from a glTF material into a Babylon material.
  81875. * @param context The context when loading the asset
  81876. * @param material The glTF material property
  81877. * @param babylonMaterial The Babylon material
  81878. * @returns A promise that resolves when the load is complete
  81879. */
  81880. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81881. /**
  81882. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81883. * @param context The context when loading the asset
  81884. * @param material The glTF material property
  81885. * @param babylonMaterial The Babylon material
  81886. * @returns A promise that resolves when the load is complete
  81887. */
  81888. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81889. /**
  81890. * Loads the alpha properties from a glTF material into a Babylon material.
  81891. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81892. * @param context The context when loading the asset
  81893. * @param material The glTF material property
  81894. * @param babylonMaterial The Babylon material
  81895. */
  81896. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81897. /**
  81898. * Loads a glTF texture info.
  81899. * @param context The context when loading the asset
  81900. * @param textureInfo The glTF texture info property
  81901. * @param assign A function called synchronously after parsing the glTF properties
  81902. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81903. */
  81904. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81905. /** @hidden */
  81906. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81907. /** @hidden */
  81908. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81909. private _loadSampler;
  81910. /**
  81911. * Loads a glTF image.
  81912. * @param context The context when loading the asset
  81913. * @param image The glTF image property
  81914. * @returns A promise that resolves with the loaded data when the load is complete
  81915. */
  81916. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81917. /**
  81918. * Loads a glTF uri.
  81919. * @param context The context when loading the asset
  81920. * @param property The glTF property associated with the uri
  81921. * @param uri The base64 or relative uri
  81922. * @returns A promise that resolves with the loaded data when the load is complete
  81923. */
  81924. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81925. /**
  81926. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81927. * @param babylonObject the Babylon object with metadata
  81928. * @param pointer the JSON pointer
  81929. */
  81930. static AddPointerMetadata(babylonObject: {
  81931. metadata: any;
  81932. }, pointer: string): void;
  81933. private static _GetTextureWrapMode;
  81934. private static _GetTextureSamplingMode;
  81935. private static _GetTypedArrayConstructor;
  81936. private static _GetTypedArray;
  81937. private static _GetNumComponents;
  81938. private static _ValidateUri;
  81939. /** @hidden */
  81940. static _GetDrawMode(context: string, mode: number | undefined): number;
  81941. private _compileMaterialsAsync;
  81942. private _compileShadowGeneratorsAsync;
  81943. private _forEachExtensions;
  81944. private _applyExtensions;
  81945. private _extensionsOnLoading;
  81946. private _extensionsOnReady;
  81947. private _extensionsLoadSceneAsync;
  81948. private _extensionsLoadNodeAsync;
  81949. private _extensionsLoadCameraAsync;
  81950. private _extensionsLoadVertexDataAsync;
  81951. private _extensionsLoadMeshPrimitiveAsync;
  81952. private _extensionsLoadMaterialAsync;
  81953. private _extensionsCreateMaterial;
  81954. private _extensionsLoadMaterialPropertiesAsync;
  81955. private _extensionsLoadTextureInfoAsync;
  81956. private _extensionsLoadTextureAsync;
  81957. private _extensionsLoadAnimationAsync;
  81958. private _extensionsLoadSkinAsync;
  81959. private _extensionsLoadUriAsync;
  81960. private _extensionsLoadBufferViewAsync;
  81961. private _extensionsLoadBufferAsync;
  81962. /**
  81963. * Helper method called by a loader extension to load an glTF extension.
  81964. * @param context The context when loading the asset
  81965. * @param property The glTF property to load the extension from
  81966. * @param extensionName The name of the extension to load
  81967. * @param actionAsync The action to run
  81968. * @returns The promise returned by actionAsync or null if the extension does not exist
  81969. */
  81970. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81971. /**
  81972. * Helper method called by a loader extension to load a glTF extra.
  81973. * @param context The context when loading the asset
  81974. * @param property The glTF property to load the extra from
  81975. * @param extensionName The name of the extension to load
  81976. * @param actionAsync The action to run
  81977. * @returns The promise returned by actionAsync or null if the extra does not exist
  81978. */
  81979. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81980. /**
  81981. * Checks for presence of an extension.
  81982. * @param name The name of the extension to check
  81983. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81984. */
  81985. isExtensionUsed(name: string): boolean;
  81986. /**
  81987. * Increments the indentation level and logs a message.
  81988. * @param message The message to log
  81989. */
  81990. logOpen(message: string): void;
  81991. /**
  81992. * Decrements the indentation level.
  81993. */
  81994. logClose(): void;
  81995. /**
  81996. * Logs a message
  81997. * @param message The message to log
  81998. */
  81999. log(message: string): void;
  82000. /**
  82001. * Starts a performance counter.
  82002. * @param counterName The name of the performance counter
  82003. */
  82004. startPerformanceCounter(counterName: string): void;
  82005. /**
  82006. * Ends a performance counter.
  82007. * @param counterName The name of the performance counter
  82008. */
  82009. endPerformanceCounter(counterName: string): void;
  82010. }
  82011. }
  82012. declare module BABYLON.GLTF2.Loader.Extensions {
  82013. /** @hidden */
  82014. interface IEXTLightsImageBased_LightImageBased {
  82015. _babylonTexture?: BaseTexture;
  82016. _loaded?: Promise<void>;
  82017. }
  82018. /**
  82019. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82020. */
  82021. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82022. /**
  82023. * The name of this extension.
  82024. */
  82025. readonly name: string;
  82026. /**
  82027. * Defines whether this extension is enabled.
  82028. */
  82029. enabled: boolean;
  82030. private _loader;
  82031. private _lights?;
  82032. /** @hidden */
  82033. constructor(loader: GLTFLoader);
  82034. /** @hidden */
  82035. dispose(): void;
  82036. /** @hidden */
  82037. onLoading(): void;
  82038. /** @hidden */
  82039. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82040. private _loadLightAsync;
  82041. }
  82042. }
  82043. declare module BABYLON.GLTF2.Loader.Extensions {
  82044. /**
  82045. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82046. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82047. * !!! Experimental Extension Subject to Changes !!!
  82048. */
  82049. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82050. /**
  82051. * The name of this extension.
  82052. */
  82053. readonly name: string;
  82054. /**
  82055. * Defines whether this extension is enabled.
  82056. */
  82057. enabled: boolean;
  82058. private _loader;
  82059. /** @hidden */
  82060. constructor(loader: GLTFLoader);
  82061. /** @hidden */
  82062. dispose(): void;
  82063. /** @hidden */
  82064. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82065. }
  82066. }
  82067. declare module BABYLON.GLTF2.Loader.Extensions {
  82068. /**
  82069. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82070. */
  82071. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82072. /** The name of this extension. */
  82073. readonly name: string;
  82074. /** Defines whether this extension is enabled. */
  82075. enabled: boolean;
  82076. private _loader;
  82077. /** @hidden */
  82078. constructor(loader: GLTFLoader);
  82079. /** @hidden */
  82080. dispose(): void;
  82081. /** @hidden */
  82082. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82083. }
  82084. }
  82085. declare module BABYLON.GLTF2.Loader.Extensions {
  82086. /**
  82087. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82088. */
  82089. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82090. /**
  82091. * The name of this extension.
  82092. */
  82093. readonly name: string;
  82094. /**
  82095. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82096. */
  82097. dracoCompression?: DracoCompression;
  82098. /**
  82099. * Defines whether this extension is enabled.
  82100. */
  82101. enabled: boolean;
  82102. private _loader;
  82103. /** @hidden */
  82104. constructor(loader: GLTFLoader);
  82105. /** @hidden */
  82106. dispose(): void;
  82107. /** @hidden */
  82108. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82109. }
  82110. }
  82111. declare module BABYLON.GLTF2.Loader.Extensions {
  82112. /**
  82113. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82114. */
  82115. export class KHR_lights implements IGLTFLoaderExtension {
  82116. /**
  82117. * The name of this extension.
  82118. */
  82119. readonly name: string;
  82120. /**
  82121. * Defines whether this extension is enabled.
  82122. */
  82123. enabled: boolean;
  82124. private _loader;
  82125. private _lights?;
  82126. /** @hidden */
  82127. constructor(loader: GLTFLoader);
  82128. /** @hidden */
  82129. dispose(): void;
  82130. /** @hidden */
  82131. onLoading(): void;
  82132. /** @hidden */
  82133. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82134. }
  82135. }
  82136. declare module BABYLON.GLTF2.Loader.Extensions {
  82137. /**
  82138. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82139. */
  82140. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82141. /**
  82142. * The name of this extension.
  82143. */
  82144. readonly name: string;
  82145. /**
  82146. * Defines whether this extension is enabled.
  82147. */
  82148. enabled: boolean;
  82149. /**
  82150. * Defines a number that determines the order the extensions are applied.
  82151. */
  82152. order: number;
  82153. private _loader;
  82154. /** @hidden */
  82155. constructor(loader: GLTFLoader);
  82156. /** @hidden */
  82157. dispose(): void;
  82158. /** @hidden */
  82159. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82160. private _loadSpecularGlossinessPropertiesAsync;
  82161. }
  82162. }
  82163. declare module BABYLON.GLTF2.Loader.Extensions {
  82164. /**
  82165. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82166. */
  82167. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82168. /**
  82169. * The name of this extension.
  82170. */
  82171. readonly name: string;
  82172. /**
  82173. * Defines whether this extension is enabled.
  82174. */
  82175. enabled: boolean;
  82176. /**
  82177. * Defines a number that determines the order the extensions are applied.
  82178. */
  82179. order: number;
  82180. private _loader;
  82181. /** @hidden */
  82182. constructor(loader: GLTFLoader);
  82183. /** @hidden */
  82184. dispose(): void;
  82185. /** @hidden */
  82186. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82187. private _loadUnlitPropertiesAsync;
  82188. }
  82189. }
  82190. declare module BABYLON.GLTF2.Loader.Extensions {
  82191. /**
  82192. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82193. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82194. * !!! Experimental Extension Subject to Changes !!!
  82195. */
  82196. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82197. /**
  82198. * The name of this extension.
  82199. */
  82200. readonly name: string;
  82201. /**
  82202. * Defines whether this extension is enabled.
  82203. */
  82204. enabled: boolean;
  82205. /**
  82206. * Defines a number that determines the order the extensions are applied.
  82207. */
  82208. order: number;
  82209. private _loader;
  82210. /** @hidden */
  82211. constructor(loader: GLTFLoader);
  82212. /** @hidden */
  82213. dispose(): void;
  82214. /** @hidden */
  82215. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82216. private _loadClearCoatPropertiesAsync;
  82217. }
  82218. }
  82219. declare module BABYLON.GLTF2.Loader.Extensions {
  82220. /**
  82221. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82222. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82223. * !!! Experimental Extension Subject to Changes !!!
  82224. */
  82225. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82226. /**
  82227. * The name of this extension.
  82228. */
  82229. readonly name: string;
  82230. /**
  82231. * Defines whether this extension is enabled.
  82232. */
  82233. enabled: boolean;
  82234. /**
  82235. * Defines a number that determines the order the extensions are applied.
  82236. */
  82237. order: number;
  82238. private _loader;
  82239. /** @hidden */
  82240. constructor(loader: GLTFLoader);
  82241. /** @hidden */
  82242. dispose(): void;
  82243. /** @hidden */
  82244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82245. private _loadSheenPropertiesAsync;
  82246. }
  82247. }
  82248. declare module BABYLON.GLTF2.Loader.Extensions {
  82249. /**
  82250. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82251. * !!! Experimental Extension Subject to Changes !!!
  82252. */
  82253. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82254. /**
  82255. * The name of this extension.
  82256. */
  82257. readonly name: string;
  82258. /**
  82259. * Defines whether this extension is enabled.
  82260. */
  82261. enabled: boolean;
  82262. /**
  82263. * Defines a number that determines the order the extensions are applied.
  82264. */
  82265. order: number;
  82266. private _loader;
  82267. /** @hidden */
  82268. constructor(loader: GLTFLoader);
  82269. /** @hidden */
  82270. dispose(): void;
  82271. /** @hidden */
  82272. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82273. private _loadSpecularPropertiesAsync;
  82274. }
  82275. }
  82276. declare module BABYLON.GLTF2.Loader.Extensions {
  82277. /**
  82278. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82279. * !!! Experimental Extension Subject to Changes !!!
  82280. */
  82281. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82282. /**
  82283. * Default ior Value from the spec.
  82284. */
  82285. private static readonly _DEFAULT_IOR;
  82286. /**
  82287. * The name of this extension.
  82288. */
  82289. readonly name: string;
  82290. /**
  82291. * Defines whether this extension is enabled.
  82292. */
  82293. enabled: boolean;
  82294. /**
  82295. * Defines a number that determines the order the extensions are applied.
  82296. */
  82297. order: number;
  82298. private _loader;
  82299. /** @hidden */
  82300. constructor(loader: GLTFLoader);
  82301. /** @hidden */
  82302. dispose(): void;
  82303. /** @hidden */
  82304. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82305. private _loadIorPropertiesAsync;
  82306. }
  82307. }
  82308. declare module BABYLON.GLTF2.Loader.Extensions {
  82309. /**
  82310. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82311. * !!! Experimental Extension Subject to Changes !!!
  82312. */
  82313. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82314. /**
  82315. * The name of this extension.
  82316. */
  82317. readonly name: string;
  82318. /**
  82319. * Defines whether this extension is enabled.
  82320. */
  82321. enabled: boolean;
  82322. private _loader;
  82323. private _variants?;
  82324. /** @hidden */
  82325. constructor(loader: GLTFLoader);
  82326. /** @hidden */
  82327. dispose(): void;
  82328. /**
  82329. * Gets the list of available variant names for this asset.
  82330. * @param rootMesh The glTF root mesh
  82331. * @returns the list of all the variant names for this model
  82332. */
  82333. static GetAvailableVariants(rootMesh: Mesh): string[];
  82334. /**
  82335. * Gets the list of available variant names for this asset.
  82336. * @param rootMesh The glTF root mesh
  82337. * @returns the list of all the variant names for this model
  82338. */
  82339. getAvailableVariants(rootMesh: Mesh): string[];
  82340. /**
  82341. * Select a variant given a variant name or a list of variant names.
  82342. * @param rootMesh The glTF root mesh
  82343. * @param variantName The variant name(s) to select.
  82344. */
  82345. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82346. /**
  82347. * Select a variant given a variant name or a list of variant names.
  82348. * @param rootMesh The glTF root mesh
  82349. * @param variantName The variant name(s) to select.
  82350. */
  82351. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82352. /**
  82353. * Reset back to the original before selecting a variant.
  82354. * @param rootMesh The glTF root mesh
  82355. */
  82356. static Reset(rootMesh: Mesh): void;
  82357. /**
  82358. * Reset back to the original before selecting a variant.
  82359. * @param rootMesh The glTF root mesh
  82360. */
  82361. reset(rootMesh: Mesh): void;
  82362. /**
  82363. * Gets the last selected variant name(s) or null if original.
  82364. * @param rootMesh The glTF root mesh
  82365. * @returns The selected variant name(s).
  82366. */
  82367. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82368. /**
  82369. * Gets the last selected variant name(s) or null if original.
  82370. * @param rootMesh The glTF root mesh
  82371. * @returns The selected variant name(s).
  82372. */
  82373. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82374. private static _GetExtensionMetadata;
  82375. /** @hidden */
  82376. onLoading(): void;
  82377. /** @hidden */
  82378. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82379. }
  82380. }
  82381. declare module BABYLON.GLTF2.Loader.Extensions {
  82382. /**
  82383. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82384. * !!! Experimental Extension Subject to Changes !!!
  82385. */
  82386. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82387. /**
  82388. * The name of this extension.
  82389. */
  82390. readonly name: string;
  82391. /**
  82392. * Defines whether this extension is enabled.
  82393. */
  82394. enabled: boolean;
  82395. /**
  82396. * Defines a number that determines the order the extensions are applied.
  82397. */
  82398. order: number;
  82399. private _loader;
  82400. /** @hidden */
  82401. constructor(loader: GLTFLoader);
  82402. /** @hidden */
  82403. dispose(): void;
  82404. /** @hidden */
  82405. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82406. private _loadTransparentPropertiesAsync;
  82407. }
  82408. }
  82409. declare module BABYLON.GLTF2.Loader.Extensions {
  82410. /**
  82411. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82412. */
  82413. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82414. /**
  82415. * The name of this extension.
  82416. */
  82417. readonly name: string;
  82418. /**
  82419. * Defines whether this extension is enabled.
  82420. */
  82421. enabled: boolean;
  82422. /** @hidden */
  82423. constructor(loader: GLTFLoader);
  82424. /** @hidden */
  82425. dispose(): void;
  82426. }
  82427. }
  82428. declare module BABYLON.GLTF2.Loader.Extensions {
  82429. /**
  82430. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82431. * !!! Experimental Extension Subject to Changes !!!
  82432. */
  82433. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82434. /** The name of this extension. */
  82435. readonly name: string;
  82436. /** Defines whether this extension is enabled. */
  82437. enabled: boolean;
  82438. private _loader;
  82439. /** @hidden */
  82440. constructor(loader: GLTFLoader);
  82441. /** @hidden */
  82442. dispose(): void;
  82443. /** @hidden */
  82444. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82445. }
  82446. }
  82447. declare module BABYLON.GLTF2.Loader.Extensions {
  82448. /**
  82449. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82450. */
  82451. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82452. /**
  82453. * The name of this extension.
  82454. */
  82455. readonly name: string;
  82456. /**
  82457. * Defines whether this extension is enabled.
  82458. */
  82459. enabled: boolean;
  82460. private _loader;
  82461. /** @hidden */
  82462. constructor(loader: GLTFLoader);
  82463. /** @hidden */
  82464. dispose(): void;
  82465. /** @hidden */
  82466. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82467. }
  82468. }
  82469. declare module BABYLON.GLTF2.Loader.Extensions {
  82470. /**
  82471. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82472. * !!! Experimental Extension Subject to Changes !!!
  82473. */
  82474. export class KHR_xmp implements IGLTFLoaderExtension {
  82475. /**
  82476. * The name of this extension.
  82477. */
  82478. readonly name: string;
  82479. /**
  82480. * Defines whether this extension is enabled.
  82481. */
  82482. enabled: boolean;
  82483. /**
  82484. * Defines a number that determines the order the extensions are applied.
  82485. */
  82486. order: number;
  82487. private _loader;
  82488. /** @hidden */
  82489. constructor(loader: GLTFLoader);
  82490. /** @hidden */
  82491. dispose(): void;
  82492. /**
  82493. * Called after the loader state changes to LOADING.
  82494. */
  82495. onLoading(): void;
  82496. }
  82497. }
  82498. declare module BABYLON.GLTF2.Loader.Extensions {
  82499. /**
  82500. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82501. */
  82502. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82503. /**
  82504. * The name of this extension.
  82505. */
  82506. readonly name: string;
  82507. /**
  82508. * Defines whether this extension is enabled.
  82509. */
  82510. enabled: boolean;
  82511. private _loader;
  82512. private _clips;
  82513. private _emitters;
  82514. /** @hidden */
  82515. constructor(loader: GLTFLoader);
  82516. /** @hidden */
  82517. dispose(): void;
  82518. /** @hidden */
  82519. onLoading(): void;
  82520. /** @hidden */
  82521. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82522. /** @hidden */
  82523. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82524. /** @hidden */
  82525. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82526. private _loadClipAsync;
  82527. private _loadEmitterAsync;
  82528. private _getEventAction;
  82529. private _loadAnimationEventAsync;
  82530. }
  82531. }
  82532. declare module BABYLON.GLTF2.Loader.Extensions {
  82533. /**
  82534. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82535. */
  82536. export class MSFT_lod implements IGLTFLoaderExtension {
  82537. /**
  82538. * The name of this extension.
  82539. */
  82540. readonly name: string;
  82541. /**
  82542. * Defines whether this extension is enabled.
  82543. */
  82544. enabled: boolean;
  82545. /**
  82546. * Defines a number that determines the order the extensions are applied.
  82547. */
  82548. order: number;
  82549. /**
  82550. * Maximum number of LODs to load, starting from the lowest LOD.
  82551. */
  82552. maxLODsToLoad: number;
  82553. /**
  82554. * Observable raised when all node LODs of one level are loaded.
  82555. * The event data is the index of the loaded LOD starting from zero.
  82556. * Dispose the loader to cancel the loading of the next level of LODs.
  82557. */
  82558. onNodeLODsLoadedObservable: Observable<number>;
  82559. /**
  82560. * Observable raised when all material LODs of one level are loaded.
  82561. * The event data is the index of the loaded LOD starting from zero.
  82562. * Dispose the loader to cancel the loading of the next level of LODs.
  82563. */
  82564. onMaterialLODsLoadedObservable: Observable<number>;
  82565. private _loader;
  82566. private _bufferLODs;
  82567. private _nodeIndexLOD;
  82568. private _nodeSignalLODs;
  82569. private _nodePromiseLODs;
  82570. private _nodeBufferLODs;
  82571. private _materialIndexLOD;
  82572. private _materialSignalLODs;
  82573. private _materialPromiseLODs;
  82574. private _materialBufferLODs;
  82575. /** @hidden */
  82576. constructor(loader: GLTFLoader);
  82577. /** @hidden */
  82578. dispose(): void;
  82579. /** @hidden */
  82580. onReady(): void;
  82581. /** @hidden */
  82582. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82583. /** @hidden */
  82584. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82585. /** @hidden */
  82586. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82587. /** @hidden */
  82588. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82589. /** @hidden */
  82590. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82591. private _loadBufferLOD;
  82592. /**
  82593. * Gets an array of LOD properties from lowest to highest.
  82594. */
  82595. private _getLODs;
  82596. private _disposeTransformNode;
  82597. private _disposeMaterials;
  82598. }
  82599. }
  82600. declare module BABYLON.GLTF2.Loader.Extensions {
  82601. /** @hidden */
  82602. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82603. readonly name: string;
  82604. enabled: boolean;
  82605. private _loader;
  82606. constructor(loader: GLTFLoader);
  82607. dispose(): void;
  82608. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82609. }
  82610. }
  82611. declare module BABYLON.GLTF2.Loader.Extensions {
  82612. /** @hidden */
  82613. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82614. readonly name: string;
  82615. enabled: boolean;
  82616. private _loader;
  82617. constructor(loader: GLTFLoader);
  82618. dispose(): void;
  82619. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82620. }
  82621. }
  82622. declare module BABYLON.GLTF2.Loader.Extensions {
  82623. /**
  82624. * Store glTF extras (if present) in BJS objects' metadata
  82625. */
  82626. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82627. /**
  82628. * The name of this extension.
  82629. */
  82630. readonly name: string;
  82631. /**
  82632. * Defines whether this extension is enabled.
  82633. */
  82634. enabled: boolean;
  82635. private _loader;
  82636. private _assignExtras;
  82637. /** @hidden */
  82638. constructor(loader: GLTFLoader);
  82639. /** @hidden */
  82640. dispose(): void;
  82641. /** @hidden */
  82642. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82643. /** @hidden */
  82644. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82645. /** @hidden */
  82646. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82647. }
  82648. }
  82649. declare module BABYLON {
  82650. /**
  82651. * Class reading and parsing the MTL file bundled with the obj file.
  82652. */
  82653. export class MTLFileLoader {
  82654. /**
  82655. * Invert Y-Axis of referenced textures on load
  82656. */
  82657. static INVERT_TEXTURE_Y: boolean;
  82658. /**
  82659. * All material loaded from the mtl will be set here
  82660. */
  82661. materials: StandardMaterial[];
  82662. /**
  82663. * This function will read the mtl file and create each material described inside
  82664. * This function could be improve by adding :
  82665. * -some component missing (Ni, Tf...)
  82666. * -including the specific options available
  82667. *
  82668. * @param scene defines the scene the material will be created in
  82669. * @param data defines the mtl data to parse
  82670. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82671. * @param forAssetContainer defines if the material should be registered in the scene
  82672. */
  82673. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82674. /**
  82675. * Gets the texture for the material.
  82676. *
  82677. * If the material is imported from input file,
  82678. * We sanitize the url to ensure it takes the textre from aside the material.
  82679. *
  82680. * @param rootUrl The root url to load from
  82681. * @param value The value stored in the mtl
  82682. * @return The Texture
  82683. */
  82684. private static _getTexture;
  82685. }
  82686. }
  82687. declare module BABYLON {
  82688. /**
  82689. * Options for loading OBJ/MTL files
  82690. */
  82691. type MeshLoadOptions = {
  82692. /**
  82693. * Defines if UVs are optimized by default during load.
  82694. */
  82695. OptimizeWithUV: boolean;
  82696. /**
  82697. * Defines custom scaling of UV coordinates of loaded meshes.
  82698. */
  82699. UVScaling: Vector2;
  82700. /**
  82701. * Invert model on y-axis (does a model scaling inversion)
  82702. */
  82703. InvertY: boolean;
  82704. /**
  82705. * Invert Y-Axis of referenced textures on load
  82706. */
  82707. InvertTextureY: boolean;
  82708. /**
  82709. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82710. */
  82711. ImportVertexColors: boolean;
  82712. /**
  82713. * Compute the normals for the model, even if normals are present in the file.
  82714. */
  82715. ComputeNormals: boolean;
  82716. /**
  82717. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82718. */
  82719. SkipMaterials: boolean;
  82720. /**
  82721. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82722. */
  82723. MaterialLoadingFailsSilently: boolean;
  82724. };
  82725. /**
  82726. * OBJ file type loader.
  82727. * This is a babylon scene loader plugin.
  82728. */
  82729. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82730. /**
  82731. * Defines if UVs are optimized by default during load.
  82732. */
  82733. static OPTIMIZE_WITH_UV: boolean;
  82734. /**
  82735. * Invert model on y-axis (does a model scaling inversion)
  82736. */
  82737. static INVERT_Y: boolean;
  82738. /**
  82739. * Invert Y-Axis of referenced textures on load
  82740. */
  82741. static get INVERT_TEXTURE_Y(): boolean;
  82742. static set INVERT_TEXTURE_Y(value: boolean);
  82743. /**
  82744. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82745. */
  82746. static IMPORT_VERTEX_COLORS: boolean;
  82747. /**
  82748. * Compute the normals for the model, even if normals are present in the file.
  82749. */
  82750. static COMPUTE_NORMALS: boolean;
  82751. /**
  82752. * Defines custom scaling of UV coordinates of loaded meshes.
  82753. */
  82754. static UV_SCALING: Vector2;
  82755. /**
  82756. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82757. */
  82758. static SKIP_MATERIALS: boolean;
  82759. /**
  82760. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82761. *
  82762. * Defaults to true for backwards compatibility.
  82763. */
  82764. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82765. /**
  82766. * Defines the name of the plugin.
  82767. */
  82768. name: string;
  82769. /**
  82770. * Defines the extension the plugin is able to load.
  82771. */
  82772. extensions: string;
  82773. /** @hidden */
  82774. obj: RegExp;
  82775. /** @hidden */
  82776. group: RegExp;
  82777. /** @hidden */
  82778. mtllib: RegExp;
  82779. /** @hidden */
  82780. usemtl: RegExp;
  82781. /** @hidden */
  82782. smooth: RegExp;
  82783. /** @hidden */
  82784. vertexPattern: RegExp;
  82785. /** @hidden */
  82786. normalPattern: RegExp;
  82787. /** @hidden */
  82788. uvPattern: RegExp;
  82789. /** @hidden */
  82790. facePattern1: RegExp;
  82791. /** @hidden */
  82792. facePattern2: RegExp;
  82793. /** @hidden */
  82794. facePattern3: RegExp;
  82795. /** @hidden */
  82796. facePattern4: RegExp;
  82797. /** @hidden */
  82798. facePattern5: RegExp;
  82799. private _forAssetContainer;
  82800. private _meshLoadOptions;
  82801. /**
  82802. * Creates loader for .OBJ files
  82803. *
  82804. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82805. */
  82806. constructor(meshLoadOptions?: MeshLoadOptions);
  82807. private static get currentMeshLoadOptions();
  82808. /**
  82809. * Calls synchronously the MTL file attached to this obj.
  82810. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82811. * Without this function materials are not displayed in the first frame (but displayed after).
  82812. * In consequence it is impossible to get material information in your HTML file
  82813. *
  82814. * @param url The URL of the MTL file
  82815. * @param rootUrl
  82816. * @param onSuccess Callback function to be called when the MTL file is loaded
  82817. * @private
  82818. */
  82819. private _loadMTL;
  82820. /**
  82821. * Instantiates a OBJ file loader plugin.
  82822. * @returns the created plugin
  82823. */
  82824. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82825. /**
  82826. * If the data string can be loaded directly.
  82827. *
  82828. * @param data string containing the file data
  82829. * @returns if the data can be loaded directly
  82830. */
  82831. canDirectLoad(data: string): boolean;
  82832. /**
  82833. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82834. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82835. * @param scene the scene the meshes should be added to
  82836. * @param data the OBJ data to load
  82837. * @param rootUrl root url to load from
  82838. * @param onProgress event that fires when loading progress has occured
  82839. * @param fileName Defines the name of the file to load
  82840. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82841. */
  82842. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82843. meshes: AbstractMesh[];
  82844. particleSystems: IParticleSystem[];
  82845. skeletons: Skeleton[];
  82846. animationGroups: AnimationGroup[];
  82847. }>;
  82848. /**
  82849. * Imports all objects from the loaded OBJ data and adds them to the scene
  82850. * @param scene the scene the objects should be added to
  82851. * @param data the OBJ data to load
  82852. * @param rootUrl root url to load from
  82853. * @param onProgress event that fires when loading progress has occured
  82854. * @param fileName Defines the name of the file to load
  82855. * @returns a promise which completes when objects have been loaded to the scene
  82856. */
  82857. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82858. /**
  82859. * Load into an asset container.
  82860. * @param scene The scene to load into
  82861. * @param data The data to import
  82862. * @param rootUrl The root url for scene and resources
  82863. * @param onProgress The callback when the load progresses
  82864. * @param fileName Defines the name of the file to load
  82865. * @returns The loaded asset container
  82866. */
  82867. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82868. /**
  82869. * Read the OBJ file and create an Array of meshes.
  82870. * Each mesh contains all information given by the OBJ and the MTL file.
  82871. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82872. *
  82873. * @param meshesNames
  82874. * @param scene Scene The scene where are displayed the data
  82875. * @param data String The content of the obj file
  82876. * @param rootUrl String The path to the folder
  82877. * @returns Array<AbstractMesh>
  82878. * @private
  82879. */
  82880. private _parseSolid;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /**
  82885. * STL file type loader.
  82886. * This is a babylon scene loader plugin.
  82887. */
  82888. export class STLFileLoader implements ISceneLoaderPlugin {
  82889. /** @hidden */
  82890. solidPattern: RegExp;
  82891. /** @hidden */
  82892. facetsPattern: RegExp;
  82893. /** @hidden */
  82894. normalPattern: RegExp;
  82895. /** @hidden */
  82896. vertexPattern: RegExp;
  82897. /**
  82898. * Defines the name of the plugin.
  82899. */
  82900. name: string;
  82901. /**
  82902. * Defines the extensions the stl loader is able to load.
  82903. * force data to come in as an ArrayBuffer
  82904. * we'll convert to string if it looks like it's an ASCII .stl
  82905. */
  82906. extensions: ISceneLoaderPluginExtensions;
  82907. /**
  82908. * Import meshes into a scene.
  82909. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82910. * @param scene The scene to import into
  82911. * @param data The data to import
  82912. * @param rootUrl The root url for scene and resources
  82913. * @param meshes The meshes array to import into
  82914. * @param particleSystems The particle systems array to import into
  82915. * @param skeletons The skeletons array to import into
  82916. * @param onError The callback when import fails
  82917. * @returns True if successful or false otherwise
  82918. */
  82919. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82920. /**
  82921. * Load into a scene.
  82922. * @param scene The scene to load into
  82923. * @param data The data to import
  82924. * @param rootUrl The root url for scene and resources
  82925. * @param onError The callback when import fails
  82926. * @returns true if successful or false otherwise
  82927. */
  82928. load(scene: Scene, data: any, rootUrl: string): boolean;
  82929. /**
  82930. * Load into an asset container.
  82931. * @param scene The scene to load into
  82932. * @param data The data to import
  82933. * @param rootUrl The root url for scene and resources
  82934. * @param onError The callback when import fails
  82935. * @returns The loaded asset container
  82936. */
  82937. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82938. private _isBinary;
  82939. private _parseBinary;
  82940. private _parseASCII;
  82941. }
  82942. }
  82943. declare module BABYLON {
  82944. /**
  82945. * Class for generating OBJ data from a Babylon scene.
  82946. */
  82947. export class OBJExport {
  82948. /**
  82949. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82950. * @param mesh defines the list of meshes to serialize
  82951. * @param materials defines if materials should be exported
  82952. * @param matlibname defines the name of the associated mtl file
  82953. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82954. * @returns the OBJ content
  82955. */
  82956. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82957. /**
  82958. * Exports the material(s) of a mesh in .MTL file format (text)
  82959. * @param mesh defines the mesh to extract the material from
  82960. * @returns the mtl content
  82961. */
  82962. static MTL(mesh: Mesh): string;
  82963. }
  82964. }
  82965. declare module BABYLON {
  82966. /** @hidden */
  82967. export var __IGLTFExporterExtension: number;
  82968. /**
  82969. * Interface for extending the exporter
  82970. * @hidden
  82971. */
  82972. export interface IGLTFExporterExtension {
  82973. /**
  82974. * The name of this extension
  82975. */
  82976. readonly name: string;
  82977. /**
  82978. * Defines whether this extension is enabled
  82979. */
  82980. enabled: boolean;
  82981. /**
  82982. * Defines whether this extension is required
  82983. */
  82984. required: boolean;
  82985. }
  82986. }
  82987. declare module BABYLON.GLTF2.Exporter {
  82988. /** @hidden */
  82989. export var __IGLTFExporterExtensionV2: number;
  82990. /**
  82991. * Interface for a glTF exporter extension
  82992. * @hidden
  82993. */
  82994. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82995. /**
  82996. * Define this method to modify the default behavior before exporting a texture
  82997. * @param context The context when loading the asset
  82998. * @param babylonTexture The Babylon.js texture
  82999. * @param mimeType The mime-type of the generated image
  83000. * @returns A promise that resolves with the exported texture
  83001. */
  83002. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83003. /**
  83004. * Define this method to get notified when a texture info is created
  83005. * @param context The context when loading the asset
  83006. * @param textureInfo The glTF texture info
  83007. * @param babylonTexture The Babylon.js texture
  83008. */
  83009. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83010. /**
  83011. * Define this method to modify the default behavior when exporting texture info
  83012. * @param context The context when loading the asset
  83013. * @param meshPrimitive glTF mesh primitive
  83014. * @param babylonSubMesh Babylon submesh
  83015. * @param binaryWriter glTF serializer binary writer instance
  83016. * @returns nullable IMeshPrimitive promise
  83017. */
  83018. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83019. /**
  83020. * Define this method to modify the default behavior when exporting a node
  83021. * @param context The context when exporting the node
  83022. * @param node glTF node
  83023. * @param babylonNode BabylonJS node
  83024. * @returns nullable INode promise
  83025. */
  83026. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83027. [key: number]: number;
  83028. }): Promise<Nullable<INode>>;
  83029. /**
  83030. * Define this method to modify the default behavior when exporting a material
  83031. * @param material glTF material
  83032. * @param babylonMaterial BabylonJS material
  83033. * @returns nullable IMaterial promise
  83034. */
  83035. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83036. /**
  83037. * Define this method to return additional textures to export from a material
  83038. * @param material glTF material
  83039. * @param babylonMaterial BabylonJS material
  83040. * @returns List of textures
  83041. */
  83042. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83043. /** Gets a boolean indicating that this extension was used */
  83044. wasUsed: boolean;
  83045. /** Gets a boolean indicating that this extension is required for the file to work */
  83046. required: boolean;
  83047. /**
  83048. * Called after the exporter state changes to EXPORTING
  83049. */
  83050. onExporting?(): void;
  83051. }
  83052. }
  83053. declare module BABYLON.GLTF2.Exporter {
  83054. /**
  83055. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83056. * @hidden
  83057. */
  83058. export class _GLTFMaterialExporter {
  83059. /**
  83060. * Represents the dielectric specular values for R, G and B
  83061. */
  83062. private static readonly _DielectricSpecular;
  83063. /**
  83064. * Allows the maximum specular power to be defined for material calculations
  83065. */
  83066. private static readonly _MaxSpecularPower;
  83067. /**
  83068. * Mapping to store textures
  83069. */
  83070. private _textureMap;
  83071. /**
  83072. * Numeric tolerance value
  83073. */
  83074. private static readonly _Epsilon;
  83075. /**
  83076. * Reference to the glTF Exporter
  83077. */
  83078. private _exporter;
  83079. constructor(exporter: _Exporter);
  83080. /**
  83081. * Specifies if two colors are approximately equal in value
  83082. * @param color1 first color to compare to
  83083. * @param color2 second color to compare to
  83084. * @param epsilon threshold value
  83085. */
  83086. private static FuzzyEquals;
  83087. /**
  83088. * Gets the materials from a Babylon scene and converts them to glTF materials
  83089. * @param scene babylonjs scene
  83090. * @param mimeType texture mime type
  83091. * @param images array of images
  83092. * @param textures array of textures
  83093. * @param materials array of materials
  83094. * @param imageData mapping of texture names to base64 textures
  83095. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83096. */
  83097. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83098. /**
  83099. * Makes a copy of the glTF material without the texture parameters
  83100. * @param originalMaterial original glTF material
  83101. * @returns glTF material without texture parameters
  83102. */
  83103. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83104. /**
  83105. * Specifies if the material has any texture parameters present
  83106. * @param material glTF Material
  83107. * @returns boolean specifying if texture parameters are present
  83108. */
  83109. _hasTexturesPresent(material: IMaterial): boolean;
  83110. /**
  83111. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83112. * @param babylonStandardMaterial
  83113. * @returns glTF Metallic Roughness Material representation
  83114. */
  83115. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83116. /**
  83117. * Computes the metallic factor
  83118. * @param diffuse diffused value
  83119. * @param specular specular value
  83120. * @param oneMinusSpecularStrength one minus the specular strength
  83121. * @returns metallic value
  83122. */
  83123. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83124. /**
  83125. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83126. * @param glTFMaterial glTF material
  83127. * @param babylonMaterial Babylon material
  83128. */
  83129. private static _SetAlphaMode;
  83130. /**
  83131. * Converts a Babylon Standard Material to a glTF Material
  83132. * @param babylonStandardMaterial BJS Standard Material
  83133. * @param mimeType mime type to use for the textures
  83134. * @param images array of glTF image interfaces
  83135. * @param textures array of glTF texture interfaces
  83136. * @param materials array of glTF material interfaces
  83137. * @param imageData map of image file name to data
  83138. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83139. */
  83140. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83141. private _finishMaterial;
  83142. /**
  83143. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83144. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83145. * @param mimeType mime type to use for the textures
  83146. * @param images array of glTF image interfaces
  83147. * @param textures array of glTF texture interfaces
  83148. * @param materials array of glTF material interfaces
  83149. * @param imageData map of image file name to data
  83150. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83151. */
  83152. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83153. /**
  83154. * Converts an image typed array buffer to a base64 image
  83155. * @param buffer typed array buffer
  83156. * @param width width of the image
  83157. * @param height height of the image
  83158. * @param mimeType mimetype of the image
  83159. * @returns base64 image string
  83160. */
  83161. private _createBase64FromCanvasAsync;
  83162. /**
  83163. * Generates a white texture based on the specified width and height
  83164. * @param width width of the texture in pixels
  83165. * @param height height of the texture in pixels
  83166. * @param scene babylonjs scene
  83167. * @returns white texture
  83168. */
  83169. private _createWhiteTexture;
  83170. /**
  83171. * 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
  83172. * @param texture1 first texture to resize
  83173. * @param texture2 second texture to resize
  83174. * @param scene babylonjs scene
  83175. * @returns resized textures or null
  83176. */
  83177. private _resizeTexturesToSameDimensions;
  83178. /**
  83179. * Converts an array of pixels to a Float32Array
  83180. * Throws an error if the pixel format is not supported
  83181. * @param pixels - array buffer containing pixel values
  83182. * @returns Float32 of pixels
  83183. */
  83184. private _convertPixelArrayToFloat32;
  83185. /**
  83186. * Convert Specular Glossiness Textures to Metallic Roughness
  83187. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83188. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83189. * @param diffuseTexture texture used to store diffuse information
  83190. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83191. * @param factors specular glossiness material factors
  83192. * @param mimeType the mime type to use for the texture
  83193. * @returns pbr metallic roughness interface or null
  83194. */
  83195. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83196. /**
  83197. * Converts specular glossiness material properties to metallic roughness
  83198. * @param specularGlossiness interface with specular glossiness material properties
  83199. * @returns interface with metallic roughness material properties
  83200. */
  83201. private _convertSpecularGlossinessToMetallicRoughness;
  83202. /**
  83203. * Calculates the surface reflectance, independent of lighting conditions
  83204. * @param color Color source to calculate brightness from
  83205. * @returns number representing the perceived brightness, or zero if color is undefined
  83206. */
  83207. private _getPerceivedBrightness;
  83208. /**
  83209. * Returns the maximum color component value
  83210. * @param color
  83211. * @returns maximum color component value, or zero if color is null or undefined
  83212. */
  83213. private _getMaxComponent;
  83214. /**
  83215. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83216. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83217. * @param mimeType mime type to use for the textures
  83218. * @param images array of glTF image interfaces
  83219. * @param textures array of glTF texture interfaces
  83220. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83221. * @param imageData map of image file name to data
  83222. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83223. * @returns glTF PBR Metallic Roughness factors
  83224. */
  83225. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83226. private _getGLTFTextureSampler;
  83227. private _getGLTFTextureWrapMode;
  83228. private _getGLTFTextureWrapModesSampler;
  83229. /**
  83230. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83231. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83232. * @param mimeType mime type to use for the textures
  83233. * @param images array of glTF image interfaces
  83234. * @param textures array of glTF texture interfaces
  83235. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83236. * @param imageData map of image file name to data
  83237. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83238. * @returns glTF PBR Metallic Roughness factors
  83239. */
  83240. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83241. /**
  83242. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83243. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83244. * @param mimeType mime type to use for the textures
  83245. * @param images array of glTF image interfaces
  83246. * @param textures array of glTF texture interfaces
  83247. * @param materials array of glTF material interfaces
  83248. * @param imageData map of image file name to data
  83249. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83250. */
  83251. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83252. private setMetallicRoughnessPbrMaterial;
  83253. private getPixelsFromTexture;
  83254. /**
  83255. * Extracts a texture from a Babylon texture into file data and glTF data
  83256. * @param babylonTexture Babylon texture to extract
  83257. * @param mimeType Mime Type of the babylonTexture
  83258. * @return glTF texture info, or null if the texture format is not supported
  83259. */
  83260. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83261. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83262. /**
  83263. * Builds a texture from base64 string
  83264. * @param base64Texture base64 texture string
  83265. * @param baseTextureName Name to use for the texture
  83266. * @param mimeType image mime type for the texture
  83267. * @param images array of images
  83268. * @param textures array of textures
  83269. * @param imageData map of image data
  83270. * @returns glTF texture info, or null if the texture format is not supported
  83271. */
  83272. private _getTextureInfoFromBase64;
  83273. }
  83274. }
  83275. declare module BABYLON {
  83276. /**
  83277. * Class for holding and downloading glTF file data
  83278. */
  83279. export class GLTFData {
  83280. /**
  83281. * Object which contains the file name as the key and its data as the value
  83282. */
  83283. glTFFiles: {
  83284. [fileName: string]: string | Blob;
  83285. };
  83286. /**
  83287. * Initializes the glTF file object
  83288. */
  83289. constructor();
  83290. /**
  83291. * Downloads the glTF data as files based on their names and data
  83292. */
  83293. downloadFiles(): void;
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /**
  83298. * Holds a collection of exporter options and parameters
  83299. */
  83300. export interface IExportOptions {
  83301. /**
  83302. * Function which indicates whether a babylon node should be exported or not
  83303. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83304. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83305. */
  83306. shouldExportNode?(node: Node): boolean;
  83307. /**
  83308. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83309. * @param metadata source metadata to read from
  83310. * @returns the data to store to glTF node extras
  83311. */
  83312. metadataSelector?(metadata: any): any;
  83313. /**
  83314. * The sample rate to bake animation curves
  83315. */
  83316. animationSampleRate?: number;
  83317. /**
  83318. * Begin serialization without waiting for the scene to be ready
  83319. */
  83320. exportWithoutWaitingForScene?: boolean;
  83321. /**
  83322. * Indicates if coordinate system swapping root nodes should be included in export
  83323. */
  83324. includeCoordinateSystemConversionNodes?: boolean;
  83325. }
  83326. /**
  83327. * Class for generating glTF data from a Babylon scene.
  83328. */
  83329. export class GLTF2Export {
  83330. /**
  83331. * Exports the geometry of the scene to .gltf file format asynchronously
  83332. * @param scene Babylon scene with scene hierarchy information
  83333. * @param filePrefix File prefix to use when generating the glTF file
  83334. * @param options Exporter options
  83335. * @returns Returns an object with a .gltf file and associates texture names
  83336. * as keys and their data and paths as values
  83337. */
  83338. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83339. private static _PreExportAsync;
  83340. private static _PostExportAsync;
  83341. /**
  83342. * Exports the geometry of the scene to .glb file format asychronously
  83343. * @param scene Babylon scene with scene hierarchy information
  83344. * @param filePrefix File prefix to use when generating glb file
  83345. * @param options Exporter options
  83346. * @returns Returns an object with a .glb filename as key and data as value
  83347. */
  83348. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83349. }
  83350. }
  83351. declare module BABYLON.GLTF2.Exporter {
  83352. /**
  83353. * @hidden
  83354. */
  83355. export class _GLTFUtilities {
  83356. /**
  83357. * Creates a buffer view based on the supplied arguments
  83358. * @param bufferIndex index value of the specified buffer
  83359. * @param byteOffset byte offset value
  83360. * @param byteLength byte length of the bufferView
  83361. * @param byteStride byte distance between conequential elements
  83362. * @param name name of the buffer view
  83363. * @returns bufferView for glTF
  83364. */
  83365. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83366. /**
  83367. * Creates an accessor based on the supplied arguments
  83368. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83369. * @param name The name of the accessor
  83370. * @param type The type of the accessor
  83371. * @param componentType The datatype of components in the attribute
  83372. * @param count The number of attributes referenced by this accessor
  83373. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83374. * @param min Minimum value of each component in this attribute
  83375. * @param max Maximum value of each component in this attribute
  83376. * @returns accessor for glTF
  83377. */
  83378. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83379. /**
  83380. * Calculates the minimum and maximum values of an array of position floats
  83381. * @param positions Positions array of a mesh
  83382. * @param vertexStart Starting vertex offset to calculate min and max values
  83383. * @param vertexCount Number of vertices to check for min and max values
  83384. * @returns min number array and max number array
  83385. */
  83386. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83387. min: number[];
  83388. max: number[];
  83389. };
  83390. /**
  83391. * Converts a new right-handed Vector3
  83392. * @param vector vector3 array
  83393. * @returns right-handed Vector3
  83394. */
  83395. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83396. /**
  83397. * Converts a Vector3 to right-handed
  83398. * @param vector Vector3 to convert to right-handed
  83399. */
  83400. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83401. /**
  83402. * Converts a three element number array to right-handed
  83403. * @param vector number array to convert to right-handed
  83404. */
  83405. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83406. /**
  83407. * Converts a new right-handed Vector3
  83408. * @param vector vector3 array
  83409. * @returns right-handed Vector3
  83410. */
  83411. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83412. /**
  83413. * Converts a Vector3 to right-handed
  83414. * @param vector Vector3 to convert to right-handed
  83415. */
  83416. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83417. /**
  83418. * Converts a three element number array to right-handed
  83419. * @param vector number array to convert to right-handed
  83420. */
  83421. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83422. /**
  83423. * Converts a Vector4 to right-handed
  83424. * @param vector Vector4 to convert to right-handed
  83425. */
  83426. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83427. /**
  83428. * Converts a Vector4 to right-handed
  83429. * @param vector Vector4 to convert to right-handed
  83430. */
  83431. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83432. /**
  83433. * Converts a Quaternion to right-handed
  83434. * @param quaternion Source quaternion to convert to right-handed
  83435. */
  83436. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83437. /**
  83438. * Converts a Quaternion to right-handed
  83439. * @param quaternion Source quaternion to convert to right-handed
  83440. */
  83441. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83442. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83443. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83444. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83445. }
  83446. }
  83447. declare module BABYLON.GLTF2.Exporter {
  83448. /**
  83449. * Converts Babylon Scene into glTF 2.0.
  83450. * @hidden
  83451. */
  83452. export class _Exporter {
  83453. /**
  83454. * Stores the glTF to export
  83455. */
  83456. _glTF: IGLTF;
  83457. /**
  83458. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83459. */
  83460. _bufferViews: IBufferView[];
  83461. /**
  83462. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83463. */
  83464. _accessors: IAccessor[];
  83465. /**
  83466. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83467. */
  83468. _nodes: INode[];
  83469. /**
  83470. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83471. */
  83472. private _scenes;
  83473. /**
  83474. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83475. */
  83476. private _meshes;
  83477. /**
  83478. * Stores all the generated material information, which represents the appearance of each primitive
  83479. */
  83480. _materials: IMaterial[];
  83481. _materialMap: {
  83482. [materialID: number]: number;
  83483. };
  83484. /**
  83485. * Stores all the generated texture information, which is referenced by glTF materials
  83486. */
  83487. _textures: ITexture[];
  83488. /**
  83489. * Stores all the generated image information, which is referenced by glTF textures
  83490. */
  83491. _images: IImage[];
  83492. /**
  83493. * Stores all the texture samplers
  83494. */
  83495. _samplers: ISampler[];
  83496. /**
  83497. * Stores all the generated glTF skins
  83498. */
  83499. _skins: ISkin[];
  83500. /**
  83501. * Stores all the generated animation samplers, which is referenced by glTF animations
  83502. */
  83503. /**
  83504. * Stores the animations for glTF models
  83505. */
  83506. private _animations;
  83507. /**
  83508. * Stores the total amount of bytes stored in the glTF buffer
  83509. */
  83510. private _totalByteLength;
  83511. /**
  83512. * Stores a reference to the Babylon scene containing the source geometry and material information
  83513. */
  83514. _babylonScene: Scene;
  83515. /**
  83516. * Stores a map of the image data, where the key is the file name and the value
  83517. * is the image data
  83518. */
  83519. _imageData: {
  83520. [fileName: string]: {
  83521. data: Uint8Array;
  83522. mimeType: ImageMimeType;
  83523. };
  83524. };
  83525. protected _orderedImageData: Array<{
  83526. data: Uint8Array;
  83527. mimeType: ImageMimeType;
  83528. }>;
  83529. /**
  83530. * Stores a map of the unique id of a node to its index in the node array
  83531. */
  83532. _nodeMap: {
  83533. [key: number]: number;
  83534. };
  83535. /**
  83536. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83537. */
  83538. _convertToRightHandedSystem: boolean;
  83539. /**
  83540. * Specifies if a Babylon node should be converted to right-handed on export
  83541. */
  83542. _convertToRightHandedSystemMap: {
  83543. [nodeId: number]: boolean;
  83544. };
  83545. _includeCoordinateSystemConversionNodes: boolean;
  83546. /**
  83547. * Baked animation sample rate
  83548. */
  83549. private _animationSampleRate;
  83550. private _options;
  83551. private _localEngine;
  83552. _glTFMaterialExporter: _GLTFMaterialExporter;
  83553. private _extensions;
  83554. private static _ExtensionNames;
  83555. private static _ExtensionFactories;
  83556. private _applyExtension;
  83557. private _applyExtensions;
  83558. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83559. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83560. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83561. [key: number]: number;
  83562. }): Promise<Nullable<INode>>;
  83563. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83564. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83565. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83566. private _forEachExtensions;
  83567. private _extensionsOnExporting;
  83568. /**
  83569. * Load glTF serializer extensions
  83570. */
  83571. private _loadExtensions;
  83572. /**
  83573. * Creates a glTF Exporter instance, which can accept optional exporter options
  83574. * @param babylonScene Babylon scene object
  83575. * @param options Options to modify the behavior of the exporter
  83576. */
  83577. constructor(babylonScene: Scene, options?: IExportOptions);
  83578. dispose(): void;
  83579. /**
  83580. * Registers a glTF exporter extension
  83581. * @param name Name of the extension to export
  83582. * @param factory The factory function that creates the exporter extension
  83583. */
  83584. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83585. /**
  83586. * Un-registers an exporter extension
  83587. * @param name The name fo the exporter extension
  83588. * @returns A boolean indicating whether the extension has been un-registered
  83589. */
  83590. static UnregisterExtension(name: string): boolean;
  83591. /**
  83592. * Lazy load a local engine
  83593. */
  83594. _getLocalEngine(): Engine;
  83595. private reorderIndicesBasedOnPrimitiveMode;
  83596. /**
  83597. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83598. * clock-wise during export to glTF
  83599. * @param submesh BabylonJS submesh
  83600. * @param primitiveMode Primitive mode of the mesh
  83601. * @param sideOrientation the winding order of the submesh
  83602. * @param vertexBufferKind The type of vertex attribute
  83603. * @param meshAttributeArray The vertex attribute data
  83604. * @param byteOffset The offset to the binary data
  83605. * @param binaryWriter The binary data for the glTF file
  83606. * @param convertToRightHandedSystem Converts the values to right-handed
  83607. */
  83608. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83609. /**
  83610. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83611. * clock-wise during export to glTF
  83612. * @param submesh BabylonJS submesh
  83613. * @param primitiveMode Primitive mode of the mesh
  83614. * @param sideOrientation the winding order of the submesh
  83615. * @param vertexBufferKind The type of vertex attribute
  83616. * @param meshAttributeArray The vertex attribute data
  83617. * @param byteOffset The offset to the binary data
  83618. * @param binaryWriter The binary data for the glTF file
  83619. * @param convertToRightHandedSystem Converts the values to right-handed
  83620. */
  83621. private reorderTriangleFillMode;
  83622. /**
  83623. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83624. * clock-wise during export to glTF
  83625. * @param submesh BabylonJS submesh
  83626. * @param primitiveMode Primitive mode of the mesh
  83627. * @param sideOrientation the winding order of the submesh
  83628. * @param vertexBufferKind The type of vertex attribute
  83629. * @param meshAttributeArray The vertex attribute data
  83630. * @param byteOffset The offset to the binary data
  83631. * @param binaryWriter The binary data for the glTF file
  83632. * @param convertToRightHandedSystem Converts the values to right-handed
  83633. */
  83634. private reorderTriangleStripDrawMode;
  83635. /**
  83636. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83637. * clock-wise during export to glTF
  83638. * @param submesh BabylonJS submesh
  83639. * @param primitiveMode Primitive mode of the mesh
  83640. * @param sideOrientation the winding order of the submesh
  83641. * @param vertexBufferKind The type of vertex attribute
  83642. * @param meshAttributeArray The vertex attribute data
  83643. * @param byteOffset The offset to the binary data
  83644. * @param binaryWriter The binary data for the glTF file
  83645. * @param convertToRightHandedSystem Converts the values to right-handed
  83646. */
  83647. private reorderTriangleFanMode;
  83648. /**
  83649. * Writes the vertex attribute data to binary
  83650. * @param vertices The vertices to write to the binary writer
  83651. * @param byteOffset The offset into the binary writer to overwrite binary data
  83652. * @param vertexAttributeKind The vertex attribute type
  83653. * @param meshAttributeArray The vertex attribute data
  83654. * @param binaryWriter The writer containing the binary data
  83655. * @param convertToRightHandedSystem Converts the values to right-handed
  83656. */
  83657. private writeVertexAttributeData;
  83658. /**
  83659. * Writes mesh attribute data to a data buffer
  83660. * Returns the bytelength of the data
  83661. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83662. * @param meshAttributeArray Array containing the attribute data
  83663. * @param byteStride Specifies the space between data
  83664. * @param binaryWriter The buffer to write the binary data to
  83665. * @param convertToRightHandedSystem Converts the values to right-handed
  83666. */
  83667. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83668. /**
  83669. * Writes mesh attribute data to a data buffer
  83670. * Returns the bytelength of the data
  83671. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83672. * @param meshAttributeArray Array containing the attribute data
  83673. * @param byteStride Specifies the space between data
  83674. * @param binaryWriter The buffer to write the binary data to
  83675. * @param convertToRightHandedSystem Converts the values to right-handed
  83676. */
  83677. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83678. /**
  83679. * Generates glTF json data
  83680. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83681. * @param glTFPrefix Text to use when prefixing a glTF file
  83682. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83683. * @returns json data as string
  83684. */
  83685. private generateJSON;
  83686. /**
  83687. * Generates data for .gltf and .bin files based on the glTF prefix string
  83688. * @param glTFPrefix Text to use when prefixing a glTF file
  83689. * @param dispose Dispose the exporter
  83690. * @returns GLTFData with glTF file data
  83691. */
  83692. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83693. /**
  83694. * Creates a binary buffer for glTF
  83695. * @returns array buffer for binary data
  83696. */
  83697. private _generateBinaryAsync;
  83698. /**
  83699. * Pads the number to a multiple of 4
  83700. * @param num number to pad
  83701. * @returns padded number
  83702. */
  83703. private _getPadding;
  83704. /**
  83705. * @hidden
  83706. */
  83707. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83708. /**
  83709. * Sets the TRS for each node
  83710. * @param node glTF Node for storing the transformation data
  83711. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83712. * @param convertToRightHandedSystem Converts the values to right-handed
  83713. */
  83714. private setNodeTransformation;
  83715. private getVertexBufferFromMesh;
  83716. /**
  83717. * Creates a bufferview based on the vertices type for the Babylon mesh
  83718. * @param kind Indicates the type of vertices data
  83719. * @param componentType Indicates the numerical type used to store the data
  83720. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83721. * @param binaryWriter The buffer to write the bufferview data to
  83722. * @param convertToRightHandedSystem Converts the values to right-handed
  83723. */
  83724. private createBufferViewKind;
  83725. /**
  83726. * Creates a bufferview based on the vertices type for the Babylon mesh
  83727. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83728. * @param babylonMorphTarget the morph target to be exported
  83729. * @param binaryWriter The buffer to write the bufferview data to
  83730. * @param convertToRightHandedSystem Converts the values to right-handed
  83731. */
  83732. private setMorphTargetAttributes;
  83733. /**
  83734. * The primitive mode of the Babylon mesh
  83735. * @param babylonMesh The BabylonJS mesh
  83736. */
  83737. private getMeshPrimitiveMode;
  83738. /**
  83739. * Sets the primitive mode of the glTF mesh primitive
  83740. * @param meshPrimitive glTF mesh primitive
  83741. * @param primitiveMode The primitive mode
  83742. */
  83743. private setPrimitiveMode;
  83744. /**
  83745. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83746. * @param meshPrimitive glTF mesh primitive
  83747. * @param attributeKind vertex attribute
  83748. * @returns boolean specifying if uv coordinates are present
  83749. */
  83750. private setAttributeKind;
  83751. /**
  83752. * Sets data for the primitive attributes of each submesh
  83753. * @param mesh glTF Mesh object to store the primitive attribute information
  83754. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83755. * @param binaryWriter Buffer to write the attribute data to
  83756. * @param convertToRightHandedSystem Converts the values to right-handed
  83757. */
  83758. private setPrimitiveAttributesAsync;
  83759. /**
  83760. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83761. * @param node The node to check
  83762. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83763. */
  83764. private isBabylonCoordinateSystemConvertingNode;
  83765. /**
  83766. * Creates a glTF scene based on the array of meshes
  83767. * Returns the the total byte offset
  83768. * @param babylonScene Babylon scene to get the mesh data from
  83769. * @param binaryWriter Buffer to write binary data to
  83770. */
  83771. private createSceneAsync;
  83772. /**
  83773. * Creates a mapping of Node unique id to node index and handles animations
  83774. * @param babylonScene Babylon Scene
  83775. * @param nodes Babylon transform nodes
  83776. * @param binaryWriter Buffer to write binary data to
  83777. * @returns Node mapping of unique id to index
  83778. */
  83779. private createNodeMapAndAnimationsAsync;
  83780. /**
  83781. * Creates a glTF node from a Babylon mesh
  83782. * @param babylonMesh Source Babylon mesh
  83783. * @param binaryWriter Buffer for storing geometry data
  83784. * @param convertToRightHandedSystem Converts the values to right-handed
  83785. * @param nodeMap Node mapping of unique id to glTF node index
  83786. * @returns glTF node
  83787. */
  83788. private createNodeAsync;
  83789. /**
  83790. * Creates a glTF skin from a Babylon skeleton
  83791. * @param babylonScene Babylon Scene
  83792. * @param nodes Babylon transform nodes
  83793. * @param binaryWriter Buffer to write binary data to
  83794. * @returns Node mapping of unique id to index
  83795. */
  83796. private createSkinsAsync;
  83797. }
  83798. /**
  83799. * @hidden
  83800. *
  83801. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83802. */
  83803. export class _BinaryWriter {
  83804. /**
  83805. * Array buffer which stores all binary data
  83806. */
  83807. private _arrayBuffer;
  83808. /**
  83809. * View of the array buffer
  83810. */
  83811. private _dataView;
  83812. /**
  83813. * byte offset of data in array buffer
  83814. */
  83815. private _byteOffset;
  83816. /**
  83817. * Initialize binary writer with an initial byte length
  83818. * @param byteLength Initial byte length of the array buffer
  83819. */
  83820. constructor(byteLength: number);
  83821. /**
  83822. * Resize the array buffer to the specified byte length
  83823. * @param byteLength
  83824. */
  83825. private resizeBuffer;
  83826. /**
  83827. * Get an array buffer with the length of the byte offset
  83828. * @returns ArrayBuffer resized to the byte offset
  83829. */
  83830. getArrayBuffer(): ArrayBuffer;
  83831. /**
  83832. * Get the byte offset of the array buffer
  83833. * @returns byte offset
  83834. */
  83835. getByteOffset(): number;
  83836. /**
  83837. * Stores an UInt8 in the array buffer
  83838. * @param entry
  83839. * @param byteOffset If defined, specifies where to set the value as an offset.
  83840. */
  83841. setUInt8(entry: number, byteOffset?: number): void;
  83842. /**
  83843. * Stores an UInt16 in the array buffer
  83844. * @param entry
  83845. * @param byteOffset If defined, specifies where to set the value as an offset.
  83846. */
  83847. setUInt16(entry: number, byteOffset?: number): void;
  83848. /**
  83849. * Gets an UInt32 in the array buffer
  83850. * @param entry
  83851. * @param byteOffset If defined, specifies where to set the value as an offset.
  83852. */
  83853. getUInt32(byteOffset: number): number;
  83854. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83855. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83856. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83857. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83858. /**
  83859. * Stores a Float32 in the array buffer
  83860. * @param entry
  83861. */
  83862. setFloat32(entry: number, byteOffset?: number): void;
  83863. /**
  83864. * Stores an UInt32 in the array buffer
  83865. * @param entry
  83866. * @param byteOffset If defined, specifies where to set the value as an offset.
  83867. */
  83868. setUInt32(entry: number, byteOffset?: number): void;
  83869. }
  83870. }
  83871. declare module BABYLON.GLTF2.Exporter {
  83872. /**
  83873. * @hidden
  83874. * Interface to store animation data.
  83875. */
  83876. export interface _IAnimationData {
  83877. /**
  83878. * Keyframe data.
  83879. */
  83880. inputs: number[];
  83881. /**
  83882. * Value data.
  83883. */
  83884. outputs: number[][];
  83885. /**
  83886. * Animation interpolation data.
  83887. */
  83888. samplerInterpolation: AnimationSamplerInterpolation;
  83889. /**
  83890. * Minimum keyframe value.
  83891. */
  83892. inputsMin: number;
  83893. /**
  83894. * Maximum keyframe value.
  83895. */
  83896. inputsMax: number;
  83897. }
  83898. /**
  83899. * @hidden
  83900. */
  83901. export interface _IAnimationInfo {
  83902. /**
  83903. * The target channel for the animation
  83904. */
  83905. animationChannelTargetPath: AnimationChannelTargetPath;
  83906. /**
  83907. * The glTF accessor type for the data.
  83908. */
  83909. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83910. /**
  83911. * Specifies if quaternions should be used.
  83912. */
  83913. useQuaternion: boolean;
  83914. }
  83915. /**
  83916. * @hidden
  83917. * Utility class for generating glTF animation data from BabylonJS.
  83918. */
  83919. export class _GLTFAnimation {
  83920. /**
  83921. * @ignore
  83922. *
  83923. * Creates glTF channel animation from BabylonJS animation.
  83924. * @param babylonTransformNode - BabylonJS mesh.
  83925. * @param animation - animation.
  83926. * @param animationChannelTargetPath - The target animation channel.
  83927. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83928. * @param useQuaternion - Specifies if quaternions are used.
  83929. * @returns nullable IAnimationData
  83930. */
  83931. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83932. private static _DeduceAnimationInfo;
  83933. /**
  83934. * @ignore
  83935. * Create node animations from the transform node animations
  83936. * @param babylonNode
  83937. * @param runtimeGLTFAnimation
  83938. * @param idleGLTFAnimations
  83939. * @param nodeMap
  83940. * @param nodes
  83941. * @param binaryWriter
  83942. * @param bufferViews
  83943. * @param accessors
  83944. * @param convertToRightHandedSystem
  83945. * @param animationSampleRate
  83946. */
  83947. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83948. [key: number]: number;
  83949. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83950. /**
  83951. * @ignore
  83952. * Create individual morph animations from the mesh's morph target animation tracks
  83953. * @param babylonNode
  83954. * @param runtimeGLTFAnimation
  83955. * @param idleGLTFAnimations
  83956. * @param nodeMap
  83957. * @param nodes
  83958. * @param binaryWriter
  83959. * @param bufferViews
  83960. * @param accessors
  83961. * @param convertToRightHandedSystem
  83962. * @param animationSampleRate
  83963. */
  83964. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83965. [key: number]: number;
  83966. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83967. /**
  83968. * @ignore
  83969. * Create node and morph animations from the animation groups
  83970. * @param babylonScene
  83971. * @param glTFAnimations
  83972. * @param nodeMap
  83973. * @param nodes
  83974. * @param binaryWriter
  83975. * @param bufferViews
  83976. * @param accessors
  83977. * @param convertToRightHandedSystemMap
  83978. * @param animationSampleRate
  83979. */
  83980. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83981. [key: number]: number;
  83982. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83983. [nodeId: number]: boolean;
  83984. }, animationSampleRate: number): void;
  83985. private static AddAnimation;
  83986. /**
  83987. * Create a baked animation
  83988. * @param babylonTransformNode BabylonJS mesh
  83989. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83990. * @param animationChannelTargetPath animation target channel
  83991. * @param minFrame minimum animation frame
  83992. * @param maxFrame maximum animation frame
  83993. * @param fps frames per second of the animation
  83994. * @param inputs input key frames of the animation
  83995. * @param outputs output key frame data of the animation
  83996. * @param convertToRightHandedSystem converts the values to right-handed
  83997. * @param useQuaternion specifies if quaternions should be used
  83998. */
  83999. private static _CreateBakedAnimation;
  84000. private static _ConvertFactorToVector3OrQuaternion;
  84001. private static _SetInterpolatedValue;
  84002. /**
  84003. * Creates linear animation from the animation key frames
  84004. * @param babylonTransformNode BabylonJS mesh
  84005. * @param animation BabylonJS animation
  84006. * @param animationChannelTargetPath The target animation channel
  84007. * @param frameDelta The difference between the last and first frame of the animation
  84008. * @param inputs Array to store the key frame times
  84009. * @param outputs Array to store the key frame data
  84010. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84011. * @param useQuaternion Specifies if quaternions are used in the animation
  84012. */
  84013. private static _CreateLinearOrStepAnimation;
  84014. /**
  84015. * Creates cubic spline animation from the animation key frames
  84016. * @param babylonTransformNode BabylonJS mesh
  84017. * @param animation BabylonJS animation
  84018. * @param animationChannelTargetPath The target animation channel
  84019. * @param frameDelta The difference between the last and first frame of the animation
  84020. * @param inputs Array to store the key frame times
  84021. * @param outputs Array to store the key frame data
  84022. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84023. * @param useQuaternion Specifies if quaternions are used in the animation
  84024. */
  84025. private static _CreateCubicSplineAnimation;
  84026. private static _GetBasePositionRotationOrScale;
  84027. /**
  84028. * Adds a key frame value
  84029. * @param keyFrame
  84030. * @param animation
  84031. * @param outputs
  84032. * @param animationChannelTargetPath
  84033. * @param basePositionRotationOrScale
  84034. * @param convertToRightHandedSystem
  84035. * @param useQuaternion
  84036. */
  84037. private static _AddKeyframeValue;
  84038. /**
  84039. * Determine the interpolation based on the key frames
  84040. * @param keyFrames
  84041. * @param animationChannelTargetPath
  84042. * @param useQuaternion
  84043. */
  84044. private static _DeduceInterpolation;
  84045. /**
  84046. * Adds an input tangent or output tangent to the output data
  84047. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84048. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84049. * @param outputs The animation data by keyframe
  84050. * @param animationChannelTargetPath The target animation channel
  84051. * @param interpolation The interpolation type
  84052. * @param keyFrame The key frame with the animation data
  84053. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84054. * @param useQuaternion Specifies if quaternions are used
  84055. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84056. */
  84057. private static AddSplineTangent;
  84058. /**
  84059. * Get the minimum and maximum key frames' frame values
  84060. * @param keyFrames animation key frames
  84061. * @returns the minimum and maximum key frame value
  84062. */
  84063. private static calculateMinMaxKeyFrames;
  84064. }
  84065. }
  84066. declare module BABYLON.GLTF2.Exporter {
  84067. /** @hidden */
  84068. export var textureTransformPixelShader: {
  84069. name: string;
  84070. shader: string;
  84071. };
  84072. }
  84073. declare module BABYLON.GLTF2.Exporter.Extensions {
  84074. /**
  84075. * @hidden
  84076. */
  84077. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84078. private _recordedTextures;
  84079. /** Name of this extension */
  84080. readonly name: string;
  84081. /** Defines whether this extension is enabled */
  84082. enabled: boolean;
  84083. /** Defines whether this extension is required */
  84084. required: boolean;
  84085. /** Reference to the glTF exporter */
  84086. private _wasUsed;
  84087. constructor(exporter: _Exporter);
  84088. dispose(): void;
  84089. /** @hidden */
  84090. get wasUsed(): boolean;
  84091. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84092. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84093. /**
  84094. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84095. * @param babylonTexture
  84096. * @param offset
  84097. * @param rotation
  84098. * @param scale
  84099. * @param scene
  84100. */
  84101. private _textureTransformTextureAsync;
  84102. }
  84103. }
  84104. declare module BABYLON.GLTF2.Exporter.Extensions {
  84105. /**
  84106. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84107. */
  84108. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84109. /** The name of this extension. */
  84110. readonly name: string;
  84111. /** Defines whether this extension is enabled. */
  84112. enabled: boolean;
  84113. /** Defines whether this extension is required */
  84114. required: boolean;
  84115. /** Reference to the glTF exporter */
  84116. private _exporter;
  84117. private _lights;
  84118. /** @hidden */
  84119. constructor(exporter: _Exporter);
  84120. /** @hidden */
  84121. dispose(): void;
  84122. /** @hidden */
  84123. get wasUsed(): boolean;
  84124. /** @hidden */
  84125. onExporting(): void;
  84126. /**
  84127. * Define this method to modify the default behavior when exporting a node
  84128. * @param context The context when exporting the node
  84129. * @param node glTF node
  84130. * @param babylonNode BabylonJS node
  84131. * @param nodeMap Node mapping of unique id to glTF node index
  84132. * @returns nullable INode promise
  84133. */
  84134. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84135. [key: number]: number;
  84136. }): Promise<Nullable<INode>>;
  84137. }
  84138. }
  84139. declare module BABYLON.GLTF2.Exporter.Extensions {
  84140. /**
  84141. * @hidden
  84142. */
  84143. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84144. /** Name of this extension */
  84145. readonly name: string;
  84146. /** Defines whether this extension is enabled */
  84147. enabled: boolean;
  84148. /** Defines whether this extension is required */
  84149. required: boolean;
  84150. /** Reference to the glTF exporter */
  84151. private _textureInfos;
  84152. private _exportedTextures;
  84153. private _wasUsed;
  84154. constructor(exporter: _Exporter);
  84155. dispose(): void;
  84156. /** @hidden */
  84157. get wasUsed(): boolean;
  84158. private _getTextureIndex;
  84159. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84160. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84161. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84162. }
  84163. }
  84164. declare module BABYLON.GLTF2.Exporter.Extensions {
  84165. /**
  84166. * @hidden
  84167. */
  84168. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84169. /** Name of this extension */
  84170. readonly name: string;
  84171. /** Defines whether this extension is enabled */
  84172. enabled: boolean;
  84173. /** Defines whether this extension is required */
  84174. required: boolean;
  84175. private _wasUsed;
  84176. constructor(exporter: _Exporter);
  84177. /** @hidden */
  84178. get wasUsed(): boolean;
  84179. dispose(): void;
  84180. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84181. }
  84182. }
  84183. declare module BABYLON {
  84184. /**
  84185. * Class for generating STL data from a Babylon scene.
  84186. */
  84187. export class STLExport {
  84188. /**
  84189. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84190. * @param meshes list defines the mesh to serialize
  84191. * @param download triggers the automatic download of the file.
  84192. * @param fileName changes the downloads fileName.
  84193. * @param binary changes the STL to a binary type.
  84194. * @param isLittleEndian toggle for binary type exporter.
  84195. * @returns the STL as UTF8 string
  84196. */
  84197. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84198. }
  84199. }
  84200. declare module "babylonjs-gltf2interface" {
  84201. export = BABYLON.GLTF2;
  84202. }
  84203. /**
  84204. * Module for glTF 2.0 Interface
  84205. */
  84206. declare module BABYLON.GLTF2 {
  84207. /**
  84208. * The datatype of the components in the attribute
  84209. */
  84210. const enum AccessorComponentType {
  84211. /**
  84212. * Byte
  84213. */
  84214. BYTE = 5120,
  84215. /**
  84216. * Unsigned Byte
  84217. */
  84218. UNSIGNED_BYTE = 5121,
  84219. /**
  84220. * Short
  84221. */
  84222. SHORT = 5122,
  84223. /**
  84224. * Unsigned Short
  84225. */
  84226. UNSIGNED_SHORT = 5123,
  84227. /**
  84228. * Unsigned Int
  84229. */
  84230. UNSIGNED_INT = 5125,
  84231. /**
  84232. * Float
  84233. */
  84234. FLOAT = 5126,
  84235. }
  84236. /**
  84237. * Specifies if the attirbute is a scalar, vector, or matrix
  84238. */
  84239. const enum AccessorType {
  84240. /**
  84241. * Scalar
  84242. */
  84243. SCALAR = "SCALAR",
  84244. /**
  84245. * Vector2
  84246. */
  84247. VEC2 = "VEC2",
  84248. /**
  84249. * Vector3
  84250. */
  84251. VEC3 = "VEC3",
  84252. /**
  84253. * Vector4
  84254. */
  84255. VEC4 = "VEC4",
  84256. /**
  84257. * Matrix2x2
  84258. */
  84259. MAT2 = "MAT2",
  84260. /**
  84261. * Matrix3x3
  84262. */
  84263. MAT3 = "MAT3",
  84264. /**
  84265. * Matrix4x4
  84266. */
  84267. MAT4 = "MAT4",
  84268. }
  84269. /**
  84270. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84271. */
  84272. const enum AnimationChannelTargetPath {
  84273. /**
  84274. * Translation
  84275. */
  84276. TRANSLATION = "translation",
  84277. /**
  84278. * Rotation
  84279. */
  84280. ROTATION = "rotation",
  84281. /**
  84282. * Scale
  84283. */
  84284. SCALE = "scale",
  84285. /**
  84286. * Weights
  84287. */
  84288. WEIGHTS = "weights",
  84289. }
  84290. /**
  84291. * Interpolation algorithm
  84292. */
  84293. const enum AnimationSamplerInterpolation {
  84294. /**
  84295. * The animated values are linearly interpolated between keyframes
  84296. */
  84297. LINEAR = "LINEAR",
  84298. /**
  84299. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84300. */
  84301. STEP = "STEP",
  84302. /**
  84303. * The animation's interpolation is computed using a cubic spline with specified tangents
  84304. */
  84305. CUBICSPLINE = "CUBICSPLINE",
  84306. }
  84307. /**
  84308. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84309. */
  84310. const enum CameraType {
  84311. /**
  84312. * A perspective camera containing properties to create a perspective projection matrix
  84313. */
  84314. PERSPECTIVE = "perspective",
  84315. /**
  84316. * An orthographic camera containing properties to create an orthographic projection matrix
  84317. */
  84318. ORTHOGRAPHIC = "orthographic",
  84319. }
  84320. /**
  84321. * The mime-type of the image
  84322. */
  84323. const enum ImageMimeType {
  84324. /**
  84325. * JPEG Mime-type
  84326. */
  84327. JPEG = "image/jpeg",
  84328. /**
  84329. * PNG Mime-type
  84330. */
  84331. PNG = "image/png",
  84332. }
  84333. /**
  84334. * The alpha rendering mode of the material
  84335. */
  84336. const enum MaterialAlphaMode {
  84337. /**
  84338. * The alpha value is ignored and the rendered output is fully opaque
  84339. */
  84340. OPAQUE = "OPAQUE",
  84341. /**
  84342. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84343. */
  84344. MASK = "MASK",
  84345. /**
  84346. * 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)
  84347. */
  84348. BLEND = "BLEND",
  84349. }
  84350. /**
  84351. * The type of the primitives to render
  84352. */
  84353. const enum MeshPrimitiveMode {
  84354. /**
  84355. * Points
  84356. */
  84357. POINTS = 0,
  84358. /**
  84359. * Lines
  84360. */
  84361. LINES = 1,
  84362. /**
  84363. * Line Loop
  84364. */
  84365. LINE_LOOP = 2,
  84366. /**
  84367. * Line Strip
  84368. */
  84369. LINE_STRIP = 3,
  84370. /**
  84371. * Triangles
  84372. */
  84373. TRIANGLES = 4,
  84374. /**
  84375. * Triangle Strip
  84376. */
  84377. TRIANGLE_STRIP = 5,
  84378. /**
  84379. * Triangle Fan
  84380. */
  84381. TRIANGLE_FAN = 6,
  84382. }
  84383. /**
  84384. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84385. */
  84386. const enum TextureMagFilter {
  84387. /**
  84388. * Nearest
  84389. */
  84390. NEAREST = 9728,
  84391. /**
  84392. * Linear
  84393. */
  84394. LINEAR = 9729,
  84395. }
  84396. /**
  84397. * Minification filter. All valid values correspond to WebGL enums
  84398. */
  84399. const enum TextureMinFilter {
  84400. /**
  84401. * Nearest
  84402. */
  84403. NEAREST = 9728,
  84404. /**
  84405. * Linear
  84406. */
  84407. LINEAR = 9729,
  84408. /**
  84409. * Nearest Mip-Map Nearest
  84410. */
  84411. NEAREST_MIPMAP_NEAREST = 9984,
  84412. /**
  84413. * Linear Mipmap Nearest
  84414. */
  84415. LINEAR_MIPMAP_NEAREST = 9985,
  84416. /**
  84417. * Nearest Mipmap Linear
  84418. */
  84419. NEAREST_MIPMAP_LINEAR = 9986,
  84420. /**
  84421. * Linear Mipmap Linear
  84422. */
  84423. LINEAR_MIPMAP_LINEAR = 9987,
  84424. }
  84425. /**
  84426. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84427. */
  84428. const enum TextureWrapMode {
  84429. /**
  84430. * Clamp to Edge
  84431. */
  84432. CLAMP_TO_EDGE = 33071,
  84433. /**
  84434. * Mirrored Repeat
  84435. */
  84436. MIRRORED_REPEAT = 33648,
  84437. /**
  84438. * Repeat
  84439. */
  84440. REPEAT = 10497,
  84441. }
  84442. /**
  84443. * glTF Property
  84444. */
  84445. interface IProperty {
  84446. /**
  84447. * Dictionary object with extension-specific objects
  84448. */
  84449. extensions?: {
  84450. [key: string]: any;
  84451. };
  84452. /**
  84453. * Application-Specific data
  84454. */
  84455. extras?: any;
  84456. }
  84457. /**
  84458. * glTF Child of Root Property
  84459. */
  84460. interface IChildRootProperty extends IProperty {
  84461. /**
  84462. * The user-defined name of this object
  84463. */
  84464. name?: string;
  84465. }
  84466. /**
  84467. * Indices of those attributes that deviate from their initialization value
  84468. */
  84469. interface IAccessorSparseIndices extends IProperty {
  84470. /**
  84471. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84472. */
  84473. bufferView: number;
  84474. /**
  84475. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84476. */
  84477. byteOffset?: number;
  84478. /**
  84479. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84480. */
  84481. componentType: AccessorComponentType;
  84482. }
  84483. /**
  84484. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84485. */
  84486. interface IAccessorSparseValues extends IProperty {
  84487. /**
  84488. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84489. */
  84490. bufferView: number;
  84491. /**
  84492. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84493. */
  84494. byteOffset?: number;
  84495. }
  84496. /**
  84497. * Sparse storage of attributes that deviate from their initialization value
  84498. */
  84499. interface IAccessorSparse extends IProperty {
  84500. /**
  84501. * The number of attributes encoded in this sparse accessor
  84502. */
  84503. count: number;
  84504. /**
  84505. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84506. */
  84507. indices: IAccessorSparseIndices;
  84508. /**
  84509. * 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
  84510. */
  84511. values: IAccessorSparseValues;
  84512. }
  84513. /**
  84514. * 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
  84515. */
  84516. interface IAccessor extends IChildRootProperty {
  84517. /**
  84518. * The index of the bufferview
  84519. */
  84520. bufferView?: number;
  84521. /**
  84522. * The offset relative to the start of the bufferView in bytes
  84523. */
  84524. byteOffset?: number;
  84525. /**
  84526. * The datatype of components in the attribute
  84527. */
  84528. componentType: AccessorComponentType;
  84529. /**
  84530. * Specifies whether integer data values should be normalized
  84531. */
  84532. normalized?: boolean;
  84533. /**
  84534. * The number of attributes referenced by this accessor
  84535. */
  84536. count: number;
  84537. /**
  84538. * Specifies if the attribute is a scalar, vector, or matrix
  84539. */
  84540. type: AccessorType;
  84541. /**
  84542. * Maximum value of each component in this attribute
  84543. */
  84544. max?: number[];
  84545. /**
  84546. * Minimum value of each component in this attribute
  84547. */
  84548. min?: number[];
  84549. /**
  84550. * Sparse storage of attributes that deviate from their initialization value
  84551. */
  84552. sparse?: IAccessorSparse;
  84553. }
  84554. /**
  84555. * Targets an animation's sampler at a node's property
  84556. */
  84557. interface IAnimationChannel extends IProperty {
  84558. /**
  84559. * The index of a sampler in this animation used to compute the value for the target
  84560. */
  84561. sampler: number;
  84562. /**
  84563. * The index of the node and TRS property to target
  84564. */
  84565. target: IAnimationChannelTarget;
  84566. }
  84567. /**
  84568. * The index of the node and TRS property that an animation channel targets
  84569. */
  84570. interface IAnimationChannelTarget extends IProperty {
  84571. /**
  84572. * The index of the node to target
  84573. */
  84574. node: number;
  84575. /**
  84576. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84577. */
  84578. path: AnimationChannelTargetPath;
  84579. }
  84580. /**
  84581. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84582. */
  84583. interface IAnimationSampler extends IProperty {
  84584. /**
  84585. * The index of an accessor containing keyframe input values, e.g., time
  84586. */
  84587. input: number;
  84588. /**
  84589. * Interpolation algorithm
  84590. */
  84591. interpolation?: AnimationSamplerInterpolation;
  84592. /**
  84593. * The index of an accessor, containing keyframe output values
  84594. */
  84595. output: number;
  84596. }
  84597. /**
  84598. * A keyframe animation
  84599. */
  84600. interface IAnimation extends IChildRootProperty {
  84601. /**
  84602. * An array of channels, each of which targets an animation's sampler at a node's property
  84603. */
  84604. channels: IAnimationChannel[];
  84605. /**
  84606. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84607. */
  84608. samplers: IAnimationSampler[];
  84609. }
  84610. /**
  84611. * Metadata about the glTF asset
  84612. */
  84613. interface IAsset extends IChildRootProperty {
  84614. /**
  84615. * A copyright message suitable for display to credit the content creator
  84616. */
  84617. copyright?: string;
  84618. /**
  84619. * Tool that generated this glTF model. Useful for debugging
  84620. */
  84621. generator?: string;
  84622. /**
  84623. * The glTF version that this asset targets
  84624. */
  84625. version: string;
  84626. /**
  84627. * The minimum glTF version that this asset targets
  84628. */
  84629. minVersion?: string;
  84630. }
  84631. /**
  84632. * A buffer points to binary geometry, animation, or skins
  84633. */
  84634. interface IBuffer extends IChildRootProperty {
  84635. /**
  84636. * 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
  84637. */
  84638. uri?: string;
  84639. /**
  84640. * The length of the buffer in bytes
  84641. */
  84642. byteLength: number;
  84643. }
  84644. /**
  84645. * A view into a buffer generally representing a subset of the buffer
  84646. */
  84647. interface IBufferView extends IChildRootProperty {
  84648. /**
  84649. * The index of the buffer
  84650. */
  84651. buffer: number;
  84652. /**
  84653. * The offset into the buffer in bytes
  84654. */
  84655. byteOffset?: number;
  84656. /**
  84657. * The lenth of the bufferView in bytes
  84658. */
  84659. byteLength: number;
  84660. /**
  84661. * The stride, in bytes
  84662. */
  84663. byteStride?: number;
  84664. }
  84665. /**
  84666. * An orthographic camera containing properties to create an orthographic projection matrix
  84667. */
  84668. interface ICameraOrthographic extends IProperty {
  84669. /**
  84670. * The floating-point horizontal magnification of the view. Must not be zero
  84671. */
  84672. xmag: number;
  84673. /**
  84674. * The floating-point vertical magnification of the view. Must not be zero
  84675. */
  84676. ymag: number;
  84677. /**
  84678. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84679. */
  84680. zfar: number;
  84681. /**
  84682. * The floating-point distance to the near clipping plane
  84683. */
  84684. znear: number;
  84685. }
  84686. /**
  84687. * A perspective camera containing properties to create a perspective projection matrix
  84688. */
  84689. interface ICameraPerspective extends IProperty {
  84690. /**
  84691. * The floating-point aspect ratio of the field of view
  84692. */
  84693. aspectRatio?: number;
  84694. /**
  84695. * The floating-point vertical field of view in radians
  84696. */
  84697. yfov: number;
  84698. /**
  84699. * The floating-point distance to the far clipping plane
  84700. */
  84701. zfar?: number;
  84702. /**
  84703. * The floating-point distance to the near clipping plane
  84704. */
  84705. znear: number;
  84706. }
  84707. /**
  84708. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84709. */
  84710. interface ICamera extends IChildRootProperty {
  84711. /**
  84712. * An orthographic camera containing properties to create an orthographic projection matrix
  84713. */
  84714. orthographic?: ICameraOrthographic;
  84715. /**
  84716. * A perspective camera containing properties to create a perspective projection matrix
  84717. */
  84718. perspective?: ICameraPerspective;
  84719. /**
  84720. * Specifies if the camera uses a perspective or orthographic projection
  84721. */
  84722. type: CameraType;
  84723. }
  84724. /**
  84725. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84726. */
  84727. interface IImage extends IChildRootProperty {
  84728. /**
  84729. * 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
  84730. */
  84731. uri?: string;
  84732. /**
  84733. * The image's MIME type
  84734. */
  84735. mimeType?: ImageMimeType;
  84736. /**
  84737. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84738. */
  84739. bufferView?: number;
  84740. }
  84741. /**
  84742. * Material Normal Texture Info
  84743. */
  84744. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84745. /**
  84746. * The scalar multiplier applied to each normal vector of the normal texture
  84747. */
  84748. scale?: number;
  84749. }
  84750. /**
  84751. * Material Occlusion Texture Info
  84752. */
  84753. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84754. /**
  84755. * A scalar multiplier controlling the amount of occlusion applied
  84756. */
  84757. strength?: number;
  84758. }
  84759. /**
  84760. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84761. */
  84762. interface IMaterialPbrMetallicRoughness {
  84763. /**
  84764. * The material's base color factor
  84765. */
  84766. baseColorFactor?: number[];
  84767. /**
  84768. * The base color texture
  84769. */
  84770. baseColorTexture?: ITextureInfo;
  84771. /**
  84772. * The metalness of the material
  84773. */
  84774. metallicFactor?: number;
  84775. /**
  84776. * The roughness of the material
  84777. */
  84778. roughnessFactor?: number;
  84779. /**
  84780. * The metallic-roughness texture
  84781. */
  84782. metallicRoughnessTexture?: ITextureInfo;
  84783. }
  84784. /**
  84785. * The material appearance of a primitive
  84786. */
  84787. interface IMaterial extends IChildRootProperty {
  84788. /**
  84789. * 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
  84790. */
  84791. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84792. /**
  84793. * The normal map texture
  84794. */
  84795. normalTexture?: IMaterialNormalTextureInfo;
  84796. /**
  84797. * The occlusion map texture
  84798. */
  84799. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84800. /**
  84801. * The emissive map texture
  84802. */
  84803. emissiveTexture?: ITextureInfo;
  84804. /**
  84805. * 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
  84806. */
  84807. emissiveFactor?: number[];
  84808. /**
  84809. * The alpha rendering mode of the material
  84810. */
  84811. alphaMode?: MaterialAlphaMode;
  84812. /**
  84813. * The alpha cutoff value of the material
  84814. */
  84815. alphaCutoff?: number;
  84816. /**
  84817. * Specifies whether the material is double sided
  84818. */
  84819. doubleSided?: boolean;
  84820. }
  84821. /**
  84822. * Geometry to be rendered with the given material
  84823. */
  84824. interface IMeshPrimitive extends IProperty {
  84825. /**
  84826. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84827. */
  84828. attributes: {
  84829. [name: string]: number;
  84830. };
  84831. /**
  84832. * The index of the accessor that contains the indices
  84833. */
  84834. indices?: number;
  84835. /**
  84836. * The index of the material to apply to this primitive when rendering
  84837. */
  84838. material?: number;
  84839. /**
  84840. * The type of primitives to render. All valid values correspond to WebGL enums
  84841. */
  84842. mode?: MeshPrimitiveMode;
  84843. /**
  84844. * 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
  84845. */
  84846. targets?: {
  84847. [name: string]: number;
  84848. }[];
  84849. }
  84850. /**
  84851. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84852. */
  84853. interface IMesh extends IChildRootProperty {
  84854. /**
  84855. * An array of primitives, each defining geometry to be rendered with a material
  84856. */
  84857. primitives: IMeshPrimitive[];
  84858. /**
  84859. * Array of weights to be applied to the Morph Targets
  84860. */
  84861. weights?: number[];
  84862. }
  84863. /**
  84864. * A node in the node hierarchy
  84865. */
  84866. interface INode extends IChildRootProperty {
  84867. /**
  84868. * The index of the camera referenced by this node
  84869. */
  84870. camera?: number;
  84871. /**
  84872. * The indices of this node's children
  84873. */
  84874. children?: number[];
  84875. /**
  84876. * The index of the skin referenced by this node
  84877. */
  84878. skin?: number;
  84879. /**
  84880. * A floating-point 4x4 transformation matrix stored in column-major order
  84881. */
  84882. matrix?: number[];
  84883. /**
  84884. * The index of the mesh in this node
  84885. */
  84886. mesh?: number;
  84887. /**
  84888. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84889. */
  84890. rotation?: number[];
  84891. /**
  84892. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84893. */
  84894. scale?: number[];
  84895. /**
  84896. * The node's translation along the x, y, and z axes
  84897. */
  84898. translation?: number[];
  84899. /**
  84900. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84901. */
  84902. weights?: number[];
  84903. }
  84904. /**
  84905. * Texture sampler properties for filtering and wrapping modes
  84906. */
  84907. interface ISampler extends IChildRootProperty {
  84908. /**
  84909. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84910. */
  84911. magFilter?: TextureMagFilter;
  84912. /**
  84913. * Minification filter. All valid values correspond to WebGL enums
  84914. */
  84915. minFilter?: TextureMinFilter;
  84916. /**
  84917. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84918. */
  84919. wrapS?: TextureWrapMode;
  84920. /**
  84921. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84922. */
  84923. wrapT?: TextureWrapMode;
  84924. }
  84925. /**
  84926. * The root nodes of a scene
  84927. */
  84928. interface IScene extends IChildRootProperty {
  84929. /**
  84930. * The indices of each root node
  84931. */
  84932. nodes: number[];
  84933. }
  84934. /**
  84935. * Joints and matrices defining a skin
  84936. */
  84937. interface ISkin extends IChildRootProperty {
  84938. /**
  84939. * 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
  84940. */
  84941. inverseBindMatrices?: number;
  84942. /**
  84943. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84944. */
  84945. skeleton?: number;
  84946. /**
  84947. * 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)
  84948. */
  84949. joints: number[];
  84950. }
  84951. /**
  84952. * A texture and its sampler
  84953. */
  84954. interface ITexture extends IChildRootProperty {
  84955. /**
  84956. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84957. */
  84958. sampler?: number;
  84959. /**
  84960. * The index of the image used by this texture
  84961. */
  84962. source: number;
  84963. }
  84964. /**
  84965. * Reference to a texture
  84966. */
  84967. interface ITextureInfo extends IProperty {
  84968. /**
  84969. * The index of the texture
  84970. */
  84971. index: number;
  84972. /**
  84973. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84974. */
  84975. texCoord?: number;
  84976. }
  84977. /**
  84978. * The root object for a glTF asset
  84979. */
  84980. interface IGLTF extends IProperty {
  84981. /**
  84982. * An array of accessors. An accessor is a typed view into a bufferView
  84983. */
  84984. accessors?: IAccessor[];
  84985. /**
  84986. * An array of keyframe animations
  84987. */
  84988. animations?: IAnimation[];
  84989. /**
  84990. * Metadata about the glTF asset
  84991. */
  84992. asset: IAsset;
  84993. /**
  84994. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84995. */
  84996. buffers?: IBuffer[];
  84997. /**
  84998. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84999. */
  85000. bufferViews?: IBufferView[];
  85001. /**
  85002. * An array of cameras
  85003. */
  85004. cameras?: ICamera[];
  85005. /**
  85006. * Names of glTF extensions used somewhere in this asset
  85007. */
  85008. extensionsUsed?: string[];
  85009. /**
  85010. * Names of glTF extensions required to properly load this asset
  85011. */
  85012. extensionsRequired?: string[];
  85013. /**
  85014. * An array of images. An image defines data used to create a texture
  85015. */
  85016. images?: IImage[];
  85017. /**
  85018. * An array of materials. A material defines the appearance of a primitive
  85019. */
  85020. materials?: IMaterial[];
  85021. /**
  85022. * An array of meshes. A mesh is a set of primitives to be rendered
  85023. */
  85024. meshes?: IMesh[];
  85025. /**
  85026. * An array of nodes
  85027. */
  85028. nodes?: INode[];
  85029. /**
  85030. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85031. */
  85032. samplers?: ISampler[];
  85033. /**
  85034. * The index of the default scene
  85035. */
  85036. scene?: number;
  85037. /**
  85038. * An array of scenes
  85039. */
  85040. scenes?: IScene[];
  85041. /**
  85042. * An array of skins. A skin is defined by joints and matrices
  85043. */
  85044. skins?: ISkin[];
  85045. /**
  85046. * An array of textures
  85047. */
  85048. textures?: ITexture[];
  85049. }
  85050. /**
  85051. * The glTF validation results
  85052. * @ignore
  85053. */
  85054. interface IGLTFValidationResults {
  85055. info: {
  85056. generator: string;
  85057. hasAnimations: boolean;
  85058. hasDefaultScene: boolean;
  85059. hasMaterials: boolean;
  85060. hasMorphTargets: boolean;
  85061. hasSkins: boolean;
  85062. hasTextures: boolean;
  85063. maxAttributesUsed: number;
  85064. primitivesCount: number
  85065. };
  85066. issues: {
  85067. messages: Array<string>;
  85068. numErrors: number;
  85069. numHints: number;
  85070. numInfos: number;
  85071. numWarnings: number;
  85072. truncated: boolean
  85073. };
  85074. mimeType: string;
  85075. uri: string;
  85076. validatedAt: string;
  85077. validatorVersion: string;
  85078. }
  85079. /**
  85080. * The glTF validation options
  85081. */
  85082. interface IGLTFValidationOptions {
  85083. /** Uri to use */
  85084. uri?: string;
  85085. /** Function used to load external resources */
  85086. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85087. /** Boolean indicating that we need to validate accessor data */
  85088. validateAccessorData?: boolean;
  85089. /** max number of issues allowed */
  85090. maxIssues?: number;
  85091. /** Ignored issues */
  85092. ignoredIssues?: Array<string>;
  85093. /** Value to override severy settings */
  85094. severityOverrides?: Object;
  85095. }
  85096. /**
  85097. * The glTF validator object
  85098. * @ignore
  85099. */
  85100. interface IGLTFValidator {
  85101. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85102. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85103. }
  85104. /**
  85105. * Interfaces from the EXT_lights_image_based extension
  85106. */
  85107. /** @hidden */
  85108. interface IEXTLightsImageBased_LightReferenceImageBased {
  85109. light: number;
  85110. }
  85111. /** @hidden */
  85112. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85113. intensity: number;
  85114. rotation: number[];
  85115. specularImageSize: number;
  85116. specularImages: number[][];
  85117. irradianceCoefficients: number[][];
  85118. }
  85119. /** @hidden */
  85120. interface IEXTLightsImageBased {
  85121. lights: IEXTLightsImageBased_LightImageBased[];
  85122. }
  85123. /**
  85124. * Interfaces from the EXT_mesh_gpu_instancing extension
  85125. * !!! Experimental Extension Subject to Changes !!!
  85126. */
  85127. /** @hidden */
  85128. interface IEXTMeshGpuInstancing {
  85129. mesh?: number;
  85130. attributes: { [name: string]: number };
  85131. }
  85132. /**
  85133. * Interfaces from the KHR_draco_mesh_compression extension
  85134. */
  85135. /** @hidden */
  85136. interface IKHRDracoMeshCompression {
  85137. bufferView: number;
  85138. attributes: { [name: string]: number };
  85139. }
  85140. /**
  85141. * Interfaces from the KHR_lights_punctual extension
  85142. */
  85143. /** @hidden */
  85144. const enum IKHRLightsPunctual_LightType {
  85145. DIRECTIONAL = "directional",
  85146. POINT = "point",
  85147. SPOT = "spot"
  85148. }
  85149. /** @hidden */
  85150. interface IKHRLightsPunctual_LightReference {
  85151. light: number;
  85152. }
  85153. /** @hidden */
  85154. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85155. type: IKHRLightsPunctual_LightType;
  85156. color?: number[];
  85157. intensity?: number;
  85158. range?: number;
  85159. spot?: {
  85160. innerConeAngle?: number;
  85161. outerConeAngle?: number;
  85162. };
  85163. }
  85164. /** @hidden */
  85165. interface IKHRLightsPunctual {
  85166. lights: IKHRLightsPunctual_Light[];
  85167. }
  85168. /**
  85169. * Interfaces from the KHR_materials_clearcoat extension
  85170. * !!! Experimental Extension Subject to Changes !!!
  85171. */
  85172. /** @hidden */
  85173. interface IKHRMaterialsClearcoat {
  85174. clearcoatFactor: number;
  85175. clearcoatTexture: ITextureInfo;
  85176. clearcoatRoughnessFactor: number;
  85177. clearcoatRoughnessTexture: ITextureInfo;
  85178. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85179. }
  85180. /**
  85181. * Interfaces from the KHR_materials_ior extension
  85182. * !!! Experimental Extension Subject to Changes !!!
  85183. */
  85184. /** @hidden */
  85185. interface IKHRMaterialsIor {
  85186. ior: number;
  85187. }
  85188. /**
  85189. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85190. */
  85191. /** @hidden */
  85192. interface IKHRMaterialsPbrSpecularGlossiness {
  85193. diffuseFactor: number[];
  85194. diffuseTexture: ITextureInfo;
  85195. specularFactor: number[];
  85196. glossinessFactor: number;
  85197. specularGlossinessTexture: ITextureInfo;
  85198. }
  85199. /**
  85200. * Interfaces from the KHR_materials_sheen extension
  85201. * !!! Experimental Extension Subject to Changes !!!
  85202. */
  85203. /** @hidden */
  85204. interface IKHRMaterialsSheen {
  85205. sheenColorFactor?: number[];
  85206. sheenTexture?: ITextureInfo;
  85207. sheenRoughnessFactor?: number;
  85208. }
  85209. /**
  85210. * Interfaces from the KHR_materials_specular extension
  85211. * !!! Experimental Extension Subject to Changes !!!
  85212. */
  85213. /** @hidden */
  85214. interface IKHRMaterialsSpecular {
  85215. specularFactor: number;
  85216. specularColorFactor: number[];
  85217. specularTexture: ITextureInfo;
  85218. }
  85219. /**
  85220. * Interfaces from the KHR_materials_transmission extension
  85221. * !!! Experimental Extension Subject to Changes !!!
  85222. */
  85223. /** @hidden */
  85224. interface IKHRMaterialsTransmission {
  85225. transmissionFactor?: number;
  85226. transmissionTexture?: ITextureInfo;
  85227. }
  85228. /**
  85229. * Interfaces from the KHR_materials_variants extension
  85230. * !!! Experimental Extension Subject to Changes !!!
  85231. */
  85232. /** @hidden */
  85233. interface IKHRMaterialVariants_Mapping extends IProperty {
  85234. mappings: Array<{
  85235. variants: number[];
  85236. material: number;
  85237. }>;
  85238. }
  85239. /** @hidden */
  85240. interface IKHRMaterialVariants_Variant extends IProperty {
  85241. name: string;
  85242. }
  85243. /** @hidden */
  85244. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85245. variants: Array<IKHRMaterialVariants_Variant>;
  85246. }
  85247. /**
  85248. * Interfaces from the KHR_texture_basisu extension
  85249. * !!! Experimental Extension Subject to Changes !!!
  85250. */
  85251. /** @hidden */
  85252. interface IKHRTextureBasisU {
  85253. source: number;
  85254. }
  85255. /**
  85256. * Interfaces from the EXT_texture_webp extension
  85257. */
  85258. /** @hidden */
  85259. interface IEXTTextureWebP {
  85260. source: number;
  85261. }
  85262. /**
  85263. * Interfaces from the KHR_texture_transform extension
  85264. */
  85265. /** @hidden */
  85266. interface IKHRTextureTransform {
  85267. offset?: number[];
  85268. rotation?: number;
  85269. scale?: number[];
  85270. texCoord?: number;
  85271. }
  85272. /**
  85273. * Interfaces from the KHR_xmp extension
  85274. * !!! Experimental Extension Subject to Changes !!!
  85275. */
  85276. /** @hidden */
  85277. interface IKHRXmp_Data {
  85278. [key: string]: unknown;
  85279. }
  85280. /** @hidden */
  85281. interface IKHRXmp_Gltf {
  85282. packets: IKHRXmp_Data[];
  85283. }
  85284. /** @hidden */
  85285. interface IKHRXmp_Node {
  85286. packet: number;
  85287. }
  85288. /**
  85289. * Interfaces from the MSFT_audio_emitter extension
  85290. */
  85291. /** @hidden */
  85292. interface IMSFTAudioEmitter_ClipReference {
  85293. clip: number;
  85294. weight?: number;
  85295. }
  85296. /** @hidden */
  85297. interface IMSFTAudioEmitter_EmittersReference {
  85298. emitters: number[];
  85299. }
  85300. /** @hidden */
  85301. const enum IMSFTAudioEmitter_DistanceModel {
  85302. linear = "linear",
  85303. inverse = "inverse",
  85304. exponential = "exponential",
  85305. }
  85306. /** @hidden */
  85307. interface IMSFTAudioEmitter_Emitter {
  85308. name?: string;
  85309. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85310. refDistance?: number;
  85311. maxDistance?: number;
  85312. rolloffFactor?: number;
  85313. innerAngle?: number;
  85314. outerAngle?: number;
  85315. loop?: boolean;
  85316. volume?: number;
  85317. clips: IMSFTAudioEmitter_ClipReference[];
  85318. }
  85319. /** @hidden */
  85320. const enum IMSFTAudioEmitter_AudioMimeType {
  85321. WAV = "audio/wav",
  85322. }
  85323. /** @hidden */
  85324. interface IMSFTAudioEmitter_Clip extends IProperty {
  85325. uri?: string;
  85326. bufferView?: number;
  85327. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85328. }
  85329. /** @hidden */
  85330. const enum IMSFTAudioEmitter_AnimationEventAction {
  85331. play = "play",
  85332. pause = "pause",
  85333. stop = "stop",
  85334. }
  85335. /** @hidden */
  85336. interface IMSFTAudioEmitter_AnimationEvent {
  85337. action: IMSFTAudioEmitter_AnimationEventAction;
  85338. emitter: number;
  85339. time: number;
  85340. startOffset?: number;
  85341. }
  85342. /**
  85343. * Interfaces from the MSFT_lod extension
  85344. */
  85345. /** @hidden */
  85346. interface IMSFTLOD {
  85347. ids: number[];
  85348. }
  85349. }
  85350. declare module BABYLON {
  85351. /** @hidden */
  85352. export var cellPixelShader: {
  85353. name: string;
  85354. shader: string;
  85355. };
  85356. }
  85357. declare module BABYLON {
  85358. /** @hidden */
  85359. export var cellVertexShader: {
  85360. name: string;
  85361. shader: string;
  85362. };
  85363. }
  85364. declare module BABYLON {
  85365. export class CellMaterial extends BABYLON.PushMaterial {
  85366. private _diffuseTexture;
  85367. diffuseTexture: BABYLON.BaseTexture;
  85368. diffuseColor: BABYLON.Color3;
  85369. _computeHighLevel: boolean;
  85370. computeHighLevel: boolean;
  85371. private _disableLighting;
  85372. disableLighting: boolean;
  85373. private _maxSimultaneousLights;
  85374. maxSimultaneousLights: number;
  85375. constructor(name: string, scene: BABYLON.Scene);
  85376. needAlphaBlending(): boolean;
  85377. needAlphaTesting(): boolean;
  85378. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85380. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85381. getAnimatables(): BABYLON.IAnimatable[];
  85382. getActiveTextures(): BABYLON.BaseTexture[];
  85383. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85384. dispose(forceDisposeEffect?: boolean): void;
  85385. getClassName(): string;
  85386. clone(name: string): CellMaterial;
  85387. serialize(): any;
  85388. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85389. }
  85390. }
  85391. declare module BABYLON {
  85392. export class CustomShaderStructure {
  85393. FragmentStore: string;
  85394. VertexStore: string;
  85395. constructor();
  85396. }
  85397. export class ShaderSpecialParts {
  85398. constructor();
  85399. Fragment_Begin: string;
  85400. Fragment_Definitions: string;
  85401. Fragment_MainBegin: string;
  85402. Fragment_Custom_Diffuse: string;
  85403. Fragment_Before_Lights: string;
  85404. Fragment_Before_Fog: string;
  85405. Fragment_Custom_Alpha: string;
  85406. Fragment_Before_FragColor: string;
  85407. Vertex_Begin: string;
  85408. Vertex_Definitions: string;
  85409. Vertex_MainBegin: string;
  85410. Vertex_Before_PositionUpdated: string;
  85411. Vertex_Before_NormalUpdated: string;
  85412. Vertex_After_WorldPosComputed: string;
  85413. Vertex_MainEnd: string;
  85414. }
  85415. export class CustomMaterial extends BABYLON.StandardMaterial {
  85416. static ShaderIndexer: number;
  85417. CustomParts: ShaderSpecialParts;
  85418. _isCreatedShader: boolean;
  85419. _createdShaderName: string;
  85420. _customUniform: string[];
  85421. _newUniforms: string[];
  85422. _newUniformInstances: {
  85423. [name: string]: any;
  85424. };
  85425. _newSamplerInstances: {
  85426. [name: string]: BABYLON.Texture;
  85427. };
  85428. _customAttributes: string[];
  85429. FragmentShader: string;
  85430. VertexShader: string;
  85431. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85432. ReviewUniform(name: string, arr: string[]): string[];
  85433. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85434. constructor(name: string, scene: BABYLON.Scene);
  85435. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85436. AddAttribute(name: string): CustomMaterial;
  85437. Fragment_Begin(shaderPart: string): CustomMaterial;
  85438. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85439. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85440. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85441. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85442. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85443. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85444. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85445. Vertex_Begin(shaderPart: string): CustomMaterial;
  85446. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85447. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85448. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85449. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85450. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85451. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85452. }
  85453. }
  85454. declare module BABYLON {
  85455. export class ShaderAlebdoParts {
  85456. constructor();
  85457. Fragment_Begin: string;
  85458. Fragment_Definitions: string;
  85459. Fragment_MainBegin: string;
  85460. Fragment_Custom_Albedo: string;
  85461. Fragment_Before_Lights: string;
  85462. Fragment_Custom_MetallicRoughness: string;
  85463. Fragment_Custom_MicroSurface: string;
  85464. Fragment_Before_Fog: string;
  85465. Fragment_Custom_Alpha: string;
  85466. Fragment_Before_FragColor: string;
  85467. Vertex_Begin: string;
  85468. Vertex_Definitions: string;
  85469. Vertex_MainBegin: string;
  85470. Vertex_Before_PositionUpdated: string;
  85471. Vertex_Before_NormalUpdated: string;
  85472. Vertex_After_WorldPosComputed: string;
  85473. Vertex_MainEnd: string;
  85474. }
  85475. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85476. static ShaderIndexer: number;
  85477. CustomParts: ShaderAlebdoParts;
  85478. _isCreatedShader: boolean;
  85479. _createdShaderName: string;
  85480. _customUniform: string[];
  85481. _newUniforms: string[];
  85482. _newUniformInstances: {
  85483. [name: string]: any;
  85484. };
  85485. _newSamplerInstances: {
  85486. [name: string]: BABYLON.Texture;
  85487. };
  85488. _customAttributes: string[];
  85489. FragmentShader: string;
  85490. VertexShader: string;
  85491. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85492. ReviewUniform(name: string, arr: string[]): string[];
  85493. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85494. constructor(name: string, scene: BABYLON.Scene);
  85495. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85496. AddAttribute(name: string): PBRCustomMaterial;
  85497. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85498. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85499. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85500. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85501. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85502. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85503. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85504. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85505. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85506. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85507. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85508. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85509. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85510. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85511. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85512. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85513. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85514. }
  85515. }
  85516. declare module BABYLON {
  85517. /** @hidden */
  85518. export var firePixelShader: {
  85519. name: string;
  85520. shader: string;
  85521. };
  85522. }
  85523. declare module BABYLON {
  85524. /** @hidden */
  85525. export var fireVertexShader: {
  85526. name: string;
  85527. shader: string;
  85528. };
  85529. }
  85530. declare module BABYLON {
  85531. export class FireMaterial extends BABYLON.PushMaterial {
  85532. private _diffuseTexture;
  85533. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85534. private _distortionTexture;
  85535. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85536. private _opacityTexture;
  85537. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85538. diffuseColor: BABYLON.Color3;
  85539. speed: number;
  85540. private _scaledDiffuse;
  85541. private _lastTime;
  85542. constructor(name: string, scene: BABYLON.Scene);
  85543. needAlphaBlending(): boolean;
  85544. needAlphaTesting(): boolean;
  85545. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85546. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85547. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85548. getAnimatables(): BABYLON.IAnimatable[];
  85549. getActiveTextures(): BABYLON.BaseTexture[];
  85550. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85551. getClassName(): string;
  85552. dispose(forceDisposeEffect?: boolean): void;
  85553. clone(name: string): FireMaterial;
  85554. serialize(): any;
  85555. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85556. }
  85557. }
  85558. declare module BABYLON {
  85559. /** @hidden */
  85560. export var furPixelShader: {
  85561. name: string;
  85562. shader: string;
  85563. };
  85564. }
  85565. declare module BABYLON {
  85566. /** @hidden */
  85567. export var furVertexShader: {
  85568. name: string;
  85569. shader: string;
  85570. };
  85571. }
  85572. declare module BABYLON {
  85573. export class FurMaterial extends BABYLON.PushMaterial {
  85574. private _diffuseTexture;
  85575. diffuseTexture: BABYLON.BaseTexture;
  85576. private _heightTexture;
  85577. heightTexture: BABYLON.BaseTexture;
  85578. diffuseColor: BABYLON.Color3;
  85579. furLength: number;
  85580. furAngle: number;
  85581. furColor: BABYLON.Color3;
  85582. furOffset: number;
  85583. furSpacing: number;
  85584. furGravity: BABYLON.Vector3;
  85585. furSpeed: number;
  85586. furDensity: number;
  85587. furOcclusion: number;
  85588. furTexture: BABYLON.DynamicTexture;
  85589. private _disableLighting;
  85590. disableLighting: boolean;
  85591. private _maxSimultaneousLights;
  85592. maxSimultaneousLights: number;
  85593. highLevelFur: boolean;
  85594. _meshes: BABYLON.AbstractMesh[];
  85595. private _furTime;
  85596. constructor(name: string, scene: BABYLON.Scene);
  85597. get furTime(): number;
  85598. set furTime(furTime: number);
  85599. needAlphaBlending(): boolean;
  85600. needAlphaTesting(): boolean;
  85601. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85602. updateFur(): void;
  85603. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85604. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85605. getAnimatables(): BABYLON.IAnimatable[];
  85606. getActiveTextures(): BABYLON.BaseTexture[];
  85607. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85608. dispose(forceDisposeEffect?: boolean): void;
  85609. clone(name: string): FurMaterial;
  85610. serialize(): any;
  85611. getClassName(): string;
  85612. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85613. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85614. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85615. }
  85616. }
  85617. declare module BABYLON {
  85618. /** @hidden */
  85619. export var gradientPixelShader: {
  85620. name: string;
  85621. shader: string;
  85622. };
  85623. }
  85624. declare module BABYLON {
  85625. /** @hidden */
  85626. export var gradientVertexShader: {
  85627. name: string;
  85628. shader: string;
  85629. };
  85630. }
  85631. declare module BABYLON {
  85632. export class GradientMaterial extends BABYLON.PushMaterial {
  85633. private _maxSimultaneousLights;
  85634. maxSimultaneousLights: number;
  85635. topColor: BABYLON.Color3;
  85636. topColorAlpha: number;
  85637. bottomColor: BABYLON.Color3;
  85638. bottomColorAlpha: number;
  85639. offset: number;
  85640. scale: number;
  85641. smoothness: number;
  85642. private _disableLighting;
  85643. disableLighting: boolean;
  85644. constructor(name: string, scene: BABYLON.Scene);
  85645. needAlphaBlending(): boolean;
  85646. needAlphaTesting(): boolean;
  85647. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85648. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85649. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85650. getAnimatables(): BABYLON.IAnimatable[];
  85651. dispose(forceDisposeEffect?: boolean): void;
  85652. clone(name: string): GradientMaterial;
  85653. serialize(): any;
  85654. getClassName(): string;
  85655. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85656. }
  85657. }
  85658. declare module BABYLON {
  85659. /** @hidden */
  85660. export var gridPixelShader: {
  85661. name: string;
  85662. shader: string;
  85663. };
  85664. }
  85665. declare module BABYLON {
  85666. /** @hidden */
  85667. export var gridVertexShader: {
  85668. name: string;
  85669. shader: string;
  85670. };
  85671. }
  85672. declare module BABYLON {
  85673. /**
  85674. * The grid materials allows you to wrap any shape with a grid.
  85675. * Colors are customizable.
  85676. */
  85677. export class GridMaterial extends BABYLON.PushMaterial {
  85678. /**
  85679. * Main color of the grid (e.g. between lines)
  85680. */
  85681. mainColor: BABYLON.Color3;
  85682. /**
  85683. * Color of the grid lines.
  85684. */
  85685. lineColor: BABYLON.Color3;
  85686. /**
  85687. * The scale of the grid compared to unit.
  85688. */
  85689. gridRatio: number;
  85690. /**
  85691. * Allows setting an offset for the grid lines.
  85692. */
  85693. gridOffset: BABYLON.Vector3;
  85694. /**
  85695. * The frequency of thicker lines.
  85696. */
  85697. majorUnitFrequency: number;
  85698. /**
  85699. * The visibility of minor units in the grid.
  85700. */
  85701. minorUnitVisibility: number;
  85702. /**
  85703. * The grid opacity outside of the lines.
  85704. */
  85705. opacity: number;
  85706. /**
  85707. * Determine RBG output is premultiplied by alpha value.
  85708. */
  85709. preMultiplyAlpha: boolean;
  85710. private _opacityTexture;
  85711. opacityTexture: BABYLON.BaseTexture;
  85712. private _gridControl;
  85713. /**
  85714. * constructor
  85715. * @param name The name given to the material in order to identify it afterwards.
  85716. * @param scene The scene the material is used in.
  85717. */
  85718. constructor(name: string, scene: BABYLON.Scene);
  85719. /**
  85720. * Returns wehter or not the grid requires alpha blending.
  85721. */
  85722. needAlphaBlending(): boolean;
  85723. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85724. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85725. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85726. /**
  85727. * Dispose the material and its associated resources.
  85728. * @param forceDisposeEffect will also dispose the used effect when true
  85729. */
  85730. dispose(forceDisposeEffect?: boolean): void;
  85731. clone(name: string): GridMaterial;
  85732. serialize(): any;
  85733. getClassName(): string;
  85734. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85735. }
  85736. }
  85737. declare module BABYLON {
  85738. /** @hidden */
  85739. export var lavaPixelShader: {
  85740. name: string;
  85741. shader: string;
  85742. };
  85743. }
  85744. declare module BABYLON {
  85745. /** @hidden */
  85746. export var lavaVertexShader: {
  85747. name: string;
  85748. shader: string;
  85749. };
  85750. }
  85751. declare module BABYLON {
  85752. export class LavaMaterial extends BABYLON.PushMaterial {
  85753. private _diffuseTexture;
  85754. diffuseTexture: BABYLON.BaseTexture;
  85755. noiseTexture: BABYLON.BaseTexture;
  85756. fogColor: BABYLON.Color3;
  85757. speed: number;
  85758. movingSpeed: number;
  85759. lowFrequencySpeed: number;
  85760. fogDensity: number;
  85761. private _lastTime;
  85762. diffuseColor: BABYLON.Color3;
  85763. private _disableLighting;
  85764. disableLighting: boolean;
  85765. private _unlit;
  85766. unlit: boolean;
  85767. private _maxSimultaneousLights;
  85768. maxSimultaneousLights: number;
  85769. private _scaledDiffuse;
  85770. constructor(name: string, scene: BABYLON.Scene);
  85771. needAlphaBlending(): boolean;
  85772. needAlphaTesting(): boolean;
  85773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85776. getAnimatables(): BABYLON.IAnimatable[];
  85777. getActiveTextures(): BABYLON.BaseTexture[];
  85778. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85779. dispose(forceDisposeEffect?: boolean): void;
  85780. clone(name: string): LavaMaterial;
  85781. serialize(): any;
  85782. getClassName(): string;
  85783. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85784. }
  85785. }
  85786. declare module BABYLON {
  85787. /** @hidden */
  85788. export var mixPixelShader: {
  85789. name: string;
  85790. shader: string;
  85791. };
  85792. }
  85793. declare module BABYLON {
  85794. /** @hidden */
  85795. export var mixVertexShader: {
  85796. name: string;
  85797. shader: string;
  85798. };
  85799. }
  85800. declare module BABYLON {
  85801. export class MixMaterial extends BABYLON.PushMaterial {
  85802. /**
  85803. * Mix textures
  85804. */
  85805. private _mixTexture1;
  85806. mixTexture1: BABYLON.BaseTexture;
  85807. private _mixTexture2;
  85808. mixTexture2: BABYLON.BaseTexture;
  85809. /**
  85810. * Diffuse textures
  85811. */
  85812. private _diffuseTexture1;
  85813. diffuseTexture1: BABYLON.Texture;
  85814. private _diffuseTexture2;
  85815. diffuseTexture2: BABYLON.Texture;
  85816. private _diffuseTexture3;
  85817. diffuseTexture3: BABYLON.Texture;
  85818. private _diffuseTexture4;
  85819. diffuseTexture4: BABYLON.Texture;
  85820. private _diffuseTexture5;
  85821. diffuseTexture5: BABYLON.Texture;
  85822. private _diffuseTexture6;
  85823. diffuseTexture6: BABYLON.Texture;
  85824. private _diffuseTexture7;
  85825. diffuseTexture7: BABYLON.Texture;
  85826. private _diffuseTexture8;
  85827. diffuseTexture8: BABYLON.Texture;
  85828. /**
  85829. * Uniforms
  85830. */
  85831. diffuseColor: BABYLON.Color3;
  85832. specularColor: BABYLON.Color3;
  85833. specularPower: number;
  85834. private _disableLighting;
  85835. disableLighting: boolean;
  85836. private _maxSimultaneousLights;
  85837. maxSimultaneousLights: number;
  85838. constructor(name: string, scene: BABYLON.Scene);
  85839. needAlphaBlending(): boolean;
  85840. needAlphaTesting(): boolean;
  85841. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85844. getAnimatables(): BABYLON.IAnimatable[];
  85845. getActiveTextures(): BABYLON.BaseTexture[];
  85846. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85847. dispose(forceDisposeEffect?: boolean): void;
  85848. clone(name: string): MixMaterial;
  85849. serialize(): any;
  85850. getClassName(): string;
  85851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. /** @hidden */
  85856. export var normalPixelShader: {
  85857. name: string;
  85858. shader: string;
  85859. };
  85860. }
  85861. declare module BABYLON {
  85862. /** @hidden */
  85863. export var normalVertexShader: {
  85864. name: string;
  85865. shader: string;
  85866. };
  85867. }
  85868. declare module BABYLON {
  85869. export class NormalMaterial extends BABYLON.PushMaterial {
  85870. private _diffuseTexture;
  85871. diffuseTexture: BABYLON.BaseTexture;
  85872. diffuseColor: BABYLON.Color3;
  85873. private _disableLighting;
  85874. disableLighting: boolean;
  85875. private _maxSimultaneousLights;
  85876. maxSimultaneousLights: number;
  85877. constructor(name: string, scene: BABYLON.Scene);
  85878. needAlphaBlending(): boolean;
  85879. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85880. needAlphaTesting(): boolean;
  85881. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85884. getAnimatables(): BABYLON.IAnimatable[];
  85885. getActiveTextures(): BABYLON.BaseTexture[];
  85886. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85887. dispose(forceDisposeEffect?: boolean): void;
  85888. clone(name: string): NormalMaterial;
  85889. serialize(): any;
  85890. getClassName(): string;
  85891. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85892. }
  85893. }
  85894. declare module BABYLON {
  85895. /** @hidden */
  85896. export var shadowOnlyPixelShader: {
  85897. name: string;
  85898. shader: string;
  85899. };
  85900. }
  85901. declare module BABYLON {
  85902. /** @hidden */
  85903. export var shadowOnlyVertexShader: {
  85904. name: string;
  85905. shader: string;
  85906. };
  85907. }
  85908. declare module BABYLON {
  85909. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85910. private _activeLight;
  85911. private _needAlphaBlending;
  85912. constructor(name: string, scene: BABYLON.Scene);
  85913. shadowColor: BABYLON.Color3;
  85914. needAlphaBlending(): boolean;
  85915. needAlphaTesting(): boolean;
  85916. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85917. get activeLight(): BABYLON.IShadowLight;
  85918. set activeLight(light: BABYLON.IShadowLight);
  85919. private _getFirstShadowLightForMesh;
  85920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85922. clone(name: string): ShadowOnlyMaterial;
  85923. serialize(): any;
  85924. getClassName(): string;
  85925. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85926. }
  85927. }
  85928. declare module BABYLON {
  85929. /** @hidden */
  85930. export var simplePixelShader: {
  85931. name: string;
  85932. shader: string;
  85933. };
  85934. }
  85935. declare module BABYLON {
  85936. /** @hidden */
  85937. export var simpleVertexShader: {
  85938. name: string;
  85939. shader: string;
  85940. };
  85941. }
  85942. declare module BABYLON {
  85943. export class SimpleMaterial extends BABYLON.PushMaterial {
  85944. private _diffuseTexture;
  85945. diffuseTexture: BABYLON.BaseTexture;
  85946. diffuseColor: BABYLON.Color3;
  85947. private _disableLighting;
  85948. disableLighting: boolean;
  85949. private _maxSimultaneousLights;
  85950. maxSimultaneousLights: number;
  85951. constructor(name: string, scene: BABYLON.Scene);
  85952. needAlphaBlending(): boolean;
  85953. needAlphaTesting(): boolean;
  85954. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85956. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85957. getAnimatables(): BABYLON.IAnimatable[];
  85958. getActiveTextures(): BABYLON.BaseTexture[];
  85959. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85960. dispose(forceDisposeEffect?: boolean): void;
  85961. clone(name: string): SimpleMaterial;
  85962. serialize(): any;
  85963. getClassName(): string;
  85964. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85965. }
  85966. }
  85967. declare module BABYLON {
  85968. /** @hidden */
  85969. export var skyPixelShader: {
  85970. name: string;
  85971. shader: string;
  85972. };
  85973. }
  85974. declare module BABYLON {
  85975. /** @hidden */
  85976. export var skyVertexShader: {
  85977. name: string;
  85978. shader: string;
  85979. };
  85980. }
  85981. declare module BABYLON {
  85982. /**
  85983. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85984. * @see https://doc.babylonjs.com/extensions/sky
  85985. */
  85986. export class SkyMaterial extends BABYLON.PushMaterial {
  85987. /**
  85988. * Defines the overall luminance of sky in interval ]0, 1[.
  85989. */
  85990. luminance: number;
  85991. /**
  85992. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85993. */
  85994. turbidity: number;
  85995. /**
  85996. * Defines the sky appearance (light intensity).
  85997. */
  85998. rayleigh: number;
  85999. /**
  86000. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86001. */
  86002. mieCoefficient: number;
  86003. /**
  86004. * Defines the amount of haze particles following the Mie scattering theory.
  86005. */
  86006. mieDirectionalG: number;
  86007. /**
  86008. * Defines the distance of the sun according to the active scene camera.
  86009. */
  86010. distance: number;
  86011. /**
  86012. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86013. * "inclined".
  86014. */
  86015. inclination: number;
  86016. /**
  86017. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86018. * an object direction and a reference direction.
  86019. */
  86020. azimuth: number;
  86021. /**
  86022. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86023. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86024. */
  86025. sunPosition: BABYLON.Vector3;
  86026. /**
  86027. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86028. * .sunPosition property.
  86029. */
  86030. useSunPosition: boolean;
  86031. /**
  86032. * Defines an offset vector used to get a horizon offset.
  86033. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86034. */
  86035. cameraOffset: BABYLON.Vector3;
  86036. private _cameraPosition;
  86037. /**
  86038. * Instantiates a new sky material.
  86039. * This material allows to create dynamic and texture free
  86040. * effects for skyboxes by taking care of the atmosphere state.
  86041. * @see https://doc.babylonjs.com/extensions/sky
  86042. * @param name Define the name of the material in the scene
  86043. * @param scene Define the scene the material belong to
  86044. */
  86045. constructor(name: string, scene: BABYLON.Scene);
  86046. /**
  86047. * Specifies if the material will require alpha blending
  86048. * @returns a boolean specifying if alpha blending is needed
  86049. */
  86050. needAlphaBlending(): boolean;
  86051. /**
  86052. * Specifies if this material should be rendered in alpha test mode
  86053. * @returns false as the sky material doesn't need alpha testing.
  86054. */
  86055. needAlphaTesting(): boolean;
  86056. /**
  86057. * Get the texture used for alpha test purpose.
  86058. * @returns null as the sky material has no texture.
  86059. */
  86060. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86061. /**
  86062. * Get if the submesh is ready to be used and all its information available.
  86063. * Child classes can use it to update shaders
  86064. * @param mesh defines the mesh to check
  86065. * @param subMesh defines which submesh to check
  86066. * @param useInstances specifies that instances should be used
  86067. * @returns a boolean indicating that the submesh is ready or not
  86068. */
  86069. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86070. /**
  86071. * Binds the submesh to this material by preparing the effect and shader to draw
  86072. * @param world defines the world transformation matrix
  86073. * @param mesh defines the mesh containing the submesh
  86074. * @param subMesh defines the submesh to bind the material to
  86075. */
  86076. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86077. /**
  86078. * Get the list of animatables in the material.
  86079. * @returns the list of animatables object used in the material
  86080. */
  86081. getAnimatables(): BABYLON.IAnimatable[];
  86082. /**
  86083. * Disposes the material
  86084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86085. */
  86086. dispose(forceDisposeEffect?: boolean): void;
  86087. /**
  86088. * Makes a duplicate of the material, and gives it a new name
  86089. * @param name defines the new name for the duplicated material
  86090. * @returns the cloned material
  86091. */
  86092. clone(name: string): SkyMaterial;
  86093. /**
  86094. * Serializes this material in a JSON representation
  86095. * @returns the serialized material object
  86096. */
  86097. serialize(): any;
  86098. /**
  86099. * Gets the current class name of the material e.g. "SkyMaterial"
  86100. * Mainly use in serialization.
  86101. * @returns the class name
  86102. */
  86103. getClassName(): string;
  86104. /**
  86105. * Creates a sky material from parsed material data
  86106. * @param source defines the JSON representation of the material
  86107. * @param scene defines the hosting scene
  86108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86109. * @returns a new sky material
  86110. */
  86111. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86112. }
  86113. }
  86114. declare module BABYLON {
  86115. /** @hidden */
  86116. export var terrainPixelShader: {
  86117. name: string;
  86118. shader: string;
  86119. };
  86120. }
  86121. declare module BABYLON {
  86122. /** @hidden */
  86123. export var terrainVertexShader: {
  86124. name: string;
  86125. shader: string;
  86126. };
  86127. }
  86128. declare module BABYLON {
  86129. export class TerrainMaterial extends BABYLON.PushMaterial {
  86130. private _mixTexture;
  86131. mixTexture: BABYLON.BaseTexture;
  86132. private _diffuseTexture1;
  86133. diffuseTexture1: BABYLON.Texture;
  86134. private _diffuseTexture2;
  86135. diffuseTexture2: BABYLON.Texture;
  86136. private _diffuseTexture3;
  86137. diffuseTexture3: BABYLON.Texture;
  86138. private _bumpTexture1;
  86139. bumpTexture1: BABYLON.Texture;
  86140. private _bumpTexture2;
  86141. bumpTexture2: BABYLON.Texture;
  86142. private _bumpTexture3;
  86143. bumpTexture3: BABYLON.Texture;
  86144. diffuseColor: BABYLON.Color3;
  86145. specularColor: BABYLON.Color3;
  86146. specularPower: number;
  86147. private _disableLighting;
  86148. disableLighting: boolean;
  86149. private _maxSimultaneousLights;
  86150. maxSimultaneousLights: number;
  86151. constructor(name: string, scene: BABYLON.Scene);
  86152. needAlphaBlending(): boolean;
  86153. needAlphaTesting(): boolean;
  86154. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86155. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86156. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86157. getAnimatables(): BABYLON.IAnimatable[];
  86158. getActiveTextures(): BABYLON.BaseTexture[];
  86159. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86160. dispose(forceDisposeEffect?: boolean): void;
  86161. clone(name: string): TerrainMaterial;
  86162. serialize(): any;
  86163. getClassName(): string;
  86164. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86165. }
  86166. }
  86167. declare module BABYLON {
  86168. /** @hidden */
  86169. export var triplanarPixelShader: {
  86170. name: string;
  86171. shader: string;
  86172. };
  86173. }
  86174. declare module BABYLON {
  86175. /** @hidden */
  86176. export var triplanarVertexShader: {
  86177. name: string;
  86178. shader: string;
  86179. };
  86180. }
  86181. declare module BABYLON {
  86182. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86183. mixTexture: BABYLON.BaseTexture;
  86184. private _diffuseTextureX;
  86185. diffuseTextureX: BABYLON.BaseTexture;
  86186. private _diffuseTextureY;
  86187. diffuseTextureY: BABYLON.BaseTexture;
  86188. private _diffuseTextureZ;
  86189. diffuseTextureZ: BABYLON.BaseTexture;
  86190. private _normalTextureX;
  86191. normalTextureX: BABYLON.BaseTexture;
  86192. private _normalTextureY;
  86193. normalTextureY: BABYLON.BaseTexture;
  86194. private _normalTextureZ;
  86195. normalTextureZ: BABYLON.BaseTexture;
  86196. tileSize: number;
  86197. diffuseColor: BABYLON.Color3;
  86198. specularColor: BABYLON.Color3;
  86199. specularPower: number;
  86200. private _disableLighting;
  86201. disableLighting: boolean;
  86202. private _maxSimultaneousLights;
  86203. maxSimultaneousLights: number;
  86204. constructor(name: string, scene: BABYLON.Scene);
  86205. needAlphaBlending(): boolean;
  86206. needAlphaTesting(): boolean;
  86207. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86208. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86209. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86210. getAnimatables(): BABYLON.IAnimatable[];
  86211. getActiveTextures(): BABYLON.BaseTexture[];
  86212. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86213. dispose(forceDisposeEffect?: boolean): void;
  86214. clone(name: string): TriPlanarMaterial;
  86215. serialize(): any;
  86216. getClassName(): string;
  86217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86218. }
  86219. }
  86220. declare module BABYLON {
  86221. /** @hidden */
  86222. export var waterPixelShader: {
  86223. name: string;
  86224. shader: string;
  86225. };
  86226. }
  86227. declare module BABYLON {
  86228. /** @hidden */
  86229. export var waterVertexShader: {
  86230. name: string;
  86231. shader: string;
  86232. };
  86233. }
  86234. declare module BABYLON {
  86235. export class WaterMaterial extends BABYLON.PushMaterial {
  86236. renderTargetSize: BABYLON.Vector2;
  86237. private _bumpTexture;
  86238. bumpTexture: BABYLON.BaseTexture;
  86239. diffuseColor: BABYLON.Color3;
  86240. specularColor: BABYLON.Color3;
  86241. specularPower: number;
  86242. private _disableLighting;
  86243. disableLighting: boolean;
  86244. private _maxSimultaneousLights;
  86245. maxSimultaneousLights: number;
  86246. /**
  86247. * @param {number}: Represents the wind force
  86248. */
  86249. windForce: number;
  86250. /**
  86251. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86252. */
  86253. windDirection: BABYLON.Vector2;
  86254. /**
  86255. * @param {number}: Wave height, represents the height of the waves
  86256. */
  86257. waveHeight: number;
  86258. /**
  86259. * @param {number}: Bump height, represents the bump height related to the bump map
  86260. */
  86261. bumpHeight: number;
  86262. /**
  86263. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86264. */
  86265. private _bumpSuperimpose;
  86266. bumpSuperimpose: boolean;
  86267. /**
  86268. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86269. */
  86270. private _fresnelSeparate;
  86271. fresnelSeparate: boolean;
  86272. /**
  86273. * @param {boolean}: bump Waves modify the reflection.
  86274. */
  86275. private _bumpAffectsReflection;
  86276. bumpAffectsReflection: boolean;
  86277. /**
  86278. * @param {number}: The water color blended with the refraction (near)
  86279. */
  86280. waterColor: BABYLON.Color3;
  86281. /**
  86282. * @param {number}: The blend factor related to the water color
  86283. */
  86284. colorBlendFactor: number;
  86285. /**
  86286. * @param {number}: The water color blended with the reflection (far)
  86287. */
  86288. waterColor2: BABYLON.Color3;
  86289. /**
  86290. * @param {number}: The blend factor related to the water color (reflection, far)
  86291. */
  86292. colorBlendFactor2: number;
  86293. /**
  86294. * @param {number}: Represents the maximum length of a wave
  86295. */
  86296. waveLength: number;
  86297. /**
  86298. * @param {number}: Defines the waves speed
  86299. */
  86300. waveSpeed: number;
  86301. /**
  86302. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86303. * will avoid calculating useless pixels in the pixel shader of the water material.
  86304. */
  86305. disableClipPlane: boolean;
  86306. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86307. private _mesh;
  86308. private _refractionRTT;
  86309. private _reflectionRTT;
  86310. private _reflectionTransform;
  86311. private _lastTime;
  86312. private _lastDeltaTime;
  86313. private _useLogarithmicDepth;
  86314. private _waitingRenderList;
  86315. private _imageProcessingConfiguration;
  86316. private _imageProcessingObserver;
  86317. /**
  86318. * Gets a boolean indicating that current material needs to register RTT
  86319. */
  86320. get hasRenderTargetTextures(): boolean;
  86321. /**
  86322. * Constructor
  86323. */
  86324. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86325. get useLogarithmicDepth(): boolean;
  86326. set useLogarithmicDepth(value: boolean);
  86327. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86328. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86329. addToRenderList(node: any): void;
  86330. enableRenderTargets(enable: boolean): void;
  86331. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86332. get renderTargetsEnabled(): boolean;
  86333. needAlphaBlending(): boolean;
  86334. needAlphaTesting(): boolean;
  86335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86336. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86337. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86338. private _createRenderTargets;
  86339. getAnimatables(): BABYLON.IAnimatable[];
  86340. getActiveTextures(): BABYLON.BaseTexture[];
  86341. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86342. dispose(forceDisposeEffect?: boolean): void;
  86343. clone(name: string): WaterMaterial;
  86344. serialize(): any;
  86345. getClassName(): string;
  86346. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86347. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86348. }
  86349. }
  86350. declare module BABYLON {
  86351. /** @hidden */
  86352. export var asciiartPixelShader: {
  86353. name: string;
  86354. shader: string;
  86355. };
  86356. }
  86357. declare module BABYLON {
  86358. /**
  86359. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86360. *
  86361. * It basically takes care rendering the font front the given font size to a texture.
  86362. * This is used later on in the postprocess.
  86363. */
  86364. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86365. private _font;
  86366. private _text;
  86367. private _charSize;
  86368. /**
  86369. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86370. */
  86371. get charSize(): number;
  86372. /**
  86373. * Create a new instance of the Ascii Art FontTexture class
  86374. * @param name the name of the texture
  86375. * @param font the font to use, use the W3C CSS notation
  86376. * @param text the caracter set to use in the rendering.
  86377. * @param scene the scene that owns the texture
  86378. */
  86379. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86380. /**
  86381. * Gets the max char width of a font.
  86382. * @param font the font to use, use the W3C CSS notation
  86383. * @return the max char width
  86384. */
  86385. private getFontWidth;
  86386. /**
  86387. * Gets the max char height of a font.
  86388. * @param font the font to use, use the W3C CSS notation
  86389. * @return the max char height
  86390. */
  86391. private getFontHeight;
  86392. /**
  86393. * Clones the current AsciiArtTexture.
  86394. * @return the clone of the texture.
  86395. */
  86396. clone(): AsciiArtFontTexture;
  86397. /**
  86398. * Parses a json object representing the texture and returns an instance of it.
  86399. * @param source the source JSON representation
  86400. * @param scene the scene to create the texture for
  86401. * @return the parsed texture
  86402. */
  86403. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86404. }
  86405. /**
  86406. * Option available in the Ascii Art Post Process.
  86407. */
  86408. export interface IAsciiArtPostProcessOptions {
  86409. /**
  86410. * The font to use following the w3c font definition.
  86411. */
  86412. font?: string;
  86413. /**
  86414. * The character set to use in the postprocess.
  86415. */
  86416. characterSet?: string;
  86417. /**
  86418. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86419. * This number is defined between 0 and 1;
  86420. */
  86421. mixToTile?: number;
  86422. /**
  86423. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86424. * This number is defined between 0 and 1;
  86425. */
  86426. mixToNormal?: number;
  86427. }
  86428. /**
  86429. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86430. *
  86431. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86432. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86433. */
  86434. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86435. /**
  86436. * The font texture used to render the char in the post process.
  86437. */
  86438. private _asciiArtFontTexture;
  86439. /**
  86440. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86441. * This number is defined between 0 and 1;
  86442. */
  86443. mixToTile: number;
  86444. /**
  86445. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86446. * This number is defined between 0 and 1;
  86447. */
  86448. mixToNormal: number;
  86449. /**
  86450. * Instantiates a new Ascii Art Post Process.
  86451. * @param name the name to give to the postprocess
  86452. * @camera the camera to apply the post process to.
  86453. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86454. */
  86455. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86456. }
  86457. }
  86458. declare module BABYLON {
  86459. /** @hidden */
  86460. export var digitalrainPixelShader: {
  86461. name: string;
  86462. shader: string;
  86463. };
  86464. }
  86465. declare module BABYLON {
  86466. /**
  86467. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86468. *
  86469. * It basically takes care rendering the font front the given font size to a texture.
  86470. * This is used later on in the postprocess.
  86471. */
  86472. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86473. private _font;
  86474. private _text;
  86475. private _charSize;
  86476. /**
  86477. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86478. */
  86479. get charSize(): number;
  86480. /**
  86481. * Create a new instance of the Digital Rain FontTexture class
  86482. * @param name the name of the texture
  86483. * @param font the font to use, use the W3C CSS notation
  86484. * @param text the caracter set to use in the rendering.
  86485. * @param scene the scene that owns the texture
  86486. */
  86487. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86488. /**
  86489. * Gets the max char width of a font.
  86490. * @param font the font to use, use the W3C CSS notation
  86491. * @return the max char width
  86492. */
  86493. private getFontWidth;
  86494. /**
  86495. * Gets the max char height of a font.
  86496. * @param font the font to use, use the W3C CSS notation
  86497. * @return the max char height
  86498. */
  86499. private getFontHeight;
  86500. /**
  86501. * Clones the current DigitalRainFontTexture.
  86502. * @return the clone of the texture.
  86503. */
  86504. clone(): DigitalRainFontTexture;
  86505. /**
  86506. * Parses a json object representing the texture and returns an instance of it.
  86507. * @param source the source JSON representation
  86508. * @param scene the scene to create the texture for
  86509. * @return the parsed texture
  86510. */
  86511. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86512. }
  86513. /**
  86514. * Option available in the Digital Rain Post Process.
  86515. */
  86516. export interface IDigitalRainPostProcessOptions {
  86517. /**
  86518. * The font to use following the w3c font definition.
  86519. */
  86520. font?: string;
  86521. /**
  86522. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86523. * This number is defined between 0 and 1;
  86524. */
  86525. mixToTile?: number;
  86526. /**
  86527. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86528. * This number is defined between 0 and 1;
  86529. */
  86530. mixToNormal?: number;
  86531. }
  86532. /**
  86533. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86534. *
  86535. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86536. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86537. */
  86538. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86539. /**
  86540. * The font texture used to render the char in the post process.
  86541. */
  86542. private _digitalRainFontTexture;
  86543. /**
  86544. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86545. * This number is defined between 0 and 1;
  86546. */
  86547. mixToTile: number;
  86548. /**
  86549. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86550. * This number is defined between 0 and 1;
  86551. */
  86552. mixToNormal: number;
  86553. /**
  86554. * Instantiates a new Digital Rain Post Process.
  86555. * @param name the name to give to the postprocess
  86556. * @camera the camera to apply the post process to.
  86557. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86558. */
  86559. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86560. }
  86561. }
  86562. declare module BABYLON {
  86563. /** @hidden */
  86564. export var brickProceduralTexturePixelShader: {
  86565. name: string;
  86566. shader: string;
  86567. };
  86568. }
  86569. declare module BABYLON {
  86570. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86571. private _numberOfBricksHeight;
  86572. private _numberOfBricksWidth;
  86573. private _jointColor;
  86574. private _brickColor;
  86575. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86576. updateShaderUniforms(): void;
  86577. get numberOfBricksHeight(): number;
  86578. set numberOfBricksHeight(value: number);
  86579. get numberOfBricksWidth(): number;
  86580. set numberOfBricksWidth(value: number);
  86581. get jointColor(): BABYLON.Color3;
  86582. set jointColor(value: BABYLON.Color3);
  86583. get brickColor(): BABYLON.Color3;
  86584. set brickColor(value: BABYLON.Color3);
  86585. /**
  86586. * Serializes this brick procedural texture
  86587. * @returns a serialized brick procedural texture object
  86588. */
  86589. serialize(): any;
  86590. /**
  86591. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86592. * @param parsedTexture defines parsed texture data
  86593. * @param scene defines the current scene
  86594. * @param rootUrl defines the root URL containing brick procedural texture information
  86595. * @returns a parsed Brick Procedural BABYLON.Texture
  86596. */
  86597. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86598. }
  86599. }
  86600. declare module BABYLON {
  86601. /** @hidden */
  86602. export var cloudProceduralTexturePixelShader: {
  86603. name: string;
  86604. shader: string;
  86605. };
  86606. }
  86607. declare module BABYLON {
  86608. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86609. private _skyColor;
  86610. private _cloudColor;
  86611. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86612. updateShaderUniforms(): void;
  86613. get skyColor(): BABYLON.Color4;
  86614. set skyColor(value: BABYLON.Color4);
  86615. get cloudColor(): BABYLON.Color4;
  86616. set cloudColor(value: BABYLON.Color4);
  86617. /**
  86618. * Serializes this cloud procedural texture
  86619. * @returns a serialized cloud procedural texture object
  86620. */
  86621. serialize(): any;
  86622. /**
  86623. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86624. * @param parsedTexture defines parsed texture data
  86625. * @param scene defines the current scene
  86626. * @param rootUrl defines the root URL containing cloud procedural texture information
  86627. * @returns a parsed Cloud Procedural BABYLON.Texture
  86628. */
  86629. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86630. }
  86631. }
  86632. declare module BABYLON {
  86633. /** @hidden */
  86634. export var fireProceduralTexturePixelShader: {
  86635. name: string;
  86636. shader: string;
  86637. };
  86638. }
  86639. declare module BABYLON {
  86640. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86641. private _time;
  86642. private _speed;
  86643. private _autoGenerateTime;
  86644. private _fireColors;
  86645. private _alphaThreshold;
  86646. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86647. updateShaderUniforms(): void;
  86648. render(useCameraPostProcess?: boolean): void;
  86649. static get PurpleFireColors(): BABYLON.Color3[];
  86650. static get GreenFireColors(): BABYLON.Color3[];
  86651. static get RedFireColors(): BABYLON.Color3[];
  86652. static get BlueFireColors(): BABYLON.Color3[];
  86653. get autoGenerateTime(): boolean;
  86654. set autoGenerateTime(value: boolean);
  86655. get fireColors(): BABYLON.Color3[];
  86656. set fireColors(value: BABYLON.Color3[]);
  86657. get time(): number;
  86658. set time(value: number);
  86659. get speed(): BABYLON.Vector2;
  86660. set speed(value: BABYLON.Vector2);
  86661. get alphaThreshold(): number;
  86662. set alphaThreshold(value: number);
  86663. /**
  86664. * Serializes this fire procedural texture
  86665. * @returns a serialized fire procedural texture object
  86666. */
  86667. serialize(): any;
  86668. /**
  86669. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86670. * @param parsedTexture defines parsed texture data
  86671. * @param scene defines the current scene
  86672. * @param rootUrl defines the root URL containing fire procedural texture information
  86673. * @returns a parsed Fire Procedural BABYLON.Texture
  86674. */
  86675. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86676. }
  86677. }
  86678. declare module BABYLON {
  86679. /** @hidden */
  86680. export var grassProceduralTexturePixelShader: {
  86681. name: string;
  86682. shader: string;
  86683. };
  86684. }
  86685. declare module BABYLON {
  86686. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86687. private _grassColors;
  86688. private _groundColor;
  86689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86690. updateShaderUniforms(): void;
  86691. get grassColors(): BABYLON.Color3[];
  86692. set grassColors(value: BABYLON.Color3[]);
  86693. get groundColor(): BABYLON.Color3;
  86694. set groundColor(value: BABYLON.Color3);
  86695. /**
  86696. * Serializes this grass procedural texture
  86697. * @returns a serialized grass procedural texture object
  86698. */
  86699. serialize(): any;
  86700. /**
  86701. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86702. * @param parsedTexture defines parsed texture data
  86703. * @param scene defines the current scene
  86704. * @param rootUrl defines the root URL containing grass procedural texture information
  86705. * @returns a parsed Grass Procedural BABYLON.Texture
  86706. */
  86707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86708. }
  86709. }
  86710. declare module BABYLON {
  86711. /** @hidden */
  86712. export var marbleProceduralTexturePixelShader: {
  86713. name: string;
  86714. shader: string;
  86715. };
  86716. }
  86717. declare module BABYLON {
  86718. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86719. private _numberOfTilesHeight;
  86720. private _numberOfTilesWidth;
  86721. private _amplitude;
  86722. private _jointColor;
  86723. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86724. updateShaderUniforms(): void;
  86725. get numberOfTilesHeight(): number;
  86726. set numberOfTilesHeight(value: number);
  86727. get amplitude(): number;
  86728. set amplitude(value: number);
  86729. get numberOfTilesWidth(): number;
  86730. set numberOfTilesWidth(value: number);
  86731. get jointColor(): BABYLON.Color3;
  86732. set jointColor(value: BABYLON.Color3);
  86733. /**
  86734. * Serializes this marble procedural texture
  86735. * @returns a serialized marble procedural texture object
  86736. */
  86737. serialize(): any;
  86738. /**
  86739. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86740. * @param parsedTexture defines parsed texture data
  86741. * @param scene defines the current scene
  86742. * @param rootUrl defines the root URL containing marble procedural texture information
  86743. * @returns a parsed Marble Procedural BABYLON.Texture
  86744. */
  86745. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86746. }
  86747. }
  86748. declare module BABYLON {
  86749. /** @hidden */
  86750. export var normalMapProceduralTexturePixelShader: {
  86751. name: string;
  86752. shader: string;
  86753. };
  86754. }
  86755. declare module BABYLON {
  86756. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86757. private _baseTexture;
  86758. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86759. updateShaderUniforms(): void;
  86760. render(useCameraPostProcess?: boolean): void;
  86761. resize(size: any, generateMipMaps: any): void;
  86762. get baseTexture(): BABYLON.Texture;
  86763. set baseTexture(texture: BABYLON.Texture);
  86764. /**
  86765. * Serializes this normal map procedural texture
  86766. * @returns a serialized normal map procedural texture object
  86767. */
  86768. serialize(): any;
  86769. /**
  86770. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86771. * @param parsedTexture defines parsed texture data
  86772. * @param scene defines the current scene
  86773. * @param rootUrl defines the root URL containing normal map procedural texture information
  86774. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86775. */
  86776. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86777. }
  86778. }
  86779. declare module BABYLON {
  86780. /** @hidden */
  86781. export var perlinNoiseProceduralTexturePixelShader: {
  86782. name: string;
  86783. shader: string;
  86784. };
  86785. }
  86786. declare module BABYLON {
  86787. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86788. time: number;
  86789. timeScale: number;
  86790. translationSpeed: number;
  86791. private _currentTranslation;
  86792. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86793. updateShaderUniforms(): void;
  86794. render(useCameraPostProcess?: boolean): void;
  86795. resize(size: any, generateMipMaps: any): void;
  86796. /**
  86797. * Serializes this perlin noise procedural texture
  86798. * @returns a serialized perlin noise procedural texture object
  86799. */
  86800. serialize(): any;
  86801. /**
  86802. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86803. * @param parsedTexture defines parsed texture data
  86804. * @param scene defines the current scene
  86805. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86806. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86807. */
  86808. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86809. }
  86810. }
  86811. declare module BABYLON {
  86812. /** @hidden */
  86813. export var roadProceduralTexturePixelShader: {
  86814. name: string;
  86815. shader: string;
  86816. };
  86817. }
  86818. declare module BABYLON {
  86819. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86820. private _roadColor;
  86821. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86822. updateShaderUniforms(): void;
  86823. get roadColor(): BABYLON.Color3;
  86824. set roadColor(value: BABYLON.Color3);
  86825. /**
  86826. * Serializes this road procedural texture
  86827. * @returns a serialized road procedural texture object
  86828. */
  86829. serialize(): any;
  86830. /**
  86831. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86832. * @param parsedTexture defines parsed texture data
  86833. * @param scene defines the current scene
  86834. * @param rootUrl defines the root URL containing road procedural texture information
  86835. * @returns a parsed Road Procedural BABYLON.Texture
  86836. */
  86837. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86838. }
  86839. }
  86840. declare module BABYLON {
  86841. /** @hidden */
  86842. export var starfieldProceduralTexturePixelShader: {
  86843. name: string;
  86844. shader: string;
  86845. };
  86846. }
  86847. declare module BABYLON {
  86848. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86849. private _time;
  86850. private _alpha;
  86851. private _beta;
  86852. private _zoom;
  86853. private _formuparam;
  86854. private _stepsize;
  86855. private _tile;
  86856. private _brightness;
  86857. private _darkmatter;
  86858. private _distfading;
  86859. private _saturation;
  86860. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86861. updateShaderUniforms(): void;
  86862. get time(): number;
  86863. set time(value: number);
  86864. get alpha(): number;
  86865. set alpha(value: number);
  86866. get beta(): number;
  86867. set beta(value: number);
  86868. get formuparam(): number;
  86869. set formuparam(value: number);
  86870. get stepsize(): number;
  86871. set stepsize(value: number);
  86872. get zoom(): number;
  86873. set zoom(value: number);
  86874. get tile(): number;
  86875. set tile(value: number);
  86876. get brightness(): number;
  86877. set brightness(value: number);
  86878. get darkmatter(): number;
  86879. set darkmatter(value: number);
  86880. get distfading(): number;
  86881. set distfading(value: number);
  86882. get saturation(): number;
  86883. set saturation(value: number);
  86884. /**
  86885. * Serializes this starfield procedural texture
  86886. * @returns a serialized starfield procedural texture object
  86887. */
  86888. serialize(): any;
  86889. /**
  86890. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86891. * @param parsedTexture defines parsed texture data
  86892. * @param scene defines the current scene
  86893. * @param rootUrl defines the root URL containing startfield procedural texture information
  86894. * @returns a parsed Starfield Procedural BABYLON.Texture
  86895. */
  86896. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86897. }
  86898. }
  86899. declare module BABYLON {
  86900. /** @hidden */
  86901. export var woodProceduralTexturePixelShader: {
  86902. name: string;
  86903. shader: string;
  86904. };
  86905. }
  86906. declare module BABYLON {
  86907. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86908. private _ampScale;
  86909. private _woodColor;
  86910. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86911. updateShaderUniforms(): void;
  86912. get ampScale(): number;
  86913. set ampScale(value: number);
  86914. get woodColor(): BABYLON.Color3;
  86915. set woodColor(value: BABYLON.Color3);
  86916. /**
  86917. * Serializes this wood procedural texture
  86918. * @returns a serialized wood procedural texture object
  86919. */
  86920. serialize(): any;
  86921. /**
  86922. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86923. * @param parsedTexture defines parsed texture data
  86924. * @param scene defines the current scene
  86925. * @param rootUrl defines the root URL containing wood procedural texture information
  86926. * @returns a parsed Wood Procedural BABYLON.Texture
  86927. */
  86928. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86929. }
  86930. }